/** * 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); } }