Package org.ejbca.core.protocol.ws.objects

Examples of org.ejbca.core.protocol.ws.objects.UserDataVOWS


  }
 
 
 
  protected UserDataVOWS convertUserDataVO(Admin admin, UserDataVO userdata) throws EjbcaException, ClassCastException {
      UserDataVOWS dataWS = new UserDataVOWS();
    String username = userdata.getUsername();
    String caname = caAdminSession.getCAInfo(admin,userdata.getCAId()).getName();

    dataWS.setUsername(username);

    if(caname == null){
      String message = "Error CA id " + userdata.getCAId() + " doesn't exists. User: "+username;
      log.error(message);
      throw new EjbcaException(ErrorCode.CA_NOT_EXISTS, message);
    }
    dataWS.setCaName(caname);
   
    String endentityprofilename = endEntityProfileSession.getEndEntityProfileName(admin,userdata.getEndEntityProfileId());
    if(endentityprofilename == null){
      String message = "Error End Entity profile id " + userdata.getEndEntityProfileId() + " doesn't exists. User: "+username;
      log.error(message);
      throw new EjbcaException(ErrorCode.EE_PROFILE_NOT_EXISTS, message);
    }
        dataWS.setEndEntityProfileName(endentityprofilename);

    String certificateprofilename = certificateProfileSession.getCertificateProfileName(admin,userdata.getCertificateProfileId());
    if(certificateprofilename == null){
      String message = "Error Certificate profile id " + userdata.getCertificateProfileId() + " doesn't exists. User: "+username;
      log.error(message);
      throw new EjbcaException(ErrorCode.CERT_PROFILE_NOT_EXISTS, message);
    }
      dataWS.setCertificateProfileName(certificateprofilename);
   
    String hardtokenissuername = null;
    if(userdata.getHardTokenIssuerId() != 0){
       hardtokenissuername = hardTokenSession.getHardTokenIssuerAlias(admin,userdata.getHardTokenIssuerId());
       if(hardtokenissuername == null){
         String message = "Error Hard Token Issuer id " + userdata.getHardTokenIssuerId() + " doesn't exists. User: "+username;
         log.error(message);
         throw new EjbcaException(ErrorCode.HARD_TOKEN_ISSUER_NOT_EXISTS, message);
       }
       dataWS.setHardTokenIssuerName(hardtokenissuername);
    }
   
    String tokenname = getTokenName(admin,userdata.getTokenType());
    if(tokenname == null){
      String message = "Error Token Type id " + userdata.getTokenType() + " doesn't exists. User: "+username;
      log.error(message);
      throw new EjbcaException(ErrorCode.UNKOWN_TOKEN_TYPE, message);
    }
    dataWS.setTokenType(tokenname);

    dataWS.setPassword(null);
    dataWS.setClearPwd(false);
    dataWS.setSubjectDN(userdata.getDN());
    dataWS.setSubjectAltName(userdata.getSubjectAltName());
    dataWS.setEmail(userdata.getEmail());
    dataWS.setStatus(userdata.getStatus());

    ExtendedInformation ei = userdata.getExtendedinformation();
    if(ei != null) {
      String startTime = ei.getCustomData(ExtendedInformation.CUSTOM_STARTTIME);
      if (startTime!=null && startTime.length()>0 && !startTime.matches("^\\d+:\\d?\\d:\\d?\\d$")) {
        try {
          // Always respond with the time formatted in a neutral time zone
          startTime = ValidityDate.getISO8601FromImpliedUTC(startTime, ValidityDate.TIMEZONE_UTC);
        } catch (ParseException e) {
          log.info("Failed to convert " + ExtendedInformation.CUSTOM_STARTTIME + " to ISO8601 format.");
        }
      }
        dataWS.setStartTime(startTime);
        String endTime = ei.getCustomData(ExtendedInformation.CUSTOM_ENDTIME);
      if (endTime!=null && endTime.length()>0 && !endTime.matches("^\\d+:\\d?\\d:\\d?\\d$")) {
        try {
          // Always respond with the time formatted in a neutral time zone
          endTime = ValidityDate.getISO8601FromImpliedUTC(endTime, ValidityDate.TIMEZONE_UTC);
        } catch (ParseException e) {
          log.info("Failed to convert " + ExtendedInformation.CUSTOM_ENDTIME + " to ISO8601 format.");
        }
      }
            dataWS.setEndTime(endTime);
        // Fill custom data in extended information
        HashMap<String, ?> data = (HashMap<String,?>)ei.getData();
        if (data != null) {
          List<ExtendedInformationWS> extendedInfo = new ArrayList<ExtendedInformationWS> ();
          Set<String> set = data.keySet();
          for (Iterator<String> iterator = set.iterator(); iterator.hasNext();) {
            String key = iterator.next();
            String value = ei.getMapData(key);
            if (value != null) {
              extendedInfo.add(new ExtendedInformationWS (key, value));       
            }
          }
          dataWS.setExtendedInformation(extendedInfo);
        }
    }

    return dataWS;
  }
View Full Code Here

TOP

Related Classes of org.ejbca.core.protocol.ws.objects.UserDataVOWS

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.