Package org.ejbca.core.protocol

Examples of org.ejbca.core.protocol.IRequestMessage


      if (userdata.getTokenType() != SecConst.TOKEN_SOFT_BROWSERGEN) {
        throw EjbcaWSHelper.getEjbcaException("Error: Wrong Token Type of user, must be 'USERGENERATED' for PKCS10/SPKAC/CRMF/CVC requests",
                                        logger, ErrorCode.BAD_USER_TOKEN_TYPE, null);
      }

      IRequestMessage imsg = null;
      if (reqType == REQTYPE_PKCS10) {
        final IRequestMessage pkcs10req = RequestMessageUtils.genPKCS10RequestMessage(req.getBytes());
        final PublicKey pubKey = pkcs10req.getRequestPublicKey();
        imsg = new SimpleRequestMessage(pubKey, username, password);
      } else if (reqType == REQTYPE_SPKAC) {
        // parts copied from request helper.
        byte[] reqBytes = req.getBytes();
        if (reqBytes != null) {
View Full Code Here


   * Currently handles PKCS10 request messages and CVC request messages.
   *
   * @return IRequestMessage
   */
  public static IRequestMessage parseRequestMessage(byte[] request) throws IOException {
    IRequestMessage ret = null;
    try {
      ret = genPKCS10RequestMessage(request);     
    } catch (IllegalArgumentException e) {
      log.debug("Can not parse PKCS10 request, trying CVC instead: "+ e.getMessage());
      ret = genCVCRequestMessage(request);
View Full Code Here

    public void test01() throws Exception {
      final String unidPrefix = "1234-5678-";
      final String fnr = "90123456789";
      final String lra = "01234";
      final MyStorage storage = new MyStorage(unidPrefix, fnr, lra);
      final IRequestMessage reqIn = new MyIRequestMessage(fnr+'-'+lra);
      final UnidFnrHandler handler = new UnidFnrHandler(storage);
      final IRequestMessage reqOut = handler.processRequestMessage(reqIn, unidPrefix+"_a_profile_name");
      assertEquals(storage.unid, reqOut.getRequestX509Name().getValues(X509Name.SN).firstElement());
    }
View Full Code Here

    addOrEditUser(admin, userdata, false, true);
    // Process request
    try {
      String password = userdata.getPassword();
      String username = userdata.getUsername();
      IRequestMessage imsg = null;
      if (reqType == SecConst.CERT_REQ_TYPE_PKCS10) {       
        IRequestMessage pkcs10req = RequestMessageUtils.genPKCS10RequestMessage(req.getBytes());
        PublicKey pubKey = pkcs10req.getRequestPublicKey();
        imsg = new SimpleRequestMessage(pubKey, username, password);
      } else if (reqType == SecConst.CERT_REQ_TYPE_SPKAC) {
        // parts copied from request helper.
        byte[] reqBytes = req.getBytes();
        if (reqBytes != null) {
View Full Code Here

        String password = args[2];
        String csr = args[3];
        String certf = args[4];
        try {
      byte[] bytes = FileTools.readFiletoBuffer(csr);
      IRequestMessage req = RequestMessageUtils.parseRequestMessage(bytes);
      if (req instanceof PKCS10RequestMessage) {
        PKCS10RequestMessage p10req = (PKCS10RequestMessage) req;
        p10req.setUsername(username);
        p10req.setPassword(password);
      } else {
View Full Code Here

        }
      }
      // Create a username and password and register the new user in EJBCA
      final UsernameGenerator gen = UsernameGenerator.getInstance(this.usernameGenParams);
      // Don't convert this DN to an ordered EJBCA DN string with CertTools.stringToBCDNString because we don't want double escaping of some characters
      final IRequestMessage req =  this.extendedUserDataHandler!=null ? this.extendedUserDataHandler.processRequestMessage(crmfreq, certProfileName) : crmfreq;
      final X509Name dnname = req.getRequestX509Name();
      if (LOG.isDebugEnabled()) {
        LOG.debug("Creating username from base dn: "+dnname.toString());
      }
      final String username = gen.generateUsername(dnname.toString());
      final String pwd;
      if (StringUtils.equals(this.userPwdParams, "random")) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Setting 12 char random user password.");
        }
        final IPasswordGenerator pwdgen = PasswordGeneratorFactory.getInstance(PasswordGeneratorFactory.PASSWORDTYPE_ALLPRINTABLE);
        pwd = pwdgen.getNewPassword(12, 12);                                                                   
      } else {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Setting fixed user password from config.");
        }
        pwd = this.userPwdParams;                                                                   
      }
      // AltNames may be in the request template
      final String altNames = req.getRequestAltNames();
      final String email;
      final List<String> emails = CertTools.getEmailFromDN(altNames);
      emails.addAll(CertTools.getEmailFromDN(dnname.toString()));
      if (!emails.isEmpty()) {
        email = emails.get(0); // Use rfc822name or first SubjectDN email address as user email address if available
View Full Code Here

TOP

Related Classes of org.ejbca.core.protocol.IRequestMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.