}
}
log.debug("Got request for " + username + ".");
debug.print("<h3>username: " + username + "</h3>");
final UserDataVO data = userAdminSession.findUser(administrator, username);
final X509Certificate notRevokedCerts[]; {
Set<X509Certificate> set = new HashSet<X509Certificate>();
for( Iterator<java.security.cert.Certificate> i = certificateStoreSession.findCertificatesByUsername(administrator, username).iterator(); i.hasNext(); ) {
Object o = i.next();
if ( o instanceof X509Certificate ) {
X509Certificate cert = (X509Certificate)o;
boolean isRevoked = certificateStoreSession.isRevoked(cert.getIssuerDN().getName(), cert.getSerialNumber());
if (!isRevoked) {
set.add(cert);
}
}
}
notRevokedCerts = (X509Certificate[])set.toArray(new X509Certificate[0]);
}
if (data == null) {
throw new ObjectNotFoundException();
}
final String authReq = request.getParameter("authpkcs10");
final String signReq = request.getParameter("signpkcs10");
if ( authReq!=null && signReq!=null ) {
final int authCertProfile;
final int signCertProfile;
final HardTokenProfile hardTokenProfile = hardTokenSession.getHardTokenProfile(administrator, data.getTokenType());
{
CertProfileID certProfileID = new CertProfileID(data, administrator, hardTokenProfile);
authCertProfile = certProfileID.getProfileID("authCertProfile", SwedishEIDProfile.CERTUSAGE_AUTHENC);
signCertProfile = certProfileID.getProfileID("signCertProfile", SwedishEIDProfile.CERTUSAGE_SIGN);
}
final int authCA;
final int signCA;
{
CAID caid = new CAID(data,administrator, hardTokenProfile, caAdminSession);
authCA = caid.getProfileID("authCA", SwedishEIDProfile.CERTUSAGE_AUTHENC);
signCA = caid.getProfileID("signCA", SwedishEIDProfile.CERTUSAGE_SIGN);
}
// if not IE, check if it's manual request
final byte[] authReqBytes = authReq.getBytes();
final byte[] signReqBytes = signReq.getBytes();
if ( authReqBytes!=null && signReqBytes!=null) {
try {
userAdminSession.changeUser(administrator, username,data.getPassword(), data.getDN(), data.getSubjectAltName(),
data.getEmail(), true, data.getEndEntityProfileId(), authCertProfile, data.getType(),
SecConst.TOKEN_SOFT_BROWSERGEN, 0, data.getStatus(), authCA);
final byte[] authb64cert=pkcs10CertRequest(administrator, signSession, authReqBytes, username, data.getPassword());
userAdminSession.changeUser(administrator, username, data.getPassword(), data.getDN(), data.getSubjectAltName(),
data.getEmail(), true, data.getEndEntityProfileId(), signCertProfile, data.getType(),
SecConst.TOKEN_SOFT_BROWSERGEN, 0, UserDataConstants.STATUS_NEW, signCA);
final byte[] signb64cert=pkcs10CertRequest(administrator, signSession, signReqBytes, username, data.getPassword());
for (int i=0; i<notRevokedCerts.length; i++) {
try {
userAdminSession.revokeCert(administrator, notRevokedCerts[i].getSerialNumber(),
notRevokedCerts[i].getIssuerDN().toString(), RevokedCertInfo.REVOCATION_REASON_SUPERSEDED);
} catch (WaitingForApprovalException e) {
log.info("A request for approval to revoke " + username + "'s old certificate "+
notRevokedCerts[i].getSerialNumber().toString(16)+" was added.");
} catch (ApprovalException e) {
log.info("A request for approval to revoke " + username + "'s old certificate "+
notRevokedCerts[i].getSerialNumber().toString(16)+" already exists.");
}
}
sendCertificates(authb64cert, signb64cert, response, getServletContext(),
getInitParameter("responseTemplate"), notRevokedCerts);
} catch( Throwable t ) {
if (t instanceof Exception) {
throw (Exception)t;
}
else {
throw new Error(t);
}
} finally {
data.setStatus(UserDataConstants.STATUS_GENERATED);
userAdminSession.changeUser(administrator, data, true); // set back to original values
}
}
}
} catch( UserCertificateRevokedException e) {