use of org.pac4j.http.profile.X509Profile in project pac4j by pac4j.
the class X509ClientTests method testOk.
@Test
public void testOk() throws CertificateException {
final var context = MockWebContext.create();
final var certificateData = Base64.getDecoder().decode(CERTIFICATE);
final var cert = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(certificateData));
final var certs = new X509Certificate[1];
certs[0] = cert;
context.setRequestAttribute(X509CredentialsExtractor.CERTIFICATE_REQUEST_ATTRIBUTE, certs);
final var credentials = (X509Credentials) client.getCredentials(context, new MockSessionStore()).get();
final var profile = (X509Profile) client.getUserProfile(credentials, context, new MockSessionStore()).get();
assertEquals("jerome", profile.getId());
}
Aggregations