@Test(expected = AuthenticationException.class) public void testVerifyBadToken() throws Exception { LoginToken token = defaultAuthentication.verifyToken("Basic THISISABADTOKEN"); LoginToken expected = LoginToken.withAccessToken("THISISABADTOKEN").withTokenType("Basic").build(); assertThat(token, is(expected)); }
@Override public LoginToken verifyToken(final String tokenHeader) { LOGGER.debug("Authentication token received as: {}", tokenHeader); UserCredential credential = parseUsernamePassword(fromNullable(tokenHeader)); if (isBasicAuthenicationValid(credential)) { return withAccessToken(credential.toBase64Encode()).withTokenType(BASIC).build(); } else { throw new AuthenticationException("Authentication Token is not valid"); } }
DefaultAuthentication implements Authentication { @Override public LoginToken verifyToken(final String tokenHeader) { LOGGER.debug("Authentication token received as: {}", tokenHeader); UserCredential credential = parseUsernamePassword(fromNullable(tokenHeader)); if (isBasicAuthenicationValid(credential)) { return withAccessToken(credential.toBase64Encode()).withTokenType(BASIC).build(); } else { throw new AuthenticationException("Authentication Token is not valid"); } } }
DefaultAuthentication implements Authentication { @Override public LoginToken verifyToken(final String tokenHeader) { LOGGER.debug("Authentication token received as: {}", tokenHeader); UserCredential credential = parseUsernamePassword(fromNullable(tokenHeader)); if (isBasicAuthenicationValid(credential)) { return withAccessToken(credential.toBase64Encode()).withTokenType(BASIC).build(); } else { throw new AuthenticationException("Authentication Token is not valid"); } } @Inject  DefaultAuthentication(final UserDirectory userDirectory); }
DefaultAuthentication implements Authentication { @Override public LoginToken verifyToken(final String tokenHeader) { LOGGER.debug("Authentication token received as: {}", tokenHeader); UserCredential credential = parseUsernamePassword(fromNullable(tokenHeader)); if (isBasicAuthenicationValid(credential)) { return withAccessToken(credential.toBase64Encode()).withTokenType(BASIC).build(); } else { throw new AuthenticationException("Authentication Token is not valid"); } } @Inject  DefaultAuthentication(final UserDirectory userDirectory); @Override LoginToken logIn(final String authHeader); @Override LoginToken verifyToken(final String tokenHeader); @Override boolean logOut(final String tokenHeader); @Override UserInfo getUserExists(final String userEmail); }
DefaultAuthentication implements Authentication { @Override public LoginToken verifyToken(final String tokenHeader) { LOGGER.debug("Authentication token received as: {}", tokenHeader); UserCredential credential = parseUsernamePassword(fromNullable(tokenHeader)); if (isBasicAuthenicationValid(credential)) { return withAccessToken(credential.toBase64Encode()).withTokenType(BASIC).build(); } else { throw new AuthenticationException("Authentication Token is not valid"); } } @Inject  DefaultAuthentication(final UserDirectory userDirectory); @Override LoginToken logIn(final String authHeader); @Override LoginToken verifyToken(final String tokenHeader); @Override boolean logOut(final String tokenHeader); @Override UserInfo getUserExists(final String userEmail); static final String BASIC; static final String EMPTY; }