Package org.ejbca.core.model.ra

Examples of org.ejbca.core.model.ra.UserDataVO


      String reqDNS = req.getMSRequestInfoSubjectAltnames()[1];
      subjectAN += (subjectAN.length() == 0 ? "" : ",") + "DNSNAME=" +reqDNS;
    }
    log.info("sdn=" + subjectDN + ", san=" + subjectAN);
    debugInfo += "\nsdn=" + subjectDN + ", san=" + subjectAN + "\n";
    UserDataVO userData = new UserDataVO(username, subjectDN, caid, subjectAN, null, UserDataConstants.STATUS_NEW, 1,endEntityProfileId, certProfileId,
        new Date(), new Date(), SecConst.TOKEN_SOFT_BROWSERGEN, 0, null);
    String password = PasswordGeneratorFactory.getInstance(PasswordGeneratorFactory.PASSWORDTYPE_LETTERSANDDIGITS).getNewPassword(8,8);
    userData.setPassword(password);
    try {
      if (userAdminSession.existsUser(admin, username)) {
        userAdminSession.changeUser(admin, userData, true);
      } else {
        userAdminSession.addUser(admin, userData, true);
View Full Code Here


    }

    private ISubMessage processExtRAEditUserRequest(Admin admin, EditUserRequest submessage) {
    log.debug("Processing ExtRAEditUserRequest");
    ExtRAResponse retval = null;
        UserDataVO userdata = null;
    try{
            userdata = generateUserDataVO(admin, submessage);
            userdata.setPassword(submessage.getPassword());        
      userdata.setType(submessage.getType());
      userdata.setTokenType(getTokenTypeId(admin, submessage.getTokenName()));
      userdata.setHardTokenIssuerId(getHardTokenIssuerId(admin, submessage.getHardTokenIssuerName()));
          storeUserData(admin, userdata, false, submessage.getStatus());
          retval = new ExtRAResponse(submessage.getRequestId(),true,null);
    }catch(Exception e){
      log.error("Error processing ExtRAEditUserRequest : ", e);
            if (userdata != null) {
View Full Code Here

    }
   
    String includeEmail = request.getParameter("includeemail");
    log.debug("includeEmail="+includeEmail);

    UserDataVO newuser = new UserDataVO();
    newuser.setType(SecConst.USER_ENDUSER);
    newuser.setUsername(username);
    newuser.setDN(dn);
    newuser.setTokenType(SecConst.TOKEN_SOFT_BROWSERGEN);
    newuser.setKeyRecoverable(false);
    newuser.setSendNotification(false);
   
    String email = request.getParameter("email");
    if (email == null) {
      email = CertTools.getPartFromDN(dn, "EMAILADDRESS");
    }
    if ((email != null) && (email.length() > 0)) {
      newuser.setEmail(email);
      if (includeEmail != null) {
          newuser.setSubjectAltName("RFC822NAME="+email);
      }
    }

    String tmp = null;
    int eProfileId = SecConst.EMPTY_ENDENTITYPROFILE;
    if ((tmp=request.getParameter("entityprofile")) != null) {
        eProfileId = endEntityProfileSession.getEndEntityProfileId(admin, request.getParameter("entityprofile"));
        if (eProfileId == 0) {
            throw new ServletException("No such end entity profile: " + tmp);
        }
    }
    newuser.setEndEntityProfileId(eProfileId);

    int cProfileId = SecConst.CERTPROFILE_FIXED_ENDUSER;
    if ((tmp=request.getParameter("certificateprofile")) != null) {
        cProfileId = certificateProfileSession.getCertificateProfileId(admin, request.getParameter("certificateprofile"));
        if (cProfileId == 0) {
            throw new ServletException("No such certificate profile: " + tmp);
        }
    }
    newuser.setCertificateProfileId(cProfileId);

    int caid = DEFAULT_DEMOCAID;
    if ((tmp=request.getParameter("ca")) != null) {
        // Do NOT get requested CA to sign with from form.
      // For security reasons, if there are more than one CA in the system
      // we definataly want to hardwire the demo to the demo CA.
    }   
    newuser.setCAId(caid);   

    String password = request.getParameter("password");
    if (password == null) {
      password = "demo";
    }
    newuser.setPassword(password);

    try {
        userAdminSession.addUser(admin, newuser.getUsername(), newuser.getPassword(), newuser.getDN(), newuser.getSubjectAltName()
                               ,newuser.getEmail(), false, newuser.getEndEntityProfileId(),
                                newuser.getCertificateProfileId(), newuser.getType(),
                                newuser.getTokenType(), newuser.getHardTokenIssuerId(), newuser.getCAId());
    } catch (Exception e) {
      throw new ServletException("Error adding user: ", e);
    }

    RequestHelper helper = new RequestHelper(admin, debug);
View Full Code Here

          username = certificateStoreSession.findUsernameByCertSerno(admin, serno, CertTools.stringToBCDNString(issuerDN));
        }
        if (username != null) {
          if ( (submessage.getRevokeAll() || submessage.getRevokeUser()) ) {
            // Revoke all users certificates by revoking the whole user
            UserDataVO vo = userAdminSession.findUser(admin,username);
            if (vo != null) {
              userAdminSession.revokeUser(admin,username, submessage.getRevocationReason());
              if (!submessage.getRevokeUser()) {
                // If we were not to revoke the user itself, but only the certificates, we should set back status
                userAdminSession.setUserStatus(admin, username, vo.getStatus());
              }         
            } else {
              retval = new ExtRAResponse(submessage.getRequestId(),false,"User not found from username: username="+username);             
            }
          } else {
View Full Code Here

    }
    if (username == null || username.length() == 0) {
      throw new ServletException("Username must not be empty.");
    }

    UserDataVO tmpuser = null;
    try {
        tmpuser = adminsession.findUser(admin, username);
     } catch (Exception e) {
        throw new ServletException("Error checking username '" + username +": ", e);
     }
View Full Code Here

          byte[] result = null;
          if (submessage.createOrEditUser()) {
        if (log.isDebugEnabled()) {
          log.debug("createOrEditUser == true, will use one-shot request processing.");
        }
            final UserDataVO userdatavo = getUserDataVO(admin, submessage);
            final String requestData = new String(submessage.getRequestData());
            final int requestTypeInt = submessage.getRequestType();
            final int responseTypeInt = submessage.getResponseType();
           
            final String hardTokenSN = null;
View Full Code Here

      return new CertificateRequestResponse(submessage.getRequestId(), false, "Error " + e.getMessage(), null, null);
    }
  }
 
  private UserDataVO getUserDataVO(final Admin admin, final CertificateRequestRequest submessage) throws ClassCastException, EjbcaException {
    final UserDataVO result = generateUserDataVO(admin, submessage);
   
    result.setStatus(UserDataConstants.STATUS_NEW);
   
    // Not yet supported: hardtokenissuerid
    // Not yet supported: custom start time
    // Not yet supported: custom end time
    // Not yet supported: generic Custom ExtendedInformation
   
    if (submessage.getCertificateSerialNumber() != null) {
      ExtendedInformation ei = result.getExtendedinformation();
      if (ei == null) {
        ei = new ExtendedInformation();
      }
            ei.setCertificateSerialNumber(submessage.getCertificateSerialNumber());
            result.setExtendedinformation(ei);
        }
   
      if (submessage.getPassword() == null) {
        final IPasswordGenerator pwdgen = PasswordGeneratorFactory.getInstance(PasswordGeneratorFactory.PASSWORDTYPE_ALLPRINTABLE);
      final String pwd = pwdgen.getNewPassword(12, 12);                 
        result.setPassword(pwd);
      } else {
        result.setPassword(submessage.getPassword());
      }
     
      return result;
    }
View Full Code Here

            userExists = true;
          }
        }
        if (userExists) {
            log.info("User foo already exists, resetting status.");
            UserDataVO userdata = new UserDataVO("foo", userDN, caid, null, "foo@anatom.se", SecConst.USER_ENDUSER, SecConst.EMPTY_ENDENTITYPROFILE,
                    SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.TOKEN_SOFT_PEM, 0, null);
            userdata.setStatus(UserDataConstants.STATUS_NEW);
            userdata.setPassword("foo123");
            userAdminSession.changeUser(admin, userdata, false);
            log.debug("Reset status to NEW");
        }
        KeyPair keys = genKeys();
View Full Code Here

                }
                // Create a new user
                ExtendedInformation ei = new ExtendedInformation();
                ei.setCustomData(EndEntityProfile.STARTTIME, "0:00:00");
                ei.setCustomData(EndEntityProfile.ENDTIME, "0:00:50");
                UserDataVO userdata = new UserDataVO(TESTUSERNAME, userDN, caid, "", "foo@bar.se", UserDataConstants.STATUS_NEW, SecConst.USER_ENDUSER,
                        endEntityProfileSession.getEndEntityProfileId(admin, TESTPROFILE), certprofileid, new Date(), new Date(), SecConst.TOKEN_SOFT_PEM, 0, ei);
                userdata.setPassword("foo123");
                try {
                    userAdminSession.revokeAndDeleteUser(admin, TESTUSERNAME, RevokedCertInfo.REVOCATION_REASON_KEYCOMPROMISE);
                } catch (NotFoundException nfe) {
                }
                userAdminSession.addUser(admin, userdata, false);
View Full Code Here

    protected void setupAccessRights() throws Exception {
        boolean userAdded = false;

        if (!userAdminSession.existsUser(intAdmin, TEST_ADMIN_USERNAME)) {
            UserDataVO user1 = new UserDataVO();
            user1.setUsername(TEST_ADMIN_USERNAME);
            user1.setPassword("foo123");
            user1.setDN("CN=wstest");
            CAInfo cainfo = caAdminSessionRemote.getCAInfo(intAdmin, getAdminCAName());
            assertNotNull("No CA with name "+getAdminCAName()+" was found.", cainfo);
            user1.setCAId(cainfo.getCAId());
            user1.setEmail(null);
            user1.setSubjectAltName(null);
            user1.setStatus(UserDataVOWS.STATUS_NEW);
            user1.setTokenType(SecConst.TOKEN_SOFT_JKS);
            user1.setEndEntityProfileId(SecConst.EMPTY_ENDENTITYPROFILE);
            user1.setCertificateProfileId(SecConst.CERTPROFILE_FIXED_ENDUSER);
            user1.setType(65);

            userAdminSession.addUser(intAdmin, user1, true);
            userAdded = true;

            boolean adminExists = false;
            AdminGroup admingroup = adminGroupSession.getAdminGroup(intAdmin, AdminGroup.TEMPSUPERADMINGROUP);
            Iterator<AdminEntity> iter = admingroup.getAdminEntities().iterator();
            while (iter.hasNext()) {
                AdminEntity adminEntity = iter.next();
                if (adminEntity.getMatchValue().equals(TEST_ADMIN_USERNAME)) {
                    adminExists = true;
                }
            }

            if (!adminExists) {
                List<AdminEntity> list = new ArrayList<AdminEntity>();
                list.add(new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASE, TEST_ADMIN_USERNAME, cainfo.getCAId()));
                adminEntitySession.addAdminEntities(intAdmin, AdminGroup.TEMPSUPERADMINGROUP, list);
                authorizationSession.forceRuleUpdate(intAdmin);
            }

        }

        if (!userAdminSession.existsUser(intAdmin, TEST_NONADMIN_USERNAME)) {
            UserDataVO user1 = new UserDataVO();
            user1.setUsername(TEST_NONADMIN_USERNAME);
            user1.setPassword("foo123");
            user1.setDN("CN=wsnonadmintest");
            CAInfo cainfo = caAdminSessionRemote.getCAInfo(intAdmin, getAdminCAName());
            user1.setCAId(cainfo.getCAId());
            user1.setEmail(null);
            user1.setSubjectAltName(null);
            user1.setStatus(UserDataVOWS.STATUS_NEW);
            user1.setTokenType(SecConst.TOKEN_SOFT_JKS);
            user1.setEndEntityProfileId(SecConst.EMPTY_ENDENTITYPROFILE);
            user1.setCertificateProfileId(SecConst.CERTPROFILE_FIXED_ENDUSER);
            user1.setType(1);

            userAdminSession.addUser(intAdmin, user1, true);
            userAdded = true;
        }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.UserDataVO

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.