default-exception.md 2.1 KB
Newer Older
1 2
## Default Sureness Exception    
`sureness` uses the exception handling process, we need to customize the corresponding exceptions thrown by the authentication failure or unauthorized access in the authentication process of `checkIn`.  
3

4
If the authentication is successful, it will pass directly, if it fails, a specific exception will be thrown, and the exception will be caught, eg:  
5 6 7 8
```
        try {
            SubjectSum subject = SurenessSecurityManager.getInstance().checkIn(servletRequest);
        } catch (ProcessorNotFoundException | UnknownAccountException | UnsupportedSubjectException e4) {
9
            // Create subject error related execption 
10
        } catch (DisabledAccountException | ExcessiveAttemptsException e2 ) {
11
            // Account disable related exception
12
        } catch (IncorrectCredentialsException | ExpiredCredentialsException e3) {
13
            // Authentication failure related exception
14
        } catch (UnauthorizedException e5) {
15
            // Authorization failure related exception
16
        } catch (RuntimeException e) {
17
            // other sureness exception
18 19 20
        }
```

21 22 23 24 25 26 27 28 29 30 31 32
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
UnknownAccountException                | authenticated,unknown account
UnSupportedSubjectException           | authenticated,unSupport request
DisabledAccountException                  | authenticated,account disable
ExcessiveAttemptsException                | authenticated,excessive attempts
IncorrectCredentialsException             | authenticated, incorrect credential
ExpiredCredentialsException               | authenticated,expired credential
UnauthorizedException                        | authorized,no permission access this resource
33

34
Custom exception should extend SurenessAuthenticationException or SurenessAuthorizationException