1 13 14 package org.ejbca.core.protocol.xkms.generators; 15 16 import java.security.cert.X509Certificate ; 17 18 import org.ejbca.core.model.ra.UserDataVO; 19 import org.ejbca.core.protocol.xkms.common.XKMSConstants; 20 import org.w3._2002._03.xkms_.KeyBindingAbstractType; 21 import org.w3._2002._03.xkms_.KeyBindingType; 22 import org.w3._2002._03.xkms_.RecoverRequestType; 23 import org.w3._2002._03.xkms_.RecoverResultType; 24 import org.w3c.dom.Document ; 25 26 34 35 public class RecoverResponseGenerator extends 36 KRSSResponseGenerator { 37 39 public RecoverResponseGenerator(String remoteIP, RecoverRequestType req, Document requestDoc) { 40 super(remoteIP, req,requestDoc); 41 } 42 43 46 public RecoverResultType getResponse(boolean requestVerifies){ 47 RecoverResultType result = xkmsFactory.createRecoverResultType(); 48 super.populateResponse(result, requestVerifies); 49 RecoverRequestType req = (RecoverRequestType) this.req; 50 51 52 if(resultMajor == null){ 53 if(!checkValidRespondWithRequest(req.getRespondWith(),false)){ 54 resultMajor = XKMSConstants.RESULTMAJOR_SENDER; 55 resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED; 56 } 57 58 if(resultMajor == null){ 59 if(resultMajor == null){ 60 X509Certificate cert = (X509Certificate ) getPublicKeyInfo(req, false); 61 62 UserDataVO userData = findUserData(cert); 63 if(userData != null){ 64 String password = ""; 65 boolean encryptedPassword = isPasswordEncrypted(req); 66 if(encryptedPassword){ 67 password = getEncryptedPassword(requestDoc, userData.getPassword()); 68 }else{ 69 password = getClearPassword(req, userData.getPassword()); 70 } 71 72 if(password != null ){ 73 X509Certificate newCert = registerReissueOrRecover(true,false, result, userData,password, cert.getPublicKey(), null); 74 if(newCert != null){ 75 KeyBindingAbstractType keyBinding = getResponseValues(req.getRecoverKeyBinding(), newCert, false, true); 76 result.getKeyBinding().add((KeyBindingType) keyBinding); 77 } 78 } 79 } 80 81 } 82 } 83 } 84 85 if(resultMajor == null){ 86 resultMajor = XKMSConstants.RESULTMAJOR_SUCCESS; 87 } 88 89 setResult(result); 90 91 return result; 92 } 93 94 95 96 97 98 99 100 } 101 | Popular Tags |