Package org.w3._2000._09.xmldsig_

Examples of org.w3._2000._09.xmldsig_.RSAKeyValueType


                SignedInfo modelSignedInfo = modelSig.getSignedInfo();
                SignedInfoType apiSignedInfoType = new SignedInfoType();
                apiSignature.setSignedInfo(apiSignedInfoType);
                // Canonicalization method
                CanonicalizationMethod modelCanonMethod = modelSignedInfo.getCanonicalizationMethod();
                CanonicalizationMethodType apiCanonMethod = new CanonicalizationMethodType();
                apiCanonMethod.setAlgorithm(modelCanonMethod.getAlgorithm());
                apiSignedInfoType.setCanonicalizationMethod(apiCanonMethod);
               
                // Signature Method
                String sigAlg = modelSignedInfo.getSignatureMethod().getAlgorithm();
                SignatureMethodType apiSigMethod = new SignatureMethodType();
View Full Code Here


                        KeyValueType keyValueType = new KeyValueType();
                        for (KeyDataValue keyValueDataKDV : modelKeyDataValue.getKeyDataValueList()) {
                            for (KeyDataValue keyValueDataChildKDV : keyValueDataKDV.getKeyDataValueList()) {
                                String keyDataDataType = keyValueDataChildKDV.getKeyDataType();
                                if (keyDataDataType.equals("DSAKeyValueType")) {
                                    DSAKeyValueType dsaKeyValueType = new DSAKeyValueType();
                                    for (KeyDataValue dsaKDV : keyValueDataChildKDV.getKeyDataValueList()) {
                                        if ("G".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setG(dsaKDV.getKeyDataValueBytes());
                                        } else if ("P".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setP(dsaKDV.getKeyDataValueBytes());
                                        } else if ("Q".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setQ(dsaKDV.getKeyDataValueBytes());
                                        } else if ("Y".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setY(dsaKDV.getKeyDataValueBytes());
                                        } else if ("J".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setJ(dsaKDV.getKeyDataValueBytes());
                                        } else if ("Seed".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setSeed(dsaKDV.getKeyDataValueBytes());
                                        } else if ("PgenCounter".equals(dsaKDV.getKeyDataName())) {
                                            dsaKeyValueType.setPgenCounter(dsaKDV.getKeyDataValueBytes());
                                        } else {
                                            throw new RuntimeException("Unrecognized dsa type: " + dsaKDV.getKeyDataName());
                                        }
                                    }
                                    JAXBElement jaxb = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", keyValueDataChildKDV.getKeyDataName()), DSAKeyValueType.class, dsaKeyValueType);
View Full Code Here

                childKDV.setKeyDataName(kvJAXB.getName().getLocalPart());
                childKDV.setKeyDataType(childVal.getClass().getSimpleName());
                modelKeyValueKDV.getKeyDataValueList().add(childKDV);

                if (childVal instanceof DSAKeyValueType) {
                    DSAKeyValueType dsaKeyVal = (DSAKeyValueType)childVal;
                    String dsaKeyValueTagName = kvJAXB.getName().getLocalPart();
                    KeyDataValue dsaKeyValKDV = new KeyDataValue(null, DSAKeyValueType.class.getSimpleName(), dsaKeyValueTagName, null, null, childKDV);
                    childKDV.getKeyDataValueList().add(dsaKeyValKDV);

                    KeyDataValue gValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "G", dsaKeyVal.getG(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(gValKDV);

                    KeyDataValue jValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "J", dsaKeyVal.getJ(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(jValKDV);

                    KeyDataValue pValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "P", dsaKeyVal.getP(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(pValKDV);

                    KeyDataValue pGenCounterValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "PgenCounter", dsaKeyVal.getPgenCounter(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(pGenCounterValKDV);

                    KeyDataValue qValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Q", dsaKeyVal.getQ(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(qValKDV);

                    KeyDataValue seedValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Seed", dsaKeyVal.getSeed(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(seedValKDV);

                    KeyDataValue yValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Y", dsaKeyVal.getY(), null, dsaKeyValKDV);
                    dsaKeyValKDV.getKeyDataValueList().add(yValKDV);
                } else if (childVal instanceof RSAKeyValueType) {
                    RSAKeyValueType rsaKeyVal = (RSAKeyValueType)childVal;
                    String rsaKeyValueTagName = kvJAXB.getName().getLocalPart();
                    KeyDataValue rsaKeyValKDV = new KeyDataValue(null, RSAKeyValueType.class.getSimpleName(), rsaKeyValueTagName, null, null, childKDV);
View Full Code Here

                    }
                   
                    String digestMethodStr = modelRef.getDigestMethod();
                    byte[] digestValBytes = modelRef.getDigestValue();
                   
                    DigestMethodType apiDigestMethod = new DigestMethodType();
                    apiDigestMethod.setAlgorithm(digestMethodStr);
                    apiRef.setDigestMethod(apiDigestMethod);
                    apiRef.setDigestValue(digestValBytes);
                   
                    apiReferenceList.add(apiRef);
                }
View Full Code Here

           
            QueryKeyBindingType queryKeyBindingType = xKMSObjectFactory.createQueryKeyBindingType();
            if(isCertQuery){
              X509DataType x509DataType = sigFactory.createX509DataType();
                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);
View Full Code Here

            reissueRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);
           
            String keyBindingId =  "_" + orgCert.getSerialNumber().toString();
            X509DataType x509DataType = sigFactory.createX509DataType();
            x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(orgCert.getEncoded()));
            KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
            keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
           
            KeyBindingType keyBindingType = xKMSObjectFactory.createKeyBindingType();               
            keyBindingType.setKeyInfo(keyInfoType);
            keyBindingType.setId(keyBindingId);
            reissueRequestType.setReissueKeyBinding(keyBindingType);   
View Full Code Here

            recoverRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);           
            recoverRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PRIVATEKEY);
           
            X509DataType x509DataType = sigFactory.createX509DataType();
            x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(orgCert.getEncoded()));
            KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
            keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
           
            String keyBindingId = "_" + CertTools.getSerialNumber(orgCert).toString();
            KeyBindingType keyBindingType = xKMSObjectFactory.createKeyBindingType();               
            keyBindingType.setKeyInfo(keyInfoType);
            keyBindingType.setId(keyBindingId);
View Full Code Here

            revokeRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_X509CHAIN);           
            revokeRequestType.getRespondWith().add(XKMSConstants.RESPONDWITH_PRIVATEKEY);
           
            X509DataType x509DataType = sigFactory.createX509DataType();
            x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(sigFactory.createX509DataTypeX509Certificate(orgCert.getEncoded()));
            KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
            keyInfoType.getContent().add(sigFactory.createX509Data(x509DataType));
           
            String keyBindingId = "_" + CertTools.getSerialNumber(orgCert).toString();
            KeyBindingType keyBindingType = xKMSObjectFactory.createKeyBindingType();               
            keyBindingType.setKeyInfo(keyInfoType);
            keyBindingType.setId(keyBindingId);
View Full Code Here

           
            RegisterResultType registerResultType = null;
            if(genKeys == null){
              registerResultType = getXKMSInvoker().register(registerRequestType, clientCert, privateKey, password, null, keyBindingId);
            }else{
              KeyInfoType keyInfoType = sigFactory.createKeyInfoType();
                RSAKeyValueType rsaKeyValueType = sigFactory.createRSAKeyValueType();
                rsaKeyValueType.setExponent(((RSAPublicKey) genKeys.getPublic()).getPublicExponent().toByteArray());
                rsaKeyValueType.setModulus(((RSAPublicKey) genKeys.getPublic()).getModulus().toByteArray());
                JAXBElement<RSAKeyValueType> rsaKeyValue = sigFactory.createRSAKeyValue(rsaKeyValueType);
                keyInfoType.getContent().add(rsaKeyValue);
               
                prototypeKeyBinding.setKeyInfo(keyInfoType);
             
              registerResultType = getXKMSInvoker().register(registerRequestType, clientCert, privateKey, password, genKeys.getPrivate(), keyBindingId);             
            }
View Full Code Here

          

     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 {
View Full Code Here

TOP

Related Classes of org.w3._2000._09.xmldsig_.RSAKeyValueType

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.