use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPemJwt.
@Test
public void testPemJwt() throws NoSuchAlgorithmException {
final FacebookProfile profile = createProfile();
final ECSignatureConfiguration signatureConfiguration = buildECSignatureConfiguration();
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(signatureConfiguration);
final String token = generator.generate(profile);
final JwtAuthenticator authenticator = new JwtAuthenticator();
authenticator.addSignatureConfiguration(signatureConfiguration);
assertToken(profile, token, authenticator);
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method createProfile.
private FacebookProfile createProfile() {
final FacebookProfile profile = new FacebookProfile();
profile.setId(ID);
profile.addAttribute(FacebookProfileDefinition.NAME, NAME);
profile.addAttribute(FacebookProfileDefinition.VERIFIED, true);
return profile;
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project cas by apereo.
the class DelegatedClientAuthenticationHandlerTests method verifyOkWithSimpleIdentifier.
@Test
public void verifyOkWithSimpleIdentifier() throws GeneralSecurityException, PreventedException {
this.handler.setTypedIdUsed(false);
val facebookProfile = new FacebookProfile();
facebookProfile.setId(ID);
this.fbClient.setProfileCreator((oAuth20Credentials, webContext, sessionStore) -> Optional.of(facebookProfile));
val result = this.handler.authenticate(this.clientCredential);
val principal = result.getPrincipal();
assertEquals(ID, principal.getId());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project cas by apereo.
the class DelegatedClientAuthenticationHandlerTests method verifyMissingClient.
@Test
public void verifyMissingClient() {
val facebookProfile = new FacebookProfile();
facebookProfile.setId(ID);
this.fbClient.setProfileCreator((oAuth20Credentials, webContext, sessionStore) -> Optional.of(facebookProfile));
val cc = new ClientCredential(new AnonymousCredentials(), "UnknownClient");
assertThrows(PreventedException.class, () -> this.handler.authenticate(cc));
}
Aggregations