use of org.pac4j.oauth.profile.facebook.FacebookProfile in project cas by apereo.
the class ClientAuthenticationHandlerTests method verifyOkWithSimpleIdentifier.
@Test
public void verifyOkWithSimpleIdentifier() throws GeneralSecurityException, PreventedException {
this.handler.setTypedIdUsed(false);
final FacebookProfile facebookProfile = new FacebookProfile();
facebookProfile.setId(ID);
this.fbClient.setProfileCreator((oAuth20Credentials, webContext) -> facebookProfile);
final AuthenticationHandlerExecutionResult result = this.handler.authenticate(this.clientCredential);
final Principal principal = result.getPrincipal();
assertEquals(ID, principal.getId());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project cas by apereo.
the class ClientAuthenticationHandlerTests method verifyOk.
@Test
public void verifyOk() throws GeneralSecurityException, PreventedException {
final FacebookProfile facebookProfile = new FacebookProfile();
facebookProfile.setId(ID);
this.fbClient.setProfileCreator((oAuth20Credentials, webContext) -> facebookProfile);
final AuthenticationHandlerExecutionResult result = this.handler.authenticate(this.clientCredential);
final Principal principal = result.getPrincipal();
assertEquals(FacebookProfile.class.getName() + '#' + ID, principal.getId());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateDifferentSecrets.
@Test
public void testGenerateAuthenticateDifferentSecrets() {
final SignatureConfiguration signatureConfiguration = new SecretSignatureConfiguration(MAC_SECRET);
final EncryptionConfiguration encryptionConfiguration = new SecretEncryptionConfiguration(KEY2);
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration, encryptionConfiguration);
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
assertToken(profile, token, new JwtAuthenticator(signatureConfiguration, encryptionConfiguration));
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method assertToken.
private CommonProfile assertToken(FacebookProfile profile, String token, JwtAuthenticator authenticator) {
final TokenCredentials credentials = new TokenCredentials(token);
authenticator.validate(credentials, null);
final CommonProfile profile2 = credentials.getUserProfile();
assertTrue(profile2 instanceof FacebookProfile);
final FacebookProfile fbProfile = (FacebookProfile) profile2;
assertEquals(profile.getTypedId(), fbProfile.getTypedId());
assertEquals(profile.getFirstName(), fbProfile.getFirstName());
assertEquals(profile.getDisplayName(), fbProfile.getDisplayName());
assertEquals(profile.getFamilyName(), fbProfile.getFamilyName());
assertEquals(profile.getVerified(), fbProfile.getVerified());
return profile2;
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPlainJwtNoSubject.
@Test
public void testPlainJwtNoSubject() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
final String token = generator.generate(new HashMap<>());
JwtAuthenticator authenticator = new JwtAuthenticator();
TestsHelper.expectException(() -> authenticator.validateToken(token), TechnicalException.class, "JWT must contain a subject ('sub' claim)");
}
Aggregations