VideographerAuthenticationToken extends BaseAuthenticationToken { @Override public String getIpAddress() { String ip = null; if (principal instanceof VideographerPrincipal) { ip = ((VideographerPrincipal) principal).getAddress(); } else if (principal instanceof String) { ip = VideographerPrincipal.parseAddressFromName((String) principal); } return ip; } VideographerAuthenticationToken(String ip, SecurityLogger securityLogger); @Override String getIpAddress(); @Override String toString(); static final String VIDEOGRAPHER_CREDENTIALS; }
@Test public void testConstructor() { VideographerAuthenticationToken token = new VideographerAuthenticationToken("127.0.0.1", mock(SecurityLogger.class)); assertThat(token.getPrincipal(), is(instanceOf(VideographerPrincipal.class))); assertThat( token.getCredentials(), is(VideographerAuthenticationToken.VIDEOGRAPHER_CREDENTIALS)); assertThat(token.getIpAddress(), is("127.0.0.1")); }