Package org.w3._2002._03.xkms_

Examples of org.w3._2002._03.xkms_.RegisterRequestType


 
  /**
   * Returns a reissue response
   */
  public RevokeResultType getResponse(boolean requestVerifies){
    RevokeResultType result = xkmsFactory.createRevokeResultType();   
    super.populateResponse(result, requestVerifies);   
    RevokeRequestType req = (RevokeRequestType) this.req;
   

    if(resultMajor == null){    
      if(!checkValidRespondWithRequest(req.getRespondWith(),true)){
        resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
        resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
      }

      if(resultMajor == null){
        if(resultMajor == null){
          X509Certificate cert = (X509Certificate) getPublicKeyInfo(req, false);
          boolean isCertValid = certIsValid(cert);
          if(isCertValid){           
            UserDataVO userData = findUserData(cert);
            String revocationCodeId = getRevocationCodeFromUserData(userData);
            if(userData != null && revocationCodeId != null){
              String revokeCode = getRevocationCode(req);
              if(XKMSConfig.isRevocationAllowed()){
                if(revokeCode != null ){
                X509Certificate newCert = revoke(revokeCode, revocationCodeId, cert);
                if(newCert != null && req.getRespondWith().size() > 0){
                  KeyBindingAbstractType keyBinding = getResponseValues(req.getRevokeKeyBinding(), newCert, true, false);
                  result.getKeyBinding().add((KeyBindingType) keyBinding);
                }
                }
              }else{
                resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
                resultMinor = XKMSConstants.RESULTMINOR_REFUSED;               
View Full Code Here


        revokeRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CERT);

        byte[] first = XKMSUtil.getSecretKeyFromPassphrase("UsersRevokationCodeId1234", true, 20, XKMSUtil.KEY_REVOCATIONCODEIDENTIFIER_PASS1).getEncoded();
        revokeRequestType.setRevocationCode(first);

        RevokeResultType revokeResultType = xKMSInvoker.revoke(revokeRequestType, null, null, null, keyBindingType.getId());

        assertTrue(revokeResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SENDER));
        assertTrue(revokeResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_REFUSED));
    }
View Full Code Here

                keyBindingType.setKeyInfo(keyInfoType);
                keyBindingType.setId("424242");
                revokeRequestType.setRevokeKeyBinding(keyBindingType);
                first = XKMSUtil.getSecretKeyFromPassphrase("foo123", true, 20, XKMSUtil.KEY_REVOCATIONCODEIDENTIFIER_PASS1).getEncoded();
                revokeRequestType.setRevocationCode(first);
                RevokeResultType revokeResultType = xKMSInvoker.revoke(revokeRequestType, null, null, null, keyBindingType.getId());
                assertTrue(ERRORNOTSENTFORAPPROVAL, revokeResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_SUCCESS));
                assertTrue(ERRORNOTSENTFORAPPROVAL, revokeResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_INCOMPLETE));
                // Try to revoke via XKMS and verify failure
                revokeRequestType = xKMSObjectFactory.createRevokeRequestType();
                revokeRequestType.setId("810");
                x509DataType = sigFactory.createX509DataType();
                x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert.getEncoded()));
                keyInfoType = sigFactory.createKeyInfoType();
                keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
                keyBindingType = xKMSObjectFactory.createKeyBindingType();
                keyBindingType.setKeyInfo(keyInfoType);
                keyBindingType.setId("424242");
                revokeRequestType.setRevokeKeyBinding(keyBindingType);
                first = XKMSUtil.getSecretKeyFromPassphrase("foo123", true, 20, XKMSUtil.KEY_REVOCATIONCODEIDENTIFIER_PASS1).getEncoded();
                revokeRequestType.setRevocationCode(first);
                revokeResultType = xKMSInvoker.revoke(revokeRequestType, null, null, null, keyBindingType.getId());
                assertTrue(ERRORNOTSENTFORAPPROVAL, revokeResultType.getResultMajor().equals(XKMSConstants.RESULTMAJOR_RECIEVER));
                assertTrue(ERRORNOTSENTFORAPPROVAL, revokeResultType.getResultMinor().equals(XKMSConstants.RESULTMINOR_REFUSED));
                // Approve revocation and verify success
                approveRevocation(administrator, approvingAdmin, username, RevokedCertInfo.REVOCATION_REASON_UNSPECIFIED,
                        ApprovalDataVO.APPROVALTYPE_REVOKECERTIFICATE, certificateStoreSession, approvalSession, caID);
                // Try to reactivate user
            } finally {
View Full Code Here

       

    } // storeKeyStore
 
  protected void displayStatus(KeyBindingType type) {
    StatusType status = type.getStatus();
    getPrintStream().println("  The certificate had the following status");
    getPrintStream().println("  Valid:");
    displayStatusReasons(status.getValidReason());
    getPrintStream().println("  Indeterminable:");
    displayStatusReasons(status.getIndeterminateReason());
    getPrintStream().println("  Invalid:");
    displayStatusReasons(status.getInvalidReason());
   
  }
View Full Code Here

     *
     * @param kRSSCall, regenerated certificate return all valid
     * @param cert
     */
    private StatusType getStatus(X509Certificate cert, boolean kRSSCall) {
        StatusType retval = xkmsFactory.createStatusType();
       
        if(kRSSCall){
          retval.setStatusValue(XKMSConstants.STATUSVALUE_VALID);
          retval.getValidReason().add(XKMSConstants.STATUSREASON_VALIDITYINTERVAL);
          retval.getValidReason().add(XKMSConstants.STATUSREASON_ISSUERTRUST);
          retval.getValidReason().add(XKMSConstants.STATUSREASON_SIGNATURE);
          retval.getValidReason().add(XKMSConstants.STATUSREASON_REVOCATIONSTATUS);
        }else{
          boolean allValid = true;
          boolean inValidSet = false;

          //Check validity
          try{
            cert.checkValidity( new Date());
            retval.getValidReason().add(XKMSConstants.STATUSREASON_VALIDITYINTERVAL);
          }catch(Exception e){
            retval.getInvalidReason().add(XKMSConstants.STATUSREASON_VALIDITYINTERVAL);
            allValid = false;
            inValidSet = true;
          }

          // 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;
                }
              }catch(Exception e){
                retval.getInvalidReason().add(XKMSConstants.STATUSREASON_SIGNATURE);
                allValid = false
                inValidSet = true;
              }
            }else{
              retval.getInvalidReason().add(XKMSConstants.STATUSREASON_ISSUERTRUST);
              retval.getIndeterminateReason().add(XKMSConstants.STATUSREASON_SIGNATURE);
              allValid = false;
              inValidSet = true;
            }

            // Check RevocationReason
            CertificateStatus status = certificateStoreSession.getStatus(CertTools.getIssuerDN(cert), CertTools.getSerialNumber(cert));
            if(status != CertificateStatus.NOT_AVAILABLE){
              if(status.revocationReason == RevokedCertInfo.NOT_REVOKED){
                retval.getValidReason().add(XKMSConstants.STATUSREASON_REVOCATIONSTATUS);         
              }else{
                retval.getInvalidReason().add(XKMSConstants.STATUSREASON_REVOCATIONSTATUS);
                allValid = false;
                inValidSet = true;
              }             
            }else{
              retval.getIndeterminateReason().add(XKMSConstants.STATUSREASON_REVOCATIONSTATUS);
              allValid = false;
            }

          } catch (ClassCastException e) {
            log.error(intres.getLocalizedMessage("xkms.errorcreatesession"),e);
            resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
            resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
          }
          if(allValid){
            retval.setStatusValue(XKMSConstants.STATUSVALUE_VALID);
          }else{
            if(inValidSet){
              retval.setStatusValue(XKMSConstants.STATUSVALUE_INVALID);
            }else{
              retval.setStatusValue(XKMSConstants.STATUSVALUE_INDETERMINATE);
            }
          }
        }
    return retval;
  }
View Full Code Here

            if(keyBindings.size() > 0){
              getPrintStream().println("\n  The query matched " + keyBindings.size() + " certificates :");
              Iterator iter = keyBindings.iterator();
              while(iter.hasNext()){
                UnverifiedKeyBindingType next = (UnverifiedKeyBindingType) iter.next();
                displayAndOutputCert(next, outputPath, pEMEncoding);               
                if(next instanceof KeyBindingType){
                  displayStatus((KeyBindingType) next);
                }                               
                getPrintStream().println("\n\n\n");
View Full Code Here

    * in the request
    *
    * @param certificate to respond
    */
   protected KeyBindingAbstractType getResponseValues(KeyBindingAbstractType queryKeyBindingType, X509Certificate cert, boolean validateOrRevokeReq, boolean kRSSCall){
     UnverifiedKeyBindingType retval = xkmsFactory.createUnverifiedKeyBindingType();     
     if(validateOrRevokeReq || kRSSCall){
       retval = xkmsFactory.createKeyBindingType();
      
       ((KeyBindingType) retval).setStatus(getStatus(cert,  kRSSCall));
     }
          

     retval.setId("_" + cert.getSerialNumber().toString(16));            
     retval.setValidityInterval(getValidityInterval(cert));

     KeyInfoType keyInfoType = sigFactory.createKeyInfoType();

     if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_KEYNAME)){
       String keyName = cert.getSubjectDN().toString();
       keyInfoType.getContent().add(sigFactory.createKeyName(keyName));                         
     }

     if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_KEYVALUE)){
       if(cert.getPublicKey() instanceof RSAPublicKey){ 
         RSAPublicKey pubKey = (RSAPublicKey) cert.getPublicKey();       
         RSAKeyValueType rSAKeyValueType = sigFactory.createRSAKeyValueType();
         rSAKeyValueType.setModulus(pubKey.getModulus().toByteArray());
         rSAKeyValueType.setExponent(pubKey.getPublicExponent().toByteArray());
         KeyValueType keyValue = sigFactory.createKeyValueType();
         keyValue.getContent().add(sigFactory.createRSAKeyValue(rSAKeyValueType));
         keyInfoType.getContent().add(sigFactory.createKeyValue(keyValue));                         
       }else{
         log.error(intres.getLocalizedMessage("xkms.onlyrsakeysupported"));        
         resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
         resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
       }
     }

     if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CERT) ||
         req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CHAIN) ||
         req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CRL)){
           X509DataType x509DataType = sigFactory.createX509DataType();
       if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CERT) && !req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CHAIN)){
         try {             
           x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert.getEncoded()));
         } catch (CertificateEncodingException e) {
           log.error(intres.getLocalizedMessage("xkms.errordecodingcert"),e);          
           resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
           resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
         }
       }
       if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CHAIN)){
         int caid = CertTools.getIssuerDN(cert).hashCode();
         try {
           Iterator<Certificate> iter = caAdminSession.getCAInfo(pubAdmin, caid).getCertificateChain().iterator();
           while(iter.hasNext()){
             X509Certificate next = (X509Certificate) iter.next();
             x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(next.getEncoded()));
           }
           x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(cert.getEncoded()));
         } catch (Exception e) {
           log.error(intres.getLocalizedMessage("xkms.errorfetchinglastcrl"),e);          
           resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
           resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
         }
       }
       if(req.getRespondWith().contains(XKMSConstants.RESPONDWITH_X509CRL)){
         byte[] crl = null;
         try {
           crl = createCrlSession.getLastCRL(pubAdmin, CertTools.getIssuerDN(cert), false);
         } catch (Exception e) {
           log.error(intres.getLocalizedMessage("xkms.errorfetchinglastcrl"),e);
           resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
           resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
         }
         x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509CRL(crl));
       }       
       keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
      
     }
     retval.setKeyInfo(keyInfoType);
     retval.getKeyUsage().addAll(getCertKeyUsageSpec(cert));
    try {
      retval.getUseKeyWith().addAll(genUseKeyWithAttributes(cert, queryKeyBindingType.getUseKeyWith()));
    } catch (Exception e) {
      log.error(intres.getLocalizedMessage("xkms.errorextractingusekeyattr"),e);     
      resultMajor = XKMSConstants.RESULTMAJOR_RECIEVER;
      resultMinor = XKMSConstants.RESULTMINOR_FAILURE;
     
View Full Code Here

                x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(queryCert));
                KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
                keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
                queryKeyBindingType.setKeyInfo(keyInfoType);
            }else{
              UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
              useKeyWithType.setApplication(queryType);
              useKeyWithType.setIdentifier(queryVal);
              queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
            }
            if(keyUsage != null){
              queryKeyBindingType.getKeyUsage().add(keyUsage);
            }
View Full Code Here

            }
           
            String keyBindingId = genId();           
            PrototypeKeyBindingType prototypeKeyBinding = xKMSObjectFactory.createPrototypeKeyBindingType();
            prototypeKeyBinding.setId(keyBindingId);
            UseKeyWithType useKeyWithType = xKMSObjectFactory.createUseKeyWithType();
            useKeyWithType.setApplication(XKMSConstants.USEKEYWITH_PKIX);
            useKeyWithType.setIdentifier(subjectDN);           
            prototypeKeyBinding.getUseKeyWith().add(useKeyWithType);
           
            if(revocationCodeId != null && !revocationCodeId.equalsIgnoreCase("NULL")){
                byte[] first = XKMSUtil.getSecretKeyFromPassphrase(revocationCodeId, true,20, XKMSUtil.KEY_REVOCATIONCODEIDENTIFIER_PASS1).getEncoded();
                byte[] second = XKMSUtil.getSecretKeyFromPassphrase(new String(first,"ISO8859-1"), false,20, XKMSUtil.KEY_REVOCATIONCODEIDENTIFIER_PASS2).getEncoded();
View Full Code Here

  protected void displayUseKeyWith(UnverifiedKeyBindingType next) {
    Iterator<UseKeyWithType> iter = next.getUseKeyWith().iterator();
    if(next.getKeyUsage().size() != 0){
      getPrintStream().println("  Certificate can be used with applications:");
      while(iter.hasNext()){
        UseKeyWithType useKeyWith = iter.next();
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_IPSEC)){
          getPrintStream().println("    " + QUERYTYPE_IPSEC + " = " + useKeyWith.getIdentifier());       
        }
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_PKIX)){
          getPrintStream().println("    " + QUERYTYPE_PKIX + " = " + useKeyWith.getIdentifier());       
        }
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_SMIME)){
          getPrintStream().println("    " + QUERYTYPE_SMIME + " = " + useKeyWith.getIdentifier());       
        }
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_TLS)){
          getPrintStream().println("    " + QUERYTYPE_TLS + " = " + useKeyWith.getIdentifier());       
        }
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_TLSHTTP)){
          getPrintStream().println("    " + QUERYTYPE_TLSHTTP + " = " + useKeyWith.getIdentifier());       
        }
        if(useKeyWith.getApplication().equals(XKMSConstants.USEKEYWITH_TLSSMTP)){
          getPrintStream().println("    " + QUERYTYPE_TLSSMTP + " = " + useKeyWith.getIdentifier());       
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.w3._2002._03.xkms_.RegisterRequestType

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.