Package org.ejbca.core.model.ca.store

Examples of org.ejbca.core.model.ca.store.CertReqHistory


        final IPatternLogger logger = TransactionLogger.getPatternLogger();
        logAdminName(admin,logger);
    try{
      String bcIssuerDN = CertTools.stringToBCDNString(issuerDN);
      caAdminSession.verifyExistenceOfCA(bcIssuerDN.hashCode());
      CertReqHistory certreqhist = certificateStoreSession.getCertReqHistory(admin,new BigInteger(serialNumberInHex,16), bcIssuerDN);
      if(certreqhist == null){
        throw new PublisherException("Error: the  certificate with  serialnumber : " + serialNumberInHex +" and issuerdn " + issuerDN + " couldn't be found in database.");
      }

      ejbhelper.isAuthorizedToRepublish(admin, certreqhist.getUsername(),bcIssuerDN.hashCode());

      if(certreqhist != null){
        CertificateProfile certprofile = certificateProfileSession.getCertificateProfile(admin,certreqhist.getUserDataVO().getCertificateProfileId());
        java.security.cert.Certificate cert = certificateStoreSession.findCertificateByFingerprint(admin, certreqhist.getFingerprint());
        if(certprofile != null){
          CertificateInfo certinfo = certificateStoreSession.getCertificateInfo(admin, certreqhist.getFingerprint());
          if(certprofile.getPublisherList().size() > 0){
            if(publisherSession.storeCertificate(admin, certprofile.getPublisherList(), cert, certreqhist.getUserDataVO().getUsername(), certreqhist.getUserDataVO().getPassword(), certreqhist.getUserDataVO().getDN(),
                certinfo.getCAFingerprint(), certinfo.getStatus() , certinfo.getType(), certinfo.getRevocationDate().getTime(), certinfo.getRevocationReason(), certinfo.getTag(), certinfo.getCertificateProfileId(), certinfo.getUpdateTime().getTime(), certreqhist.getUserDataVO().getExtendedinformation())){
            }else{
              throw new PublisherException("Error: publication failed to at least one of the defined publishers.");
            }
          }else{
            throw new PublisherException("Error no publisher defined for the given certificate.");
View Full Code Here


   * @return certificate request history object
   */
  @Transient
    public CertReqHistory getCertReqHistory() {

    return new CertReqHistory(this.getFingerprint(),this.getSerialNumber(),
                              this.getIssuerDN(),this.getUsername(),new Date(this.getTimestamp()),
                              decodeXML(getUserDataVO(), false));
  }
View Full Code Here

         
          if(currentuser != null){
            userdatas[0] = currentuser;         
          }
          for(int i=0; i< hist.size();i++){
            CertReqHistory next = ((CertReqHistory) hist.get(i));
            userdatas[i+currentexists] = new UserView(next.getUserDataVO(),ejbcawebbean.getInformationMemory().getCAIdToNameMap());
          }
       
        }
        authorized=true;
    } catch(AuthorizationDeniedException e){ }           
View Full Code Here

    String username = null;
    String password = null;
    String dn = null;
    ExtendedInformation ei = null;
    final Certificate certificate = certificatedata.getCertificate();
    final CertReqHistory certreqhist = certificatesession.getCertReqHistory(administrator, CertTools.getSerialNumber(certificate), CertTools.getIssuerDN(certificate));
    if (certreqhist != null) {
      // First try to look up all info using the Certificate Request History from when the certificate was issued
      // We need this since the certificate subjectDN might be a subset of the subjectDN in the template
      certificateProfileId = certreqhist.getUserDataVO().getCertificateProfileId();
      username = certreqhist.getUserDataVO().getUsername();
      password = certreqhist.getUserDataVO().getPassword();
      dn = certreqhist.getUserDataVO().getDN();
      ei = certreqhist.getUserDataVO().getExtendedinformation();
    }
    final CertificateInfo certinfo = certificatesession.getCertificateInfo(administrator, CertTools.getFingerprintAsString(certificate));
    if (certinfo != null) {
      // If we are missing Certificate Request History for this certificate, we can at least recover some of this info
      if (certificateProfileId == SecConst.CERTPROFILE_NO_PROFILE) {
View Full Code Here

     *             error
     */
    public void test10getCertReqHistByIssuerDNAndSerial() throws Exception {
        log.trace(">test10getCertReqHistByIssuerDNAndSerial()");

        CertReqHistory certreqhist = certificateStoreSession.getCertReqHistory(admin, cert1.getSerialNumber(), cert1.getIssuerDN().toString());

        assertNotNull("Error couldn't find the certificate request data stored previously", certreqhist);

        UserDataVO userdata = certreqhist.getUserDataVO();
        assertTrue("Error wrong username.", (userdata.getUsername().equals(username)));
        assertTrue("Error wrong DN.", (userdata.getDN().equals("C=SE,O=PrimeCA,OU=TestCertificateData,CN=CertReqHist1")));

        log.trace("<test10getCertReqHistByIssuerDNAndSerial()");
    }
View Full Code Here

        Collection<CertReqHistory> result = certificateStoreSession.getCertReqHistory(admin, username);
        assertTrue("Error size of the returned collection.", (result.size() == 2));

        Iterator<CertReqHistory> iter = result.iterator();
        while (iter.hasNext()) {
            CertReqHistory certreqhist = iter.next();
            assertTrue("Error wrong DN", ((certreqhist.getUserDataVO().getDN().equals("C=SE,O=PrimeCA,OU=TestCertificateData,CN=CertReqHist1")) || (certreqhist
                    .getUserDataVO().getDN().equals("C=SE,O=PrimeCA,OU=TestCertificateData,CN=CertReqHist2"))));
        }
        log.trace("<test11getCertReqHistByUsername()");
    }
View Full Code Here

        log.trace(">test12removeCertReqHistData()");

        certificateStoreSession.removeCertReqHistoryData(admin, CertTools.getFingerprintAsString(cert1));
        certificateStoreSession.removeCertReqHistoryData(admin, CertTools.getFingerprintAsString(cert2));

        CertReqHistory certreqhist = certificateStoreSession.getCertReqHistory(admin, cert1.getSerialNumber(), cert1.getIssuerDN().toString());
        assertNull("Error removing cert req history data, cert1 data is still there", certreqhist);

        certreqhist = certificateStoreSession.getCertReqHistory(admin, cert2.getSerialNumber(), cert2.getIssuerDN().toString());
        assertNull("Error removing cert req history data, cert2 data is still there", certreqhist);
View Full Code Here

        final int caid = info.getIssuerDN().hashCode();
        final String username = info.getUsername();
        assertAuthorizedToCA(admin, caid, username, LogConstants.EVENT_ERROR_REVOKEDENDENTITY);
        int certificateProfileId = info.getCertificateProfileId();
        String userDataDN = info.getSubjectDN();
        final CertReqHistory certReqHistory = certificateStoreSession.getCertReqHistory(admin, certserno, issuerdn);
        UserData data = null;
        if (certReqHistory == null || XkmsConfiguration.getEnabled()) {
          // We could use userdata later, so try to find it
          data = UserData.findByUsername(entityManager, username);
        }
        int endEntityProfileId = -1;
        if (certReqHistory != null) {
            // Get the EEP that was used in the original issuance, if we can find it
          endEntityProfileId = certReqHistory.getUserDataVO().getEndEntityProfileId();
            // Republish with the same user DN that was used in the original publication, if we can find it
            userDataDN = certReqHistory.getUserDataVO().getDN();
            // If for some reason the certificate profile id was not set in the certificate data, try to get it from the certreq history
            if (certificateProfileId == SecConst.CERTPROFILE_NO_PROFILE) {
                certificateProfileId = certReqHistory.getUserDataVO().getCertificateProfileId();
            }
        } else if (data != null) {
          // Get the EEP that is currently used as a fallback, if we can find it
          endEntityProfileId = data.getEndEntityProfileId();
          // Republish with the same user DN that is currently used as a fallback, if we can find it
View Full Code Here

   
    // getCertReqHistory() might perform database updates, so we always need to run this in a transaction
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    @Override
    public CertReqHistory getCertReqHistory(Admin admin, BigInteger certificateSN, String issuerDN){
      CertReqHistory retval = null;
      Collection<CertReqHistoryData> result = CertReqHistoryData.findByIssuerDNSerialNumber(entityManager, issuerDN, certificateSN.toString());
      if(result.iterator().hasNext()) {
        retval = result.iterator().next().getCertReqHistory();
      }
      return retval;
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ca.store.CertReqHistory

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.