Skip to main content

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:

        try {
SubjectSum subject = SurenessSecurityManager.getInstance().checkIn(servletRequest);
} catch (ProcessorNotFoundException | UnknownAccountException | UnsupportedSubjectException e4) {
// Create subject error related execption
} catch (DisabledAccountException | ExcessiveAttemptsException e2 ) {
// Account disable related exception
} catch (IncorrectCredentialsException | ExpiredCredentialsException e3) {
// Authentication failure related exception
} catch (UnauthorizedException e5) {
// Authorization failure related exception
} catch (RuntimeException e) {
// other sureness exception
sureness exceptionexception note
SurenessAuthenticationExceptionbasic authenticated exception,Authentication related extend it
SurenessAuthorizationExceptionbasic authorized exception,Authorization related extend it
ProcessorNotFoundExceptionauthenticated,not found process support this subject
UnknownAccountExceptionauthenticated,unknown account
UnSupportedSubjectExceptionauthenticated,unSupport request
DisabledAccountExceptionauthenticated,account disable
ExcessiveAttemptsExceptionauthenticated,excessive attempts
IncorrectCredentialsExceptionauthenticated, incorrect credential
ExpiredCredentialsExceptionauthenticated,expired credential
NeedDigestInfoExceptionauthenticated, getAuthenticate() return digest information to client
UnauthorizedExceptionauthorized,no permission access this resource

Custom exception should extend SurenessAuthenticationException or SurenessAuthorizationException