use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPlainJwtExpired.
@Test
public void testPlainJwtExpired() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
Map<String, Object> claims = new HashMap<>();
claims.put(JwtClaims.SUBJECT, ID);
claims.put(JwtClaims.EXPIRATION_TIME, yesterday());
final String token = generator.generate(claims);
JwtAuthenticator authenticator = new JwtAuthenticator();
assertNull(authenticator.validateToken(token));
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPlainJwtWithSignatureConfigurations.
@Test(expected = CredentialsException.class)
public void testPlainJwtWithSignatureConfigurations() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
assertToken(profile, token);
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateAndEncryptedWithRolesPermissions.
@Test
public void testGenerateAuthenticateAndEncryptedWithRolesPermissions() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET));
final FacebookProfile profile = createProfile();
profile.addRoles(ROLES);
profile.addPermissions(PERMISSIONS);
final String token = generator.generate(profile);
final CommonProfile profile2 = assertToken(profile, token);
assertEquals(ROLES, profile2.getRoles());
assertEquals(PERMISSIONS, profile2.getPermissions());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateNotEncrypted.
@Test
public void testGenerateAuthenticateNotEncrypted() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET));
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
assertToken(profile, token);
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateSlightlyDifferentSignatureConfiguration.
@Test
public void testGenerateAuthenticateSlightlyDifferentSignatureConfiguration() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(KEY2));
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
jwtAuthenticator.addSignatureConfiguration(new SecretSignatureConfiguration(MAC_SECRET));
final Exception e = TestsHelper.expectException(() -> assertToken(profile, token, jwtAuthenticator));
assertTrue(e.getMessage().startsWith("JWT verification failed"));
}
Aggregations