JSPUtil.fwd(request, response, ERROR_PAGE);
return;
}
info("2.a Token and verifier found.");
X509Certificate cert = null;
AssetResponse assetResponse = null;
OA4MPResponse oa4MPResponse = null;
Map<String, String> parameters = createQueryParameters(gatewayName, portalUserName, contactEmail, portalTokenId);
try {
info("Requesting private key ...");
oa4MPResponse = getOA4MPService().requestCert(parameters);
// oa4MPResponse = getOA4MPService().requestCert();
info("2.a. Getting the cert(s) from the service");
assetResponse = getOA4MPService().getCert(token, verifier);
cert = assetResponse.getX509Certificates()[0];
// The work in this call
} catch (Throwable t) {
warn("2.a. Exception from the server: " + t.getCause().getMessage());
error("Exception while trying to get cert. message:" + t.getMessage());
request.setAttribute("exception", t);
JSPUtil.fwd(request, response, ERROR_PAGE);
return;
}
info("2.b. Done! Displaying success page.");
CertificateCredential certificateCredential = new CertificateCredential();
certificateCredential.setNotBefore(Utility.convertDateToString(cert.getNotBefore()));
certificateCredential.setNotAfter(Utility.convertDateToString(cert.getNotAfter()));
certificateCredential.setCertificate(cert);
certificateCredential.setPrivateKey(oa4MPResponse.getPrivateKey());
certificateCredential
.setCommunityUser(new CommunityUser(gatewayName, assetResponse.getUsername(), contactEmail));
certificateCredential.setPortalUserName(portalUserName);
certificateCredential.setLifeTime(duration);
certificateCredential.setToken(portalTokenId);
certificateCredentialWriter.writeCredentials(certificateCredential);
StringBuilder stringBuilder = new StringBuilder("Certificate for community user ");
stringBuilder.append(assetResponse.getUsername()).append(" successfully persisted.");
stringBuilder.append(" Certificate DN - ").append(cert.getSubjectDN());
info(stringBuilder.toString());
String contextPath = request.getContextPath();