Package org.ejbca.core.model.ca.caadmin

Examples of org.ejbca.core.model.ca.caadmin.CA


        final IPatternLogger logger = TransactionLogger.getPatternLogger();
    try {
      EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, certificateProfileSession, certificateStoreSession, endEntityProfileSession, hardTokenSession, userAdminSession);
      Admin admin = ejbhelper.getAdmin(true);
            logAdminName(admin,logger);
      CA ca = caSession.getCA(admin, caname);
      crlStoreSession.run(admin, ca);
    } catch (AuthorizationDeniedException e) {
            throw EjbcaWSHelper.getEjbcaException(e, logger, ErrorCode.NOT_AUTHORIZED, Level.ERROR);
        } catch (RuntimeException e) {  // EJBException, ...
            throw EjbcaWSHelper.getInternalException(e, logger);
View Full Code Here


                iter = caSession.getAvailableCAs().iterator();
            }
            while (iter.hasNext()) {
                int caid = ((Integer) iter.next()).intValue();
                log.debug("createCRLs for caid: " + caid);
                CA ca = caSession.getCA(admin, caid);
                if (crlCreateSession.runNewTransactionConditioned(admin, ca, addtocrloverlaptime)) {
                    createdcrls++;
                }
            }
        } catch (Exception e) {
View Full Code Here

                iter = caSession.getAvailableCAs().iterator();
            }
            while (iter.hasNext()) {
                int caid = iter.next().intValue();
                log.debug("createDeltaCRLs for caid: " + caid);
                CA ca = caSession.getCA(admin, caid);
                if (crlCreateSession.runDeltaCRLnewTransactionConditioned(admin, ca, crloverlaptime)) {
                    createddeltacrls++;
                }
            }
        } catch (Exception e) {
View Full Code Here

     * @return CA
     * @throws java.io.UnsupportedEncodingException
     * @throws IllegalKeyStoreException
     */
    private final CA readAndUpgradeCAInternal() throws java.io.UnsupportedEncodingException, IllegalKeyStoreException {
        CA ca = null;
        // First check if we already have a cached instance of the CA
        ca = CACacheManager.instance().getAndUpdateCA(getCaId().intValue(), getStatus(), getExpireTime(), getName(), getSubjectDN());
        boolean isUpdated = false;
        if (ca != null) {
          if (log.isDebugEnabled()) {
            log.debug("Found CA ('"+ca.getName()+"', "+getCaId().intValue()+") in cache.");
          }
          final long update = ca.getCAInfo().getUpdateTime().getTime();
          final long t = getUpdateTime();
          //log.debug("updateTime from ca = "+update);
          //log.debug("updateTime from db = "+t);
          if (update < t) {
              if (log.isDebugEnabled()) {
                log.debug("CA '"+ca.getName()+"' has been updated in database, need to refresh cache");
              }
            isUpdated = true;
          }
        }
        if ( (ca == null) || isUpdated) {
          if (log.isDebugEnabled()) {
            log.debug("Re-reading CA from database: "+getCaId().intValue());
          }
          final java.beans.XMLDecoder decoder = new  java.beans.XMLDecoder(new java.io.ByteArrayInputStream(getData().getBytes("UTF8")));
          final HashMap h = (HashMap) decoder.readObject();
            decoder.close();
            // Handle Base64 encoded string values
            final HashMap<Object, Object> data = new Base64GetHashMap(h);
           
            // If CA-data is upgraded we want to save the new data, so we must get the old version before loading the data
            // and perhaps upgrading
            final float oldversion = ((Float) data.get(UpgradeableDataHashMap.VERSION)).floatValue();
            switch(((Integer)(data.get(CA.CATYPE))).intValue()){
                case CAInfo.CATYPE_X509:
                    ca = new X509CA(data, getCaId().intValue(), getSubjectDN(), getName(), getStatus(), getUpdateTimeAsDate(), new Date(getExpireTime()));                   
                    break;
                case CAInfo.CATYPE_CVC:
                    ca = new CVCCA(data, getCaId().intValue(), getSubjectDN(), getName(), getStatus(), getUpdateTimeAsDate());                   
                    break;
            }
            final boolean upgradedExtendedService = ca.upgradeExtendedCAServices();
            // Compare old version with current version and save the data if there has been a change
            if ( ((ca != null) && (Float.compare(oldversion, ca.getVersion()) != 0)) || upgradedExtendedService) {
              // Make sure we upgrade the CAToken as well, if needed
                ca.getCAToken();
                setCA(ca);
                log.debug("Stored upgraded CA ('"+ca.getName()+"', "+getCaId().intValue()+") with version "+ca.getVersion());
            }
            // We have to do the same if CAToken was upgraded
            // Add CA to the cache
            CACacheManager.instance().addCA(getCaId().intValue(), ca);
        }
View Full Code Here

    protected void createCRL(String issuerdn, boolean deltaCRL) {
        getLogger().trace(">createCRL()");
        try {
            if (issuerdn != null) {
                CA ca = ejb.getCaSession().getCA(getAdmin(), issuerdn.hashCode());
                if (!deltaCRL) {
                    ejb.getCrlStoreSession().run(getAdmin(), ca);
                    int number = ejb.getCrlSession().getLastCRLNumber(getAdmin(), issuerdn, false);
                    getLogger().info("CRL with number " + number + " generated.");
                } else {
View Full Code Here

        return getCAInternal(caid, null);
    }
   
    @Override
    public CA getCA(Admin admin, String name) throws CADoesntExistsException {
        CA ca = getCAInternal(-1, name);
        if (!authorizedToCA(admin, ca.getCAId())) {
            if (log.isDebugEnabled()) {
                log.debug("Admin (" + admin.toString() + ") is not authorized to CA with name: " + name);
            }
            String msg = intres.getLocalizedMessage("caadmin.canotexistsid", name);
            throw new CADoesntExistsException(msg);
View Full Code Here

        }
       
        // First check if we already have a cached instance of the CA
        // This should only be done if we have enabled caching, meaning that
        // we will not update the CA values until cache time expires
        CA ca = null;
        if (CaHelperCache.lastCACacheUpdateTime + EjbcaConfiguration.getCacheCaTimeInCaAdminSession() > System.currentTimeMillis()) {
            if (caid != -1) {
                ca = CACacheManager.instance().getCA(caid);
            } else {
                ca = CACacheManager.instance().getCA(name);
View Full Code Here

  @Override
  public void execute(String[] args) throws ErrorAdminCommandException {
        try {
          Collection<Integer> caIds = ejb.getCaSession().getAvailableCAs(getAdmin());
          for (Integer caId : caIds) {
            final CA ca = ejb.getCaSession().getCA(getAdmin(), caId);
            final StringBuilder sb = new StringBuilder();
            sb.append("\"").append(ca.getName()).append("\" \"").append(ca.getSubjectDN()).append("\"");
            final CRLInfo crlInfo = ejb.getCrlSession().getLastCRLInfo(getAdmin(), ca.getSubjectDN(), false);
            if (crlInfo != null) {
                sb.append(" CRL# ").append(crlInfo.getLastCRLNumber());
                sb.append(" issued ").append(ValidityDate.formatAsUTC(crlInfo.getCreateDate()));
                sb.append(" expires ").append(ValidityDate.formatAsUTC(crlInfo.getExpireDate()));
            } else {
              sb.append(" NO_CRL_ISSUED");
            }
            final CRLInfo deltaCrlInfo = ejb.getCrlSession().getLastCRLInfo(getAdmin(), ca.getSubjectDN(), true);
            if (deltaCrlInfo!=null) {
                sb.append(" DELTACRL# ").append(deltaCrlInfo.getLastCRLNumber());
                sb.append(" issued ").append(ValidityDate.formatAsUTC(deltaCrlInfo.getCreateDate()));
                sb.append(" expires ").append(ValidityDate.formatAsUTC(deltaCrlInfo.getExpireDate()));
            } else {
View Full Code Here

    }

    /** Test error handling during CRL creation. */
    public void test11CrlCreateSessionErrorHandling() throws CADoesntExistsException {
      log.trace(">test11CrlCreateSessionErrorHandling()");
      CA ca = caSession.getCA(admin, getTestCAId());
      ca.setStatus(SecConst.CA_OFFLINE);
      try {
      crlCreateSession.createCRL(admin, ca, null, 0);
      assertTrue("Trying to generate a CRL for CA with status CA_OFFLINE did not throw the CATokenOfflineException.", false);
    } catch (CATokenOfflineException e) {
      // Expected
View Full Code Here

    public void cloneCertificateProfile(String originalname, String newname) throws CertificateProfileExistsException, AuthorizationDeniedException {
      certificateprofiles.cloneCertificateProfile(originalname, newname);
    }   
     
    public void createCRL(String issuerdn) throws CATokenOfflineException  {     
        CA ca;
        try {
            ca = caSession.getCA(administrator, issuerdn.hashCode());
        } catch (CADoesntExistsException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.caadmin.CA

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.