Ejemplo n.º 1
0
  private byte[] processCertReq(
      String username,
      String password,
      String req, // NOPMD
      int reqType,
      String hardTokenSN,
      String responseType) // NOPMD
      throws EjbcaException_Exception, AuthorizationDeniedException_Exception {
    try {
      final byte[] retval;

      UserDataVOWS userdata = findUser(username);
      if (userdata == null) {
        EjbcaException ex = new EjbcaException();
        ErrorCode code = new ErrorCode();
        //            code.setInternalErrorCode(todo)
        ex.setErrorCode(code);
        throw new EjbcaException_Exception("User not found: " + username, ex);
      }
      // String caName = userdata.getCaName();
      pkcs10req = RequestMessageUtils.genPKCS10RequestMessage(req.getBytes());
      PublicKey pubKey = pkcs10req.getRequestPublicKey();
      // IRequestMessage imsg = new SimpleRequestMessage(pubKey, username,
      //        password);

      X509Certificate cert = ca.issueCertificate(userdata.getSubjectDN(), 5, "SHA1withRSA", pubKey);
      if (RESPONSETYPE_PKCS7WITHCHAIN.equals(responseType)) {
        retval = ca.createPKCS7(cert, true);
      } else {
        // retval = cert.getEncoded();
        throw new UnsupportedOperationException("Not supported yet");
      }

      // Set to generated
      userdata.setStatus(40);

      return retval;
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }