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

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


          }

          // Check Issuer Trust
          try{
            int caid = CertTools.getIssuerDN(cert).hashCode();
            CAInfo cAInfo = caAdminSession.getCAInfo(pubAdmin, caid);
            if(cAInfo != null){
              retval.getValidReason().add(XKMSConstants.STATUSREASON_ISSUERTRUST);

              // Check signature 
              try{
                if(CertTools.verify(cert, cAInfo.getCertificateChain())){
                  retval.getValidReason().add(XKMSConstants.STATUSREASON_SIGNATURE);
                }else{
                  retval.getInvalidReason().add(XKMSConstants.STATUSREASON_SIGNATURE);
                  allValid = false;
                  inValidSet = true;
View Full Code Here


                                       );
           
            getLogger().info("Creating CA...");
            ejb.getCAAdminSession().createCA(getAdmin(), cainfo);
           
            CAInfo newInfo = ejb.getCAAdminSession().getCAInfo(getAdmin(), caname);
            int caid = newInfo.getCAId();
            getLogger().info("CAId for created CA: " + caid);
            getLogger().info("-Created and published initial CRL.");
            getLogger().info("CA initialized");
        } catch (Exception e) {
          getLogger().debug("An error occured: ", e);
View Full Code Here

     * xkms.response.causedforsigning on which CA that should
     * be used for signing XKMS requests
     */
    public static synchronized int cAIdUsedForSigning(Admin admin, CAAdminSession cAAdminSession){
      if(cAIdUsedForSigning == null){
        CAInfo info = cAAdminSession.getCAInfo(admin, XkmsConfiguration.getResponseCaUsedForSigning());
        if(info == null){       
          throw new EJBException("Property parameter xkms.response.causedforsigning ("+XkmsConfiguration.getResponseCaUsedForSigning()+") is missconfigured, should contain a existing CA name.");
        }         
       
        cAIdUsedForSigning = Integer.valueOf(info.getCAId());       
      }
      return cAIdUsedForSigning.intValue();
    }
View Full Code Here

    public static synchronized Collection getAcceptedCA(Admin admin,CAAdminSession cAAdminSession){
      if(acceptedCAs == null){
        acceptedCAs = new ArrayList();
        String[] cANames = XkmsConfiguration.getRequestAcceptedCas();
        for(int i=0; i < cANames.length;i++){
          CAInfo info = cAAdminSession.getCAInfo(admin, cANames[i]);
          if(info == null){       
            throw new EJBException("Property parameter xkms.request.acceptedcas is missconfigured, should contain a ';' separated string of existing CA names.");
          }
          acceptedCAs.add(Integer.valueOf(info.getCAId()));
        }
      }
      return acceptedCAs;
    }
View Full Code Here

        updatePropertyOnServer(CmpConfiguration.CONFIG_RA_NAMEGENERATIONSCHEME, "DN");
        updatePropertyOnServer(CmpConfiguration.CONFIG_RA_NAMEGENERATIONPARAMS, "CN");

        CryptoProviderTools.installBCProvider();
        // Try to use AdminCA1 if it exists
        final CAInfo adminca1;

        adminca1 = caAdminSessionRemote.getCAInfo(admin, "AdminCA1");

        if (adminca1 == null) {
            final Collection<Integer> caids;

            caids = caSession.getAvailableCAs(admin);

            final Iterator<Integer> iter = caids.iterator();
            int tmp = 0;
            while (iter.hasNext()) {
                tmp = iter.next().intValue();
            }
            caid = tmp;
        } else {
            caid = adminca1.getCAId();
        }
        if (caid == 0) {
            assertTrue("No active CA! Must have at least one active CA to run tests!", false);
        }
        final CAInfo cainfo;

        cainfo = caAdminSessionRemote.getCAInfo(admin, caid);

        Collection<Certificate> certs = cainfo.getCertificateChain();
        if (certs.size() > 0) {
            Iterator<Certificate> certiter = certs.iterator();
            Certificate cert = certiter.next();
            String subject = CertTools.getSubjectDN(cert);
            if (StringUtils.equals(subject, cainfo.getSubjectDN())) {
                // Make sure we have a BC certificate
                try {
                    cacert = (X509Certificate) CertTools.getCertfromByteArray(cert.getEncoded());
                } catch (Exception e) {
                    throw new Error(e);
View Full Code Here

            checkCmpPKIConfirmMessage(userDN, cacert, resp);
        }
    }

    public void test01CrmfHttpOkUser() throws Exception {
        final CAInfo caInfo = caAdminSessionRemote.getCAInfo(admin, "AdminCA1");
        // make sure same keys for different users is prevented
        caInfo.setDoEnforceUniquePublicKeys(true);
        // make sure same DN for different users is prevented
        caInfo.setDoEnforceUniqueDistinguishedName(true);
        caAdminSessionRemote.editCA(admin, caInfo);

        final KeyPair key1 = KeyTools.genKeys("512", AlgorithmConstants.KEYALGORITHM_RSA);
        final KeyPair key2 = KeyTools.genKeys("512", AlgorithmConstants.KEYALGORITHM_RSA);
        final KeyPair key3 = KeyTools.genKeys("512", AlgorithmConstants.KEYALGORITHM_RSA);
View Full Code Here

              Collection acceptedCAIds = XKMSConfig.getAcceptedCA(intAdmin, caAdminSession);
              if(!acceptedCAIds.contains(Integer.valueOf(cAId))){
                throw new Exception("Error XKMS request signature certificate isn't among the list of accepted CA certificates");
              }

              CAInfo cAInfo = caAdminSession.getCAInfo(intAdmin, cAId);
              Collection cACertChain = cAInfo.getCertificateChain();
              // Check issuer and validity           
              X509Certificate rootCert = null;
              Iterator iter = cACertChain.iterator();
              while(iter.hasNext()){
                X509Certificate cert = (X509Certificate) iter.next();
View Full Code Here

            if (adminGroup == null) {
                getLogger().error("No such group \"" + groupName + "\" .");
                return;
            }
            String caName = args[2];
            CAInfo caInfo = ejb.getCAAdminSession().getCAInfo(getAdmin(), caName);
            if (caInfo == null) {
                getLogger().error("No such CA \"" + caName + "\" .");
                return;
            }
            int matchWith = Arrays.asList(AdminEntity.MATCHWITHTEXTS).indexOf(args[3]);
View Full Code Here

            if (ejb.getAdminGroupSession().getAdminGroup(getAdmin(), groupName) == null) {
                getLogger().error("No such group \"" + groupName + "\" .");
                return;
            }
            String caName = args[2];
            CAInfo caInfo = ejb.getCAAdminSession().getCAInfo(getAdmin(), caName);
            if (caInfo == null) {
                getLogger().error("No such CA \"" + caName + "\" .");
                return;
            }
            int caid = caInfo.getCAId();
            int matchWith = Arrays.asList(AdminEntity.MATCHWITHTEXTS).indexOf(args[3]);
            if (matchWith == -1) {
                getLogger().error("No such thing to match with as \"" + args[3] + "\" .");
                return;
            }
View Full Code Here

      return;
    }
    try {
        final String caName = args[1];
        {
            final CAInfo cainfo = ejb.getCAAdminSession().getCAInfo(getAdmin(), caName);
            final String certProfileName = args[2];
            getLogger().debug("Searching for Certificate Profile " + certProfileName);
            final int certificateprofileid = ejb.getCertificateProfileSession().getCertificateProfileId(getAdmin(), certProfileName);
            if (certificateprofileid == SecConst.PROFILE_NO_PROFILE) {
              getLogger().error("Certificate Profile " + certProfileName + " doesn't exists.");
                throw new Exception("Certificate Profile '" + certProfileName + "' doesn't exists.");
            }
                cainfo.setCertificateProfileId(certificateprofileid);
                ejb.getCAAdminSession().editCA(getAdmin(), cainfo);
        }{
                final CAInfo cainfo = ejb.getCAAdminSession().getCAInfo(getAdmin(), caName);
                getLogger().info("Certificate profile for CA changed:");
                getLogger().info("CA Name: " + caName);
                getLogger().info("Certificate Profile: " + ejb.getCertificateProfileSession().getCertificateProfileName(getAdmin(), cainfo.getCertificateProfileId()));
        }
    } catch (Exception e) {
      getLogger().error(e.getMessage());
      usage();
    }
View Full Code Here

TOP

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

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.