Package org.apache.xml.security.keys.keyresolver

Examples of org.apache.xml.security.keys.keyresolver.KeyResolverSpi


        PublicKey publicKey = cert.getPublicKey();
        PrivateKey privateKey = (PrivateKey) ks.getKey("rsakey", pwd);
        SecretKey secretKey = (SecretKey) ks.getKey("des3key", pwd);

        StorageResolver storage = new StorageResolver(new KeyStoreResolver(ks));
        KeyResolverSpi privateKeyResolver = new PrivateKeyResolver(ks, pwd);
        KeyResolverSpi secretKeyResolver = new SecretKeyResolver(ks, pwd);

        DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
        Document doc = db.newDocument();

        KeyInfo ki;
View Full Code Here


       
        decryptDocument(document, new MyPrivateKeyResolver());

        // Now test with a static KeyResolver
        KeyResolver.registerAtStart(MyPrivateKeyResolver.class.getName(), false);
        KeyResolverSpi resolver = (KeyResolverSpi)KeyResolver.iterator().next();
        assertEquals(MyPrivateKeyResolver.class.getName(), resolver.getClass().getName());

        decryptDocument(document, null);
    }
View Full Code Here

     * @throws KeyResolverException
     */
    PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
        while (it.hasNext()) {
            KeyResolverSpi keyResolver = it.next();
            keyResolver.setSecureValidation(secureValidation);
            Node currentChild = this.constructionElement.getFirstChild();
            String uri = this.getBaseURI();
            while (currentChild != null) {      
                if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                    for (StorageResolver storage : storageResolvers) {
                        PublicKey pk =
                            keyResolver.engineLookupAndResolvePublicKey(
                                (Element) currentChild, uri, storage
                            );

                        if (pk != null) {
                            return pk;
View Full Code Here

            );
        }
        String uri = this.getBaseURI();
        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
        while (it.hasNext()) {
            KeyResolverSpi keyResolver = it.next();
            keyResolver.setSecureValidation(secureValidation);
            X509Certificate cert = applyCurrentResolver(uri, keyResolver);
            if (cert != null) {
                return cert;
            }
        }
View Full Code Here

     * @throws KeyResolverException
     */
    SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
        while (it.hasNext()) {
            KeyResolverSpi keyResolver = it.next();
            keyResolver.setSecureValidation(secureValidation);

            Node currentChild = this.constructionElement.getFirstChild();
            String uri = this.getBaseURI();
            while (currentChild != null)      {   
                if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                    for (StorageResolver storage : storageResolvers) {
                        SecretKey sk =
                            keyResolver.engineLookupAndResolveSecretKey(
                                (Element) currentChild, uri, storage
                            );

                        if (sk != null) {
                            return sk;
View Full Code Here

     * @throws KeyResolverException
     */
    PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
        while (it.hasNext()) {
            KeyResolverSpi keyResolver = it.next();
            keyResolver.setSecureValidation(secureValidation);

            Node currentChild = this.constructionElement.getFirstChild();
            String uri = this.getBaseURI();
            while (currentChild != null)      {   
                if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                    // not using StorageResolvers at the moment
                    // since they cannot return private keys
                    StorageResolver storage = null;
                    PrivateKey pk =
                        keyResolver.engineLookupAndResolvePrivateKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
View Full Code Here

        // Register a KeyResolver for the PrivateKey
        MyPrivateKeyResolver.pk = privKey;
        MyPrivateKeyResolver.pkName = keyName;
        KeyResolver.registerAtStart(MyPrivateKeyResolver.class.getName(), false);
        KeyResolverSpi resolver = (KeyResolverSpi)KeyResolver.iterator().next();
        assertEquals(MyPrivateKeyResolver.class.getName(), resolver.getClass().getName());

        // Decrypt the data by resolving the private key used as the KEK
        XMLCipher decryptCipher = XMLCipher.getInstance();
        decryptCipher.init(XMLCipher.DECRYPT_MODE, null);
        decryptCipher.doFinal(document, encryptedDataElement);
View Full Code Here

   PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    int length=KeyResolver.length();
    int storageLength=this._storageResolvers.size();
    Iterator it= KeyResolver.iterator();
      for (int i = 0; i < length; i++) {
         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
         Node currentChild=this._constructionElement.getFirstChild();
         String uri= this.getBaseURI();
         while (currentChild!=null)      {      
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {             
                  for (int k = 0; k < storageLength; k++) {
                     StorageResolver storage =
                        (StorageResolver) this._storageResolvers.get(k);

                     PublicKey pk =
                           keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
                                                       uri,
                                                        storage);

                     if (pk != null) {
                       KeyResolver.hit(it);
View Full Code Here

    */
   PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
    int length=lengthInternalKeyResolver();
    int storageLength=this._storageResolvers.size();
      for (int i = 0; i < length; i++) {
         KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
         if (log.isDebugEnabled())
           log.debug("Try " + keyResolver.getClass().getName());

         Node currentChild=this._constructionElement.getFirstChild();
         String uri=this.getBaseURI();
         while (currentChild!=null)      {   
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {              
               for (int k = 0; k < storageLength; k++) {
                   StorageResolver storage =
                      (StorageResolver) this._storageResolvers.get(k);
                   PublicKey pk = keyResolver
                           .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);

                     if (pk != null) {
                         return pk;
                     }                    
View Full Code Here

      String uri=this.getBaseURI();
      int length= KeyResolver.length();
      int storageLength=this._storageResolvers.size();  
      Iterator it = KeyResolver.iterator();
      for (int i = 0; i <length; i++) {
         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
         X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
         if (cert!=null) {
           KeyResolver.hit(it);
           return cert;
         }
View Full Code Here

TOP

Related Classes of org.apache.xml.security.keys.keyresolver.KeyResolverSpi

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.