use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateDifferentEncryptionConfiguration.
@Test
public void testGenerateAuthenticateDifferentEncryptionConfiguration() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
generator.setEncryptionConfiguration(new SecretEncryptionConfiguration(KEY2));
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
jwtAuthenticator.addEncryptionConfiguration(new SecretEncryptionConfiguration(MAC_SECRET));
final Exception e = TestsHelper.expectException(() -> assertToken(profile, token, jwtAuthenticator));
assertTrue(e.getMessage().startsWith("No encryption algorithm found for JWT:"));
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateNotSigned.
@Test
public void testGenerateAuthenticateNotSigned() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
generator.setEncryptionConfiguration(new SecretEncryptionConfiguration(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 testGenerateAuthenticateDifferentSignatureConfiguration.
@Test
public void testGenerateAuthenticateDifferentSignatureConfiguration() throws NoSuchAlgorithmException {
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(buildECSignatureConfiguration());
final Exception e = TestsHelper.expectException(() -> assertToken(profile, token, jwtAuthenticator));
assertTrue(e.getMessage().startsWith("No signature algorithm found for JWT:"));
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateUselessSignatureConfiguration.
@Test
public void testGenerateAuthenticateUselessSignatureConfiguration() {
final SignatureConfiguration signatureConfiguration = new SecretSignatureConfiguration(KEY2);
final SignatureConfiguration signatureConfiguration2 = new SecretSignatureConfiguration(MAC_SECRET);
final EncryptionConfiguration encryptionConfiguration = new SecretEncryptionConfiguration(MAC_SECRET);
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration, encryptionConfiguration);
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
final JwtAuthenticator jwtAuthenticator = new JwtAuthenticator();
jwtAuthenticator.addSignatureConfiguration(signatureConfiguration);
jwtAuthenticator.addSignatureConfiguration(signatureConfiguration2);
jwtAuthenticator.setEncryptionConfiguration(encryptionConfiguration);
assertToken(profile, token, jwtAuthenticator);
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticate.
@Test
public void testGenerateAuthenticate() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET));
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
assertToken(profile, token);
}
Aggregations