VideographerRealm extends AuthenticatingRealm { @Override public boolean supports(AuthenticationToken token) { boolean supported = token != null && token.getCredentials() != null && token instanceof VideographerAuthenticationToken; if (supported) { LOGGER.debug("The supplied authentication token is supported by {}.", getClass().getName()); } else if (token != null) { LOGGER.debug( "The supplied authentication token is not supported by {}.", getClass().getName()); } else { LOGGER.debug("The supplied authentication token is null. Sending back not supported."); } return supported; }  @Override boolean supports(AuthenticationToken token); void setAttributes(List<String> attributes); void setSecurityLogger(SecurityLogger securityLogger);  }
@Test public void testSupportsNull() { boolean supports = videographerRealm.supports(null); assertFalse(supports); }
@Test public void testSupportsVideographerToken() { BaseAuthenticationToken baseAuthenticationToken = new VideographerAuthenticationToken("127.0.0.1", mock(SecurityLogger.class)); boolean supports = videographerRealm.supports(baseAuthenticationToken); assertTrue(supports); }
@Test public void testSupportsNotBase() { AuthenticationToken authenticationToken = new AuthenticationToken() { @Override public Object getPrincipal() { return "principal"; } @Override public Object getCredentials() { return "credentials"; } }; boolean supports = videographerRealm.supports(authenticationToken); assertFalse(supports); }