public void receiveResponse(Admin admin, int caid, IResponseMessage responsemessage) throws CADoesntExistsException, AuthorizationDeniedException{
public void receiveResponse(Admin admin, int caid, IResponseMessage responsemessage) throws CADoesntExistsException, AuthorizationDeniedException, CertPathValidatorException{
    public void receiveResponse(Admin admin, int caid, IResponseMessage responsemessage) throws CADoesntExistsException, AuthorizationDeniedException{        // check authorization		Certificate cacert = null;		// Check authorization		try{			getAuthorizationSession().isAuthorizedNoLog(admin,"/super_administrator");		}catch(AuthorizationDeniedException e){			getLogSession().log(admin, caid, LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_ERROR_NOTAUTHORIZEDTORESOURCE,"Not authorized to recieve certificate responce for CA",e);			throw new AuthorizationDeniedException("Not authorized to recieve certificate responce for CA with caid = " + caid);		}                		// Get CA info.		CADataLocal cadata = null;		try{			cadata = this.cadatahome.findByPrimaryKey(new Integer(caid));			CA ca = cadata.getCA();            			if(responsemessage instanceof X509ResponseMessage){			  cacert = ((X509ResponseMessage) responsemessage).getCertificate();        			}else{				getLogSession().log(admin, caid, LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_ERROR_CAEDITED,"Error: illegal response message."); 				throw new EJBException(new EjbcaException("Error: illegal response message."));        				}                        		// if issuer is insystem CA or selfsigned, then generate new certificate.		  if(ca.getSignedBy() == CAInfo.SIGNEDBYEXTERNALCA){			 // check the validity of the certificate chain.						 			ArrayList cachain = new ArrayList();			cachain.add(cacert);			cachain.addAll(ca.getRequestCertificateChain());								CertPath cp = CertificateFactory.getInstance("X.509","BC").generateCertPath(cachain);													    			ca.setCertificateChain(cp.getCertificates());				     			// Set statuses.			                          	           			cadata.setStatus(SecConst.CA_ACTIVE);						 			if(ca instanceof X509CA){								cadata.setExpireTime(((X509Certificate) cacert).getNotAfter().getTime()); 			}			 			cadata.setCA(ca); 					    }else{                		    // Cannot create certificate request for internal CA			  getLogSession().log(admin, caid, LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_ERROR_CAEDITED,"Error: can't recieve certificate responce for internal CA"); 			  throw new EJBException(new EjbcaException("Error: can't recieve certificate responce for internal CA"));		    }    		        		}catch(Exception e){			getLogSession().log(admin, caid, LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_ERROR_CAEDITED,"Error when creating certificate request");		   throw new EJBException(e);		}                  		getLogSession().log(admin, caid, LogEntry.MODULE_CA,  new java.util.Date(), null, null, LogEntry.EVENT_INFO_CAEDITED,"Certificate responce recieved successfully");                		                    } // recieveResponse