Package org.jboss.identity.xmlsec.w3.xmldsig

Examples of org.jboss.identity.xmlsec.w3.xmldsig.KeyInfoType


           clazz = tcl.loadClass(keyManagerClassName);
           this.keyManager = (TrustKeyManager) clazz.newInstance();
           keyManager.setAuthProperties(keyProvider.getAuth());
          
           Certificate cert = keyManager.getCertificate(signingAlias);
           KeyInfoType keyInfo = KeyUtil.getKeyInfo(cert);
          
           //TODO: Assume just signing key for now
           KeyDescriptorType keyDescriptor = KeyDescriptorMetaDataBuilder.createKeyDescriptor(keyInfo,
                 null, 0, true, false);
          
View Full Code Here


    * Create a KeyInfoType
    * @return
    */
   public static KeyInfoType createKeyInfo(String id)
   {
      KeyInfoType keyInfo = oFact.createKeyInfoType();
   
      keyInfo.setId(id);
      return keyInfo;
   }
View Full Code Here

         clazz = tcl.loadClass(keyManagerClassName);
         this.keyManager = (TrustKeyManager) clazz.newInstance();
         keyManager.setAuthProperties(keyProvider.getAuth());

         Certificate cert = keyManager.getCertificate(signingAlias);
         KeyInfoType keyInfo = KeyUtil.getKeyInfo(cert);

         //TODO: Assume just signing key for now
         KeyDescriptorType keyDescriptor = KeyDescriptorMetaDataBuilder.createKeyDescriptor(keyInfo,
               null, 0, true, false);
View Full Code Here

    * @throws WSTrustException if an error occurs while creating the {@code KeyInfoType} object.
    */
   public static KeyInfoType createKeyInfo(byte[] secret, PublicKey encryptionKey, URI keyWrapAlgo)
         throws WSTrustException
   {
      KeyInfoType keyInfo = null;

      // if a public key has been specified, encrypt the secret using the public key.
      if (encryptionKey != null)
      {
         try
         {
            Document document = DocumentUtil.createDocument();
            // TODO: XMLEncryptionUtil should allow for the specification of the key wrap algorithm.
            EncryptedKey key = XMLEncryptionUtil.encryptKey(document, new SecretKeySpec(secret, "AES"), encryptionKey,
                  secret.length);
            Element encryptedKeyElement = XMLCipher.getInstance().martial(key);
            keyInfo = new KeyInfoType();
            keyInfo.getContent().add(encryptedKeyElement);
         }
         catch (Exception e)
         {
            throw new WSTrustException("Error creating KeyInfoType", e);
         }
View Full Code Here

    * @return the constructed {@code KeyInfoType} object.
    * @throws WSTrustException if an error occurs while creating the {@code KeyInfoType}.
    */
   public static KeyInfoType createKeyInfo(Certificate certificate) throws WSTrustException
   {
      KeyInfoType keyInfo = null;
      try
      {
         // TODO: check if we need to store the certificate using a base64 format.
         byte[] encodedCert = certificate.getEncoded();

         // first create a X509DataType that contains the encoded certificate.
         org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory factory = new org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory();
         X509DataType dataType = factory.createX509DataType();
         dataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
               factory.createX509DataTypeX509Certificate(encodedCert));

         // set the X509DataType in the KeyInfoType.
         keyInfo = new KeyInfoType();
         keyInfo.getContent().add(factory.createX509Data(dataType));
      }
      catch (Exception e)
      {
         throw new WSTrustException("Error creating KeyInfoType", e);
      }
View Full Code Here

         clazz = tcl.loadClass(keyManagerClassName);
         this.keyManager = (TrustKeyManager) clazz.newInstance();
         keyManager.setAuthProperties(keyProvider.getAuth());

         Certificate cert = keyManager.getCertificate(signingAlias);
         KeyInfoType keyInfo = KeyUtil.getKeyInfo(cert);

         //TODO: Assume just signing key for now
         KeyDescriptorType keyDescriptor = KeyDescriptorMetaDataBuilder.createKeyDescriptor(keyInfo,
               null, 0, true, false);
View Full Code Here

         // TODO: check if we need to store the certificate using a base64 format.
         byte[] encodedCert = certificate.getEncoded();

         // first create a X509DataType that contains the encoded certificate.
         org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory factory = new org.jboss.identity.xmlsec.w3.xmldsig.ObjectFactory();
         X509DataType dataType = factory.createX509DataType();
         dataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
               factory.createX509DataTypeX509Certificate(encodedCert));

         // set the X509DataType in the KeyInfoType.
         keyInfo = new KeyInfoType();
         keyInfo.getContent().add(factory.createX509Data(dataType));
View Full Code Here

     
      KeyDescriptorType keyDescriptor = getObjectFactory().createKeyDescriptorType();
     
      if(algorithm != null && algorithm.length() > 0)
      {
         EncryptionMethodType encryptionMethod = new EncryptionMethodType();
         encryptionMethod.setAlgorithm(algorithm);
        
         encryptionMethod.getContent().add(BigInteger.valueOf(keySize));
        
         keyDescriptor.getEncryptionMethod().add(encryptionMethod)
      }
     
      if(isSigningKey)
View Full Code Here

                                }
                               }
                               value = keyValue;
                           }
                        }
                        KeyInfoType keyInfo = new KeyInfoType();
                        keyInfo.addContent(value);
                        requestContext.setProofTokenInfo(keyInfo);
                    } else if (value instanceof KeyInfoType) {
                        requestContext.setProofTokenInfo((KeyInfoType) value);
                    } else
                        throw new WSTrustException(logger.unsupportedType(value.toString()));
View Full Code Here

     * @param keyWrapAlgo the key wrap algorithm to be used.
     * @return the constructed {@code KeyInfoType} instance.
     * @throws WSTrustException if an error occurs while creating the {@code KeyInfoType} object.
     */
    public static KeyInfoType createKeyInfo(byte[] secret, PublicKey encryptionKey, URI keyWrapAlgo, X509Certificate cer) throws WSTrustException {
        KeyInfoType keyInfo = null;

        // if a public key has been specified, encrypt the secret using the public key.
        if (encryptionKey != null) {
            try {
                Document document = DocumentUtil.createDocument();
                // TODO: XMLEncryptionUtil should allow for the specification of the key wrap algorithm.
                EncryptedKey key = XMLEncryptionUtil.encryptKey(document, new SecretKeySpec(secret, "AES"), encryptionKey,
                        secret.length * 8);
               
                //if certificate is not null provide the information about the key
                if(cer != null && includeKeyInfoInEncryptedKey == true) {
                  KeyInfo kiEnc = new KeyInfo(document);
                  X509Data xData = new X509Data(document);
                  xData.addIssuerSerial(cer.getIssuerDN().getName(), cer.getSerialNumber());
                  kiEnc.add(xData);
                    key.setKeyInfo(kiEnc);
                }
               
                Element encryptedKeyElement = XMLCipher.getInstance().martial(key);
                keyInfo = new KeyInfoType();
                keyInfo.addContent(encryptedKeyElement);
               
               
            } catch (Exception e) {
                throw logger.stsKeyInfoTypeCreationError(e);
            }
View Full Code Here

TOP

Related Classes of org.jboss.identity.xmlsec.w3.xmldsig.KeyInfoType

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.