public static synchronized String addCertRequest(String keyId,ClientId memberId,String subjectName,KeyUsageInfo keyUsage){
  log.trace("addCertRequest({}, {})",keyId,memberId);
  Key key=findKey(keyId);
  if (key.getUsage() != null && key.getUsage() != keyUsage) {
    throw CodedException.tr(X_WRONG_CERT_USAGE,"cert_request_wrong_usage","Cannot add %s certificate request to %s key",keyUsage,key.getUsage());
  }
  key.setUsage(keyUsage);
  for (  CertRequest certRequest : key.getCertRequests()) {
    ClientId crMember=certRequest.getMemberId();
    String crSubject=certRequest.getSubjectName();
    if ((memberId == null && crSubject.equalsIgnoreCase(subjectName)) || (memberId != null && memberId.equals(crMember) && crSubject.equalsIgnoreCase(subjectName))) {
      log.warn("Certificate request (memberId: {}, " + "subjectName: {}) already exists",memberId,subjectName);
      return certRequest.getId();
    }
  }
  String certId=SignerUtil.randomId();
  key.addCertRequest(new CertRequest(certId,memberId,subjectName));
  log.info("Added new certificate request (memberId: {}, " + "subjectId: {}) under key {}",new Object[]{memberId,subjectName,keyId});
  return certId;
}

public static synchronized String addCertRequest ( String keyId , ClientId memberId , String subjectName , KeyUsageInfo keyUsage ) { log . trace ( "addCertRequest({}, {})" , keyId , memberId ) ; Key key = findKey ( keyId ) ; if ( key . getUsage ( ) != null && key . getUsage ( ) != keyUsage ) { throw CodedException . tr ( X_WRONG_CERT_USAGE , "cert_request_wrong_usage" , "Cannot add %s certificate request to %s key" , keyUsage , key . getUsage ( ) ) ; } key . setUsage ( keyUsage ) ; for ( CertRequest certRequest : key . getCertRequests ( ) ) { ClientId crMember = certRequest . getMemberId ( ) ; String crSubject = certRequest . getSubjectName ( ) ; if ( ( memberId == null && crSubject . equalsIgnoreCase ( subjectName ) ) || ( memberId != null && memberId . equals ( crMember ) && crSubject . equalsIgnoreCase ( subjectName ) ) ) { log . warn ( "Certificate request (memberId: {}, " + "subjectName: {}) already exists" , memberId , subjectName ) ; return certRequest . getId ( ) ; } } String certId = SignerUtil . randomId ( ) ; key . addCertRequest ( new CertRequest ( certId , memberId , subjectName ) ) ; log . info ( "Added new certificate request (memberId: {}, " + "subjectId: {}) under key {}" , new Object [ ] { memberId , subjectName , keyId } ) ; return certId ; }
adds a new certificate request to a key .
