/** * Authenticate credentials. * @param token the token * @return the principal if present */ default Optional<Principal> authenticate(final String token) { final Claims claims = parse(token); // Use a webid claim, if one exists final Optional<Principal> webid = withWebIdClaim(claims); if (webid.isPresent()) { return webid; } // Try generating a webid from other elements return withSubjectClaim(claims); } }
@Test public void testNullAuthenticator() { final Authenticator authenticator = new NullAuthenticator(); assertFalse(authenticator.authenticate("blah").isPresent(), "Unexpected principal found!"); assertNull(authenticator.parse("credentials"), "Credentials were not null!"); }