use of org.pac4j.oauth.profile.facebook.FacebookProfile in project cas by apereo.
the class DelegatedClientAuthenticationHandlerTests method verifyOk.
@Test
public void verifyOk() throws GeneralSecurityException, PreventedException {
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(FacebookProfile.class.getName() + '#' + ID, principal.getId());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPlainJwtNotExpired.
@Test
public void testPlainJwtNotExpired() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
Map<String, Object> claims = new HashMap<>();
claims.put(JwtClaims.SUBJECT, ID);
claims.put(JwtClaims.EXPIRATION_TIME, tomorrow());
final String token = generator.generate(claims);
JwtAuthenticator authenticator = new JwtAuthenticator();
assertNotNull(authenticator.validateToken(token));
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testPlainJwtWithoutSignatureConfigurations.
@Test
public void testPlainJwtWithoutSignatureConfigurations() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
assertToken(profile, token, new JwtAuthenticator());
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testDoubleGenerateAuthenticate.
@Test
public void testDoubleGenerateAuthenticate() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET));
final FacebookProfile profile = createProfile();
final String token = generator.generate(profile);
final JwtAuthenticator authenticator = new JwtAuthenticator(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET));
final TokenCredentials credentials = new TokenCredentials(token);
authenticator.validate(credentials, null);
final FacebookProfile profile2 = (FacebookProfile) credentials.getUserProfile();
generator.generate(profile2);
}
use of org.pac4j.oauth.profile.facebook.FacebookProfile in project pac4j by pac4j.
the class JwtTests method testGenerateAuthenticateSub.
@Test(expected = TechnicalException.class)
public void testGenerateAuthenticateSub() {
final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>(new SecretSignatureConfiguration(MAC_SECRET));
final FacebookProfile profile = createProfile();
profile.addAttribute(JwtClaims.SUBJECT, VALUE);
final String token = generator.generate(profile);
assertToken(profile, token);
}
Aggregations