Search in sources :

Example 1 with ECSignatureConfiguration

use of org.pac4j.jwt.config.signature.ECSignatureConfiguration in project pac4j by pac4j.

the class JwtTests method buildECSignatureConfiguration.

private ECSignatureConfiguration buildECSignatureConfiguration() throws NoSuchAlgorithmException {
    final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
    final KeyPair keyPair = keyGen.generateKeyPair();
    return new ECSignatureConfiguration(keyPair, JWSAlgorithm.ES256);
}
Also used : KeyPair(java.security.KeyPair) ECSignatureConfiguration(org.pac4j.jwt.config.signature.ECSignatureConfiguration) KeyPairGenerator(java.security.KeyPairGenerator)

Example 2 with ECSignatureConfiguration

use of org.pac4j.jwt.config.signature.ECSignatureConfiguration 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);
}
Also used : JwtGenerator(org.pac4j.jwt.profile.JwtGenerator) ECSignatureConfiguration(org.pac4j.jwt.config.signature.ECSignatureConfiguration) JwtAuthenticator(org.pac4j.jwt.credentials.authenticator.JwtAuthenticator) FacebookProfile(org.pac4j.oauth.profile.facebook.FacebookProfile) Test(org.junit.Test)

Aggregations

ECSignatureConfiguration (org.pac4j.jwt.config.signature.ECSignatureConfiguration)2 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 Test (org.junit.Test)1 JwtAuthenticator (org.pac4j.jwt.credentials.authenticator.JwtAuthenticator)1 JwtGenerator (org.pac4j.jwt.profile.JwtGenerator)1 FacebookProfile (org.pac4j.oauth.profile.facebook.FacebookProfile)1