default-exception.md 2.4 KB
Newer Older
sinat_25235033's avatar
sinat_25235033 已提交
1 2 3 4 5 6 7 8
## Default Sureness Auth Exception    
`sureness` uses exception handling process:  
1. If auth success, method - `checkIn` will return a `SubjectSum` object containing user information.  
2. If auth failure, method - `checkIn` will throw different types of auth exceptions, 
and users need to continue the subsequent process based on these exceptions.(like return the request response)  

Here we need to customize the exceptions thrown by `checkIn`, 
passed directly when auth success, catch exception when auth failure and do something:   
9 10 11 12 13

```
        try {
            SubjectSum subject = SurenessSecurityManager.getInstance().checkIn(servletRequest);
        } catch (ProcessorNotFoundException | UnknownAccountException | UnsupportedSubjectException e4) {
14
            // Create subject error related execption 
15
        } catch (DisabledAccountException | ExcessiveAttemptsException e2 ) {
16
            // Account disable related exception
17
        } catch (IncorrectCredentialsException | ExpiredCredentialsException e3) {
18
            // Authentication failure related exception
19
        } catch (UnauthorizedException e5) {
20
            // Authorization failure related exception
21
        } catch (RuntimeException e) {
22
            // other sureness exception
23 24 25
        }
```

sinat_25235033's avatar
sinat_25235033 已提交
26 27 28 29 30
sureness exception                     | exception note
---                                    | ---
SurenessAuthenticationException        |  basic authenticated exception,Authentication related extend it
SurenessAuthorizationException         | basic authorized exception,Authorization related extend it
ProcessorNotFoundException             | authenticated,not found process support this subject
31
UnknownAccountException                | authenticated,unknown account
sinat_25235033's avatar
sinat_25235033 已提交
32 33 34 35 36 37 38
UnSupportedSubjectException            | authenticated,unSupport request
DisabledAccountException               | authenticated,account disable
ExcessiveAttemptsException             | authenticated,excessive attempts
IncorrectCredentialsException          | authenticated, incorrect credential
ExpiredCredentialsException            | authenticated,expired credential
NeedDigestInfoException                | authenticated, getAuthenticate() return digest information to client
UnauthorizedException                  | authorized,no permission access this resource
39

40
Custom exception should extend SurenessAuthenticationException or SurenessAuthorizationException