@Override protected void clientInit() { defaultCredentialsExtractor(new X509CredentialsExtractor()); defaultAuthenticator(new X509Authenticator()); } }
@Test public void testOk() throws CertificateException { final MockWebContext context = MockWebContext.create(); final byte[] certificateData = Base64.getDecoder().decode(CERTIFICATE); final X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X.509") .generateCertificate(new ByteArrayInputStream(certificateData)); final X509Certificate[]certs = new X509Certificate[1]; certs[0] = cert; context.setRequestAttribute(X509CredentialsExtractor.CERTIFICATE_REQUEST_ATTRIBUTE, certs); final X509Credentials credentials = client.getCredentials(context); final X509Profile profile = client.getUserProfile(credentials, context); assertEquals("jerome", profile.getId()); } }