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

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


      retval.setCreateTime(dateToXMKGregorianCalendar(data.getCreateTime()));
      retval.setEncKeyKeyRecoverable(false);

      Iterator<java.security.cert.Certificate> iter = certificates.iterator();
      while(iter.hasNext()){
        retval.getCertificates().add(new Certificate(iter.next()));
      }
    }catch(DatatypeConfigurationException e){
      log.error("EJBCA WebService error, getHardToken: ",e);
      throw new EjbcaException(ErrorCode.INTERNAL_ERROR, e.getMessage());
    }catch(CertificateEncodingException e){
View Full Code Here


        if (authorized == null) {
          authorized = authorizationSession.isAuthorizedNoLog(admin,AccessRulesConstants.CAPREFIX +caid);
          authorizationCache.put(caid, authorized);
        }
        if (authorized.booleanValue()) {
          retval.add(new Certificate((java.security.cert.Certificate) next));
        }
      } catch (CertificateExpiredException e) {    // Drop invalid cert
      } catch (CertificateNotYetValidException e) {   // Drop invalid cert
      } catch (CertificateEncodingException e) {    // Drop invalid cert
        log.error("A defect certificate was detected.");
View Full Code Here

        if (certs.size() > 0) {
          // The latest certificate will be first
          java.security.cert.Certificate lastcert = certs.iterator().next();
          if (lastcert != null) {
            log.debug("Found certificate for user with subjectDN: "+CertTools.getSubjectDN(lastcert)+" and serialNo: "+CertTools.getSerialNumberAsString(lastcert));
            retval.add(new Certificate(lastcert));
            // If we added a certificate, we will also append the CA certificate chain
            boolean selfSigned = false;
            int bar = 0; // to control so we don't enter an infinite loop. Max chain length is 10
            while ( (!selfSigned) && (bar < 10) ) {
              bar++;
              String issuerDN = CertTools.getIssuerDN(lastcert);
              Collection<java.security.cert.Certificate> cacerts = certificateStoreSession.findCertificatesBySubject(admin, issuerDN);
              if ( (cacerts == null) || (cacerts.size() == 0) ) {            
                log.info("No certificate found for CA with subjectDN: "+issuerDN);
                break;
              }
              Iterator<java.security.cert.Certificate> iter = cacerts.iterator();
              while (iter.hasNext()) {
                java.security.cert.Certificate cert = (java.security.cert.Certificate)iter.next();
                try {
                  lastcert.verify(cert.getPublicKey());
                  // this was the right certificate
                  retval.add(new Certificate(cert));
                  // To determine if we have found the last certificate or not
                  selfSigned = CertTools.isSelfSigned(cert);
                  // Find the next certificate in the chain now
                  lastcert = cert;
                  break; // Break of iteration over this CAs certs
View Full Code Here

      CertificateResponse ret = new CertificateResponse(CertificateHelper.RESPONSETYPE_CERTIFICATE, response);
      byte[] b64cert = ret.getData();
      CVCertificate certObject = CertificateParser.parseCertificate(Base64.decode(b64cert));
      java.security.cert.Certificate iscert = new CardVerifiableCertificate(certObject);
      ArrayList<Certificate> retval = new ArrayList<Certificate>();
      retval.add(new Certificate((java.security.cert.Certificate)iscert));
      // Get the certificate chain
      if (user != null) {
        int caid = user.getCAId();
        caAdminSession.verifyExistenceOfCA(caid);
        Collection<java.security.cert.Certificate> certs = signSession.getCertificateChain(admin, caid);
        Iterator<java.security.cert.Certificate> iter = certs.iterator();
        while (iter.hasNext()) {
          java.security.cert.Certificate cert = iter.next();
          retval.add(new Certificate(cert));
        }
      }
      log.trace("<cvcRequest");
      return retval;
    } catch (EjbcaException e) {
View Full Code Here

          }else{
            cert =  signSession.createCertificate(admin,userData.getUsername(),password, pkcs10req.getRequestPublicKey(), -1, bDate, eDate);
          }
         
          genCertificates.add(cert);
          retval.add(new TokenCertificateResponseWS(new Certificate(cert)));
        }else
          if(next.getType() == HardTokenConstants.REQUESTTYPE_KEYSTORE_REQUEST){

            if(!next.getTokenType().equals(HardTokenConstants.TOKENTYPE_PKCS12)){
              throw EjbcaWSHelper.getEjbcaException("Unsupported Key Store Type : " + next.getTokenType() + " only " + HardTokenConstants.TOKENTYPE_PKCS12 + " is supported",
View Full Code Here

  /**
   * @see org.ejbca.core.protocol.ws.common.IEjbcaWS#getCertificate(String, String)
   */
  public Certificate getCertificate(String certSNinHex, String issuerDN) throws CADoesntExistsException,
    AuthorizationDeniedException, EjbcaException {
    Certificate retval = null;
    EjbcaWSHelper ejbhelper = new EjbcaWSHelper(wsContext, authorizationSession, caAdminSession, certificateProfileSession, certificateStoreSession, endEntityProfileSession, hardTokenSession, userAdminSession);
    Admin admin = ejbhelper.getAdmin(true);
    String bcString = CertTools.stringToBCDNString(issuerDN);
    int caid = bcString.hashCode();
        final IPatternLogger logger = TransactionLogger.getPatternLogger();
        logAdminName(admin,logger);
    try {
      caAdminSession.verifyExistenceOfCA(caid);
      if(!authorizationSession.isAuthorizedNoLog(admin, AccessRulesConstants.REGULAR_VIEWCERTIFICATE)) {
          Authorizer.throwAuthorizationException(admin, AccessRulesConstants.REGULAR_VIEWCERTIFICATE, null);
      }
      if(!authorizationSession.isAuthorizedNoLog(admin, AccessRulesConstants.CAPREFIX + caid)) {
          Authorizer.throwAuthorizationException(admin, AccessRulesConstants.CAPREFIX + caid, null);
      }

      java.security.cert.Certificate cert = certificateStoreSession.findCertificateByIssuerAndSerno(admin, issuerDN, new BigInteger(certSNinHex,16));
      if(cert != null){
        retval = new Certificate(cert);
      }
    } catch (CertificateEncodingException e) {
            throw EjbcaWSHelper.getInternalException(e, logger);
        } catch (RuntimeException e) {  // EJBException, ...
            throw EjbcaWSHelper.getInternalException(e, logger);
View Full Code Here

        return retval;
      }
         Collection<java.security.cert.Certificate> certs = info.getCertificateChain();
      Iterator<java.security.cert.Certificate> iter = certs.iterator();
      while (iter.hasNext()){
        retval.add(new Certificate (iter.next ()));
      }
    } catch (CertificateEncodingException e) {
            throw EjbcaWSHelper.getInternalException(e, logger);
        } catch (RuntimeException e) {  // EJBException, ...
            throw EjbcaWSHelper.getInternalException(e, logger);
View Full Code Here

TOP

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

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.