Package org.ejbca.core.model.ra

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


    if(tokenid == 0){
      throw new EjbcaException(ErrorCode.UNKOWN_TOKEN_TYPE,
                "Error Token Type  " + userdata.getTokenType() + " doesn't exists.");
    }

    final ExtendedInformation ei = new ExtendedInformation();
    boolean useEI = false;

    if(userdata.getStartTime() != null) {
      String customStartTime = userdata.getStartTime();
      try {
        if (customStartTime.length()>0 && !customStartTime.matches("^\\d+:\\d?\\d:\\d?\\d$")) {
          if (!customStartTime.matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{2}:\\d{2}$")) {
            // We use the old absolute time format, so we need to upgrade and log deprecation info
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US);
            final String newCustomStartTime = ValidityDate.formatAsISO8601(oldDateFormat.parse(customStartTime), ValidityDate.TIMEZONE_UTC);
            log.info("WS client sent userdata with startTime using US Locale date format. yyyy-MM-dd HH:mm:ssZZ should be used for absolute time and any fetched UserDataVOWS will use this format.");
            if (log.isDebugEnabled()) {
              log.debug(" Changed startTime \"" + customStartTime + "\" to \"" + newCustomStartTime + "\" in UserDataVOWS.");
            }
            customStartTime = newCustomStartTime;
          }
          customStartTime = ValidityDate.getImpliedUTCFromISO8601(customStartTime);
        }
        ei.setCustomData(ExtendedInformation.CUSTOM_STARTTIME, customStartTime);
        useEI = true;
      } catch (ParseException e) {
        log.info("WS client supplied invalid startTime in userData. startTime for this request was ignored. Supplied SubjectDN was \"" + userdata.getSubjectDN() + "\"");
        throw new EjbcaException(ErrorCode.FIELD_VALUE_NOT_VALID, "Invalid date format in StartTime.");
      }
    }
        if(userdata.getEndTime() != null) {
      String customEndTime = userdata.getEndTime();
      try {
        if (customEndTime.length()>0 && !customEndTime.matches("^\\d+:\\d?\\d:\\d?\\d$")){
          if (!customEndTime.matches("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{2}:\\d{2}$")) {
            // We use the old absolute time format, so we need to upgrade and log deprecation info
            final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US);
            final String newCustomStartTime = ValidityDate.formatAsISO8601(oldDateFormat.parse(customEndTime), ValidityDate.TIMEZONE_UTC);
            log.info("WS client sent userdata with endTime using US Locale date format. yyyy-MM-dd HH:mm:ssZZ should be used for absolute time and any fetched UserDataVOWS will use this format.");
            if (log.isDebugEnabled()) {
              log.debug(" Changed endTime \"" + customEndTime + "\" to \"" + newCustomStartTime + "\" in UserDataVOWS.");
            }
            customEndTime = newCustomStartTime;
          }
          customEndTime = ValidityDate.getImpliedUTCFromISO8601(customEndTime);
        }
              ei.setCustomData(ExtendedInformation.CUSTOM_ENDTIME, customEndTime);
              useEI = true;
      } catch (ParseException e) {
        log.info("WS client supplied invalid endTime in userData. endTime for this request was ignored. Supplied SubjectDN was \"" + userdata.getSubjectDN() + "\"");
        throw new EjbcaException(ErrorCode.FIELD_VALUE_NOT_VALID, "Invalid date format in EndTime.");
      }
        }
        if ( userdata.getCertificateSerialNumber()!=null) {
            ei.setCertificateSerialNumber(userdata.getCertificateSerialNumber());
            useEI = true;
        }

        // Set generic Custom ExtendedInformation from potential data in UserDataVOWS
        List<ExtendedInformationWS> userei = userdata.getExtendedInformation();
        if (userei != null) {
            for (ExtendedInformationWS item : userei) {
              String key = item.getName();
              String value = item.getValue ();
              if ((key != null) && (value != null)) {
                if (log.isDebugEnabled()) {
                  log.debug("Set generic extended information: "+key+", "+value);
                }
                    ei.setMapData(key, value);                         
                    useEI = true;
              } else {
                if (log.isDebugEnabled()) {
                  log.debug("Key or value is null when trying to set generic extended information.");
                }
View Full Code Here


    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);
View Full Code Here

      assertTrue(notBefore.before(now));
      assertTrue(notAfter.after(cal1.getTime()));
      assertTrue(notAfter.before(cal2.getTime()));
     
      // Add extended information for the user and see that it does not affect it either
      ExtendedInformation ei = new ExtendedInformation();
      ei.setCustomData(EndEntityProfile.STARTTIME, "10:0:0");
      ei.setCustomData(EndEntityProfile.ENDTIME, "30:0:0");
      subject.setExtendedinformation(ei);
        cv = new CertificateValidity(subject, cp, requestNotBefore.getTime(), requestNotAfter.getTime(), cacert, false);
      notBefore = cv.getNotBefore();
      notAfter = cv.getNotAfter();
      assertTrue(notBefore.before(now));
View Full Code Here

        // Set back start date ten minutes to avoid some problems with unsynchronized clocks.
        Date now = new Date((new Date()).getTime() - SETBACKTIME);
    Date startTimeDate = null;
    Date endTimeDate = null;
        // Extract requested start and endtime from end endtity profile / user data
        ExtendedInformation ei = subject.getExtendedinformation();
        if ( ei != null ) {
            final String eiStartTime = ei.getCustomData(ExtendedInformation.CUSTOM_STARTTIME);
            final String eiEndTime = ei.getCustomData(ExtendedInformation.CUSTOM_ENDTIME);
          if ( eiStartTime != null ) {
            if ( eiStartTime.matches("^\\d+:\\d?\\d:\\d?\\d$") ) {
              final String[] startTimeArray = eiStartTime.split(":");
              long relative = (Long.parseLong(startTimeArray[0])*24*60 + Long.parseLong(startTimeArray[1])*60 +
                  Long.parseLong(startTimeArray[2])) * 60 * 1000;
 
View Full Code Here

                    UserDataVO cadata = new UserDataVO("nobody", cainfo.getSubjectDN(), cainfo.getSubjectDN().hashCode(), subjectAltName, null, 0, 0, 0, cainfo
                            .getCertificateProfileId(), null, null, 0, 0, null);
                    // We can pass the PKCS10 request message as extra
                    // parameters
                    if (requestmessage instanceof PKCS10RequestMessage) {
                        ExtendedInformation extInfo = new ExtendedInformation();
                        PKCS10CertificationRequest pkcs10 = ((PKCS10RequestMessage) requestmessage).getCertificationRequest();
                        extInfo.setCustomData(ExtendedInformation.CUSTOM_PKCS10, new String(Base64.encode(pkcs10.getEncoded())));
                        cadata.setExtendedinformation(extInfo);
                    }
                    CertificateProfile certprofile = certificateProfileSession.getCertificateProfile(admin, cainfo.getCertificateProfileId());
                    String sequence = null;
                    byte[] ki = requestmessage.getRequestKeyInfo();
View Full Code Here

                  getLogger().info("Found user:");
                  getLogger().info("username=" + data.getUsername());
                    getLogger().info("password=" + data.getPassword());
                    getLogger().info("dn: \"" + data.getDN() + "\"");
                    getLogger().info("altName: \"" + data.getSubjectAltName() + "\"");
                    ExtendedInformation ei = data.getExtendedinformation();
                    getLogger().info("directoryAttributes: \"" + (ei != null ? ei.getSubjectDirectoryAttributes() : "") + "\"");
                    getLogger().info("email=" + data.getEmail());
                    getLogger().info("status=" + data.getStatus());
                    getLogger().info("type=" + data.getType());
                    getLogger().info("token type=" + data.getTokenType());
                    getLogger().info("end entity profile id=" + data.getEndEntityProfileId());
View Full Code Here

              return;
            }
            getLogger().info("Setting subject directory attributes '" + attributes + "' for user " + username);
            try {
              UserDataVO uservo = ejb.getUserAdminSession().findUser(getAdmin(), username);
              ExtendedInformation ext = uservo.getExtendedinformation();
              if (ext == null) {
                ext = new ExtendedInformation();
              }
              ext.setSubjectDirectoryAttributes(attributes);
              uservo.setExtendedinformation(ext);
              ejb.getUserAdminSession().changeUser(getAdmin(), uservo, false);
            } catch (AuthorizationDeniedException e) {
              getLogger().error("Not authorized to change userdata.");
            } catch (UserDoesntFullfillEndEntityProfile e) {
View Full Code Here

        }

        // Save the revocation code
        if(revocationCode != null && !recover){
          UserDataVO data = userAdminSession.findUser(pubAdmin, userDataVO.getUsername());
          ExtendedInformation ei = data.getExtendedinformation();
          if (ei == null) {
            ei = new ExtendedInformation();
          }
          ei.setRevocationCodeIdentifier(revocationCode);
          data.setExtendedinformation(ei);
          userAdminSession.changeUser(raAdmin, data, true);

        }
View Full Code Here

  }
 

    protected UserDataVO generateUserDataVO(Admin admin, ExtRARequest submessage) throws ClassCastException, EjbcaException {
        String dirAttributes = submessage.getSubjectDirectoryAttributes();
        ExtendedInformation ext = null;
        if (dirAttributes != null) {
            ext = new ExtendedInformation();
            ext.setSubjectDirectoryAttributes(dirAttributes);
        }
           return  new UserDataVO(submessage.getUsername(),
                   submessage.getSubjectDN(),
                   getCAId(admin,submessage.getCAName()),
                   submessage.getSubjectAltName(),
View Full Code Here

    // 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);
View Full Code Here

TOP

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

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.