Package org.apache.ws.security.processor

Examples of org.apache.ws.security.processor.EncryptedKeyProcessor


    Element kiElem = (Element) encryptedToken.getElementsByTagNameNS(WSConstants.SIG_NS,
        "KeyInfo").item(0);
    Element encrKeyElem = (Element) kiElem.getElementsByTagNameNS(WSConstants.ENC_NS,
        EncryptionConstants._TAG_ENCRYPTEDKEY).item(0);

    EncryptedKeyProcessor encrKeyProcessor = new EncryptedKeyProcessor();
    encrKeyProcessor.handleEncryptedKey(encrKeyElem, key);

    SecretKey secretKey = WSSecurityUtil.prepareSecretKey(
        EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128, encrKeyProcessor
            .getDecryptedBytes());

    XMLCipher cipher = XMLCipher.getInstance();
    cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
View Full Code Here


    Element kiElem = (Element) encryptedToken.getElementsByTagNameNS(WSConstants.SIG_NS,
        "KeyInfo").item(0);
    Element encrKeyElem = (Element) kiElem.getElementsByTagNameNS(WSConstants.ENC_NS,
        EncryptionConstants._TAG_ENCRYPTEDKEY).item(0);

    EncryptedKeyProcessor encrKeyProcessor = new EncryptedKeyProcessor();
    encrKeyProcessor.handleEncryptedKey(encrKeyElem, key);

    SecretKey secretKey = WSSecurityUtil.prepareSecretKey(
        EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128, encrKeyProcessor
            .getDecryptedBytes());

    XMLCipher cipher = XMLCipher.getInstance();
    cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
View Full Code Here

            Element kiElem = (Element) encryptedToken.getElementsByTagNameNS(WSConstants.SIG_NS,
                    "KeyInfo").item(0);
            Element encrKeyElem = (Element) kiElem.getElementsByTagNameNS(WSConstants.ENC_NS,
                    EncryptionConstants._TAG_ENCRYPTEDKEY).item(0);

            EncryptedKeyProcessor encrKeyProcessor = new EncryptedKeyProcessor();
            encrKeyProcessor.handleEncryptedKey(encrKeyElem, key);

            SecretKey secretKey = WSSecurityUtil.prepareSecretKey(
                    EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128, encrKeyProcessor
                            .getDecryptedBytes());

            XMLCipher cipher = XMLCipher.getInstance();
            cipher.init(XMLCipher.DECRYPT_MODE, secretKey);
View Full Code Here

                            continue;
                        }
                        QName el = new QName(child.getNamespaceURI(), child.getLocalName());
                        if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)) {

                            EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
                            proc.handleEncryptedKey((Element) child, cb, crypto, null);

                            return new SAML2KeyInfo(assertion, proc.getDecryptedBytes());
                        } else if (el.equals(new QName(WSConstants.WST_NS, "BinarySecret"))) {
                            Text txt = (Text) child.getFirstChild();
                            return new SAML2KeyInfo(assertion, Base64.decode(txt.getData()));
                        }
                    }
View Full Code Here

                            continue;
                        }
                        QName el = new QName(child.getNamespaceURI(), child.getLocalName());
                        if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)) {
                           
                            EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
                            proc.handleEncryptedKey((Element)child, cb, crypto, null);
                           
                            return new SAMLKeyInfo(assertion, proc.getDecryptedBytes());
                        } else if (el.equals(new QName(WSConstants.WST_NS, "BinarySecret"))) {
                            Text txt = (Text)child.getFirstChild();
                            return new SAMLKeyInfo(assertion, Base64.decode(txt.getData()));
                        }
                    }
View Full Code Here

            OMElement elem = rpt.getFirstElement();

            if (WSConstants.ENC_KEY_LN.equals(elem.getLocalName())
                && WSConstants.ENC_NS.equals(elem.getNamespace().getNamespaceURI())) {
                // Handle the xenc:EncryptedKey case
                EncryptedKeyProcessor processor = new EncryptedKeyProcessor();
                processor.handleToken((Element) elem, null, Util
                        .getCryptoInstace(config),
                                      getCallbackHandlerInstance(config), null, new Vector(),
                                      null);
                secret = processor.getDecryptedBytes();
            } else if (RahasConstants.LocalNames.BINARY_SECRET.equals(elem.getLocalName()) &&
                       RahasConstants.WST_NS_05_02.equals(elem.getNamespace().getNamespaceURI()))
            {
                // Handle the wst:BinarySecret case
                secret = Base64.decode(elem.getText());
View Full Code Here

                // First check for the binary secret
                String b64Secret = DOMUtils.getContent(child);
                secret = Base64.decode(b64Secret);
            } else if (childQname.equals(new QName(namespace, WSConstants.ENC_KEY_LN))) {
                try {
                    EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
                    WSDocInfo docInfo = new WSDocInfo(child.getOwnerDocument());
                    RequestData data = new RequestData();
                    data.setDecCrypto(createCrypto(true));
                    data.setCallbackHandler(createHandler());
                    List<WSSecurityEngineResult> result =
                        proc.handleToken(child, data, docInfo);
                    secret =
                        (byte[])result.get(0).get(
                            WSSecurityEngineResult.TAG_SECRET
                        );
                } catch (IOException e) {
View Full Code Here

                throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "noCipher");
            }
            return cipherValue;
        } else {
            try {
                EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
                WSDocInfo docInfo = new WSDocInfo(child.getOwnerDocument());
                RequestData data = new RequestData();
                data.setWssConfig(WSSConfig.getNewInstance());
                data.setDecCrypto(createCrypto(true));
                data.setCallbackHandler(createHandler());
                List<WSSecurityEngineResult> result =
                    proc.handleToken(child, data, docInfo);
                return
                    (byte[])result.get(0).get(
                        WSSecurityEngineResult.TAG_SECRET
                    );
            } catch (IOException e) {
View Full Code Here

                String b64Secret = DOMUtils.getContent(child);
                secret = Base64.decode(b64Secret);
            } else if (childQname.equals(new QName(namespace, WSConstants.ENC_KEY_LN))) {
                try {

                    EncryptedKeyProcessor processor = new EncryptedKeyProcessor();

                    processor.handleToken(child, null, createCrypto(true), createHandler(), null,
                                          new Vector(), null);

                    secret = processor.getDecryptedBytes();
                } catch (IOException e) {
                    throw new TrustException("ENCRYPTED_KEY_ERROR", LOG, e);
                }
            } else if (childQname.equals(new QName(namespace, "ComputedKey"))) {
                // Handle the computed key
View Full Code Here

        return token;
    }
   
    private byte[] decryptKey(Element child) throws TrustException, WSSecurityException {
        try {
            EncryptedKeyProcessor processor = new EncryptedKeyProcessor();

            processor.handleToken(child, null, createCrypto(true), createHandler(), null,
                                  new Vector(), null);

            return processor.getDecryptedBytes();
        } catch (IOException e) {
            throw new TrustException("ENCRYPTED_KEY_ERROR", LOG, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.security.processor.EncryptedKeyProcessor

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.