当前位置: 首页>>代码示例>>Java>>正文


Java SOAPEnvelope.getAsDocument方法代码示例

本文整理汇总了Java中org.apache.axis.message.SOAPEnvelope.getAsDocument方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope.getAsDocument方法的具体用法?Java SOAPEnvelope.getAsDocument怎么用?Java SOAPEnvelope.getAsDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis.message.SOAPEnvelope的用法示例。


在下文中一共展示了SOAPEnvelope.getAsDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEmptyPasswordProcessing

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that processes a UserNameToken with an empty password
 */
public void testEmptyPasswordProcessing() throws Exception {
    InputStream in = new ByteArrayInputStream(EMPTY_PASSWORD_MSG.getBytes());
    Message msg = new Message(in);
    msg.setMessageContext(msgContext);
    SOAPEnvelope utEnvelope = msg.getSOAPEnvelope();
    Document doc = utEnvelope.getAsDocument();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Empty password message: ");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
        LOG.debug(outputString);
    }
    
    verify(doc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:19,代码来源:TestWSSecurityNew5.java

示例2: testNoSOAPNamespacePrefix

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test signing a SOAP message that has no SOAP namespace prefix
 */
public void testNoSOAPNamespacePrefix() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    WSSecSignature sign = new WSSecSignature();
    sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);

    Document doc = unsignedEnvelope.getAsDocument();

    WSSecHeader secHeader = new WSSecHeader();
    secHeader.setActor("bob");
    secHeader.insertSecurityHeader(doc);
    Document signedDoc = sign.build(doc, crypto, secHeader);
    
    if (LOG.isDebugEnabled()) {
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
        LOG.debug(outputString);
    }
    verify(signedDoc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:24,代码来源:TestWSSecurityWSS60.java

示例3: testEncryptionDecryptionOAEP

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that encrypt and decrypt a WS-Security envelope.
 * This test uses the RSA OAEP algorithm to transport (wrap) the symmetric
 * key.
 * <p/>
 * 
 * @throws Exception Thrown when there is any problem in signing or verification
 */
 public void testEncryptionDecryptionOAEP() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    WSSecEncrypt builder = new WSSecEncrypt();
    builder.setUserInfo("wss40");
    builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
    builder.setKeyEnc(WSConstants.KEYTRANSPORT_RSAOEP);
    Document doc = unsignedEnvelope.getAsDocument();
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);        
    LOG.info("Before Encryption Triple DES/RSA-OAEP....");
    Document encryptedDoc = builder.build(doc, crypto, secHeader);
    LOG.info("After Encryption Triple DES/RSA-OAEP....");

    String outputString = 
        org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
        LOG.debug(outputString);
    }
    assertTrue(outputString.indexOf("LogTestService2") == -1 ? true : false);
    verify(encryptedDoc, SOAP_BODY);

}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:32,代码来源:TestWSSecurityNew2.java

示例4: testEncryptionSigning

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that encrypts and signs a WS-Security envelope, then performs
 * verification and decryption <p/>
 * 
 * @throws Exception
 *             Thrown when there is any problem in signing, encryption,
 *             decryption, or verification
 */
public void testEncryptionSigning() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    WSSecEncrypt encrypt = new WSSecEncrypt();
    WSSecSignature sign = new WSSecSignature();
    encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
    sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    LOG.info("Before Encryption....");
    Document doc = unsignedEnvelope.getAsDocument();

    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
    Document encryptedSignedDoc = sign.build(encryptedDoc, crypto,
            secHeader);
    LOG.info("After Encryption....");
    verify(encryptedSignedDoc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:27,代码来源:TestWSSecurityNew6.java

示例5: testSignatureEncrypt

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
public void testSignatureEncrypt() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    Document doc = unsignedEnvelope.getAsDocument();
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    //EncryptedKey
    WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
    encrKeyBuilder.setUserInfo("wss40");
    encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
    encrKeyBuilder.prepare(doc, crypto);

    //Key information from the EncryptedKey
    byte[] ek = encrKeyBuilder.getEphemeralKey();
    String tokenIdentifier = encrKeyBuilder.getId();

    //Derived key encryption
    WSSecDKSign sigBuilder = new WSSecDKSign();
    sigBuilder.setExternalKey(ek, tokenIdentifier);
    sigBuilder.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
    LOG.info("Before HMAC-SHA1 signature");
    Document signedDoc = sigBuilder.build(doc, secHeader);

    //Derived key signature
    WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
    encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
    encrBuilder.setExternalKey(ek, tokenIdentifier);
    Document signedEncryptedDoc = encrBuilder.build(signedDoc, secHeader);

    encrKeyBuilder.prependToHeader(secHeader);
    encrKeyBuilder.prependBSTElementToHeader(secHeader);

    if (LOG.isDebugEnabled()) {
        LOG.debug("Encrypted message: 3DES  + DerivedKeys");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedEncryptedDoc);
        LOG.debug(outputString);
    }
    verify(signedEncryptedDoc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:41,代码来源:TestWSSecurityNewDK.java

示例6: testBadLocalname

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test encrypting a custom SOAP header with a bad localname
 */
public void testBadLocalname() throws Exception {
    SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
    WSSecEncrypt encrypt = new WSSecEncrypt();
    encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);

    Document doc = unencryptedEnvelope.getAsDocument();

    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);
    
    Vector parts = new Vector();
    WSEncryptionPart encP =
        new WSEncryptionPart(
            "foobar2",
            "urn:foo.bar",
            "");
    parts.add(encP);
    encrypt.setParts(parts);
    
    try {
        encrypt.build(doc, crypto, secHeader);
        fail("Failure expected on a bad localname");
    } catch (WSSecurityException ex) {
        // expected
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:31,代码来源:TestWSSecurityEncryptionParts.java

示例7: testSAMLUnsignedSenderVouches

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that creates, sends and processes an unsigned SAML assertion.
 */
public void testSAMLUnsignedSenderVouches() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml.properties");

    SAMLAssertion assertion = saml.newAssertion();

    WSSecSAMLToken wsSign = new WSSecSAMLToken();

    Document doc = unsignedEnvelope.getAsDocument();
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);
    LOG.info("Before SAMLUnsignedSenderVouches....");
    
    Document unsignedDoc = wsSign.build(doc, assertion, secHeader);
    LOG.info("After SAMLUnsignedSenderVouches....");

    if (LOG.isDebugEnabled()) {
        LOG.debug("Unsigned SAML message (sender vouches):");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(unsignedDoc);
        LOG.debug(outputString);
    }
    
    Vector results = verify(unsignedDoc);
    WSSecurityEngineResult actionResult =
        WSSecurityUtil.fetchActionResult(results, WSConstants.ST_UNSIGNED);
    SAMLAssertion receivedAssertion = 
        (SAMLAssertion) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
    assertTrue(receivedAssertion != null);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:34,代码来源:TestWSSecurityNewST1.java

示例8: testSCTDKTEncrypt

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test encryption using a derived key which is based on a secret associated
 * with a security context token
 */
public void testSCTDKTEncrypt() {
    try {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);

        WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
        sctBuilder.prepare(doc, crypto);

        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] tempSecret = new byte[16];
        random.nextBytes(tempSecret);

        // Store the secret
        this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

        String tokenId = sctBuilder.getSctId();

        // Derived key encryption
        WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
        encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
        encrBuilder.setExternalKey(tempSecret, tokenId);
        encrBuilder.build(doc, secHeader);

        sctBuilder.prependSCTElementToHeader(doc, secHeader);

        if (LOG.isDebugEnabled()) {
            String outputString = 
                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
            LOG.debug(outputString);
        }

        verify(doc);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:44,代码来源:TestWSSecurityNewSCT.java

示例9: testSCTKDKTSign

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
public void testSCTKDKTSign() {
    try {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        Document doc = unsignedEnvelope.getAsDocument();
        WSSecHeader secHeader = new WSSecHeader();
        secHeader.insertSecurityHeader(doc);

        WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
        sctBuilder.prepare(doc, crypto);

        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] tempSecret = new byte[16];
        random.nextBytes(tempSecret);

        // Store the secret
        this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

        String tokenId = sctBuilder.getSctId();

        // Derived key signature
        WSSecDKSign sigBuilder = new WSSecDKSign();
        sigBuilder.setExternalKey(tempSecret, tokenId);
        sigBuilder.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
        sigBuilder.build(doc, secHeader);
        
        sctBuilder.prependSCTElementToHeader(doc, secHeader);

        if (LOG.isDebugEnabled()) {
            String outputString = 
                org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
            LOG.debug(outputString);
        }

        verify(doc);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:40,代码来源:TestWSSecurityNewSCT.java

示例10: testSigningEncryptionEmbedded

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that encrypts and signs a WS-Security envelope, then performs
 * verification and decryption.
 * <p/>
 * 
 * @throws Exception Thrown when there is any problem in signing, encryption,
 *                   decryption, or verification
 */
public void testSigningEncryptionEmbedded() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    WSSecEncrypt encrypt = new WSSecEncrypt();
    WSSecSignature sign = new WSSecSignature();
    
    encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
    encrypt.setKeyIdentifierType(WSConstants.EMBEDDED_KEYNAME);
    encrypt.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);        
    encrypt.setKey(key);

    sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    LOG.info("Before Encryption....");
    Document doc = unsignedEnvelope.getAsDocument();
    encrypt.setDocument(doc);
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);                
    Document signedDoc = sign.build(doc, crypto, secHeader);
    Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);

    if (LOG.isDebugEnabled()) {
        LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedSignedDoc);
        LOG.debug(outputString);
    }
    LOG.info("After Encryption....");
    verify(encryptedSignedDoc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:37,代码来源:TestWSSecurityNew9.java

示例11: testSignatureSKI

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Here we're signing the SOAP body, where the signature refers to a DerivedKeyToken
 * which uses an SKI reference to the encoded certificate (which is in the
 * keystore)
 */
public void testSignatureSKI() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    Document doc = unsignedEnvelope.getAsDocument();
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    SecurityTokenReference secToken = new SecurityTokenReference(doc);
    X509Certificate[] certs = crypto.getCertificates("wss40");
    secToken.setKeyIdentifierSKI(certs[0], crypto);
    secToken.getElement();
    
    WSSecDKSign sigBuilder = new WSSecDKSign();
    java.security.Key key = crypto.getPrivateKey("wss40", "security");
    sigBuilder.setExternalKey(key.getEncoded(), secToken.getElement());
    sigBuilder.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
    sigBuilder.build(doc, secHeader);
    
    sigBuilder.appendSigToHeader(secHeader);
    
    if (LOG.isDebugEnabled()) {
        LOG.debug("Encrypted message: SKI + DerivedKeys");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
        LOG.debug(outputString);
    }
    
    Vector results = verify(doc);
    
    WSSecurityEngineResult actionResult = 
        WSSecurityUtil.fetchActionResult(results, WSConstants.SIGN);
    assertTrue(actionResult != null);
    assertFalse(actionResult.isEmpty());
    
    assertTrue(actionResult.get(WSSecurityEngineResult.TAG_DECRYPTED_KEY) != null);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:41,代码来源:TestWSSecurityNewDK.java

示例12: testSymmetricSignatureDR

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test signing a message body using a symmetric key with Direct Reference to an
 * EncryptedKey
 */
public void testSymmetricSignatureDR() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    Document doc = unsignedEnvelope.getAsDocument();
    
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);
    
    WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
    encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
    encrKey.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
    encrKey.setKeySize(192);
    encrKey.prepare(doc, crypto);
    
    WSSecSignature sign = new WSSecSignature();
    sign.setKeyIdentifierType(WSConstants.CUSTOM_SYMM_SIGNING);
    sign.setCustomTokenId(encrKey.getId());
    sign.setSecretKey(encrKey.getEphemeralKey());
    sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
    sign.setCustomTokenValueType(
        WSConstants.SOAPMESSAGE_NS11 + "#" + WSConstants.ENC_KEY_VALUE_TYPE
    );

    Document signedDoc = sign.build(doc, crypto, secHeader);
    
    if (LOG.isDebugEnabled()) {
        LOG.debug("Signed symmetric message DR:");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
        LOG.debug(outputString);
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:36,代码来源:TestWSSecurityNew17.java

示例13: testEncryptionDecryptionAES128

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
* Test encryption using a DerivedKeyToken using AES128 
* @throws Exception Thrown when there is any problem in signing or verification
*/
public void testEncryptionDecryptionAES128() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
    Document doc = unsignedEnvelope.getAsDocument();
    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    //EncryptedKey
    WSSecEncryptedKey encrKeyBuilder = new WSSecEncryptedKey();
    encrKeyBuilder.setUserInfo("wss40");
    encrKeyBuilder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
    encrKeyBuilder.prepare(doc, crypto);

    //Key information from the EncryptedKey
    byte[] ek = encrKeyBuilder.getEphemeralKey();
    String tokenIdentifier = encrKeyBuilder.getId();  
    
    //Derived key encryption
    WSSecDKEncrypt encrBuilder = new WSSecDKEncrypt();
    encrBuilder.setSymmetricEncAlgorithm(WSConstants.AES_128);
    encrBuilder.setExternalKey(ek, tokenIdentifier);
    Document encryptedDoc = encrBuilder.build(doc, secHeader);
    
    encrKeyBuilder.prependToHeader(secHeader);
    encrKeyBuilder.prependBSTElementToHeader(secHeader);
    
    if (LOG.isDebugEnabled()) {
        LOG.debug("Encrypted message: 3DES  + DerivedKeys");
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
        LOG.debug(outputString);
    }
   verify(doc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:38,代码来源:TestWSSecurityNewDK.java

示例14: testUsernameTokenNoPasswordType

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that adds a UserNameToken with no password type to a WS-Security envelope
 * See WSS-152 - https://issues.apache.org/jira/browse/WSS-152
 * "Problem with processing Username Tokens with no password type"
 * The 1.1 spec states that the password type is optional and defaults to password text, 
 * and so we should handle an incoming Username Token accordingly.
 */
public void testUsernameTokenNoPasswordType() throws Exception {
    InputStream in = new ByteArrayInputStream(SOAPUTMSG.getBytes());
    Message msg = new Message(in);
    msg.setMessageContext(msgContext);
    SOAPEnvelope utEnvelope = msg.getSOAPEnvelope();
    Document doc = utEnvelope.getAsDocument();
    if (LOG.isDebugEnabled()) {
        String outputString = 
            org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
        LOG.debug(outputString);
    }
    verify(doc);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:21,代码来源:TestWSSecurityNew5.java

示例15: testSAMLSignedKeyHolderSendKeyValue

import org.apache.axis.message.SOAPEnvelope; //导入方法依赖的package包/类
/**
 * Test that creates, sends and processes a signed SAML assertion containing
 * only key material and not an entire X509Certificate.
 */
public void testSAMLSignedKeyHolderSendKeyValue() throws Exception {
    SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();

    Document doc = unsignedEnvelope.getAsDocument();
    
    SAMLIssuer saml = SAMLIssuerFactory.getInstance("saml4sendKeyValue.properties");
    // Provide info to SAML issuer that it can construct a Holder-of-key
    // SAML token.
    saml.setInstanceDoc(doc);
    saml.setUserCrypto(crypto);
    saml.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
    SAMLAssertion assertion = saml.newAssertion();

    WSSecSignatureSAML wsSign = new WSSecSignatureSAML();
    wsSign.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
    wsSign.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
    wsSign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
    wsSign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");

    WSSecHeader secHeader = new WSSecHeader();
    secHeader.insertSecurityHeader(doc);

    LOG.info("Before SAMLSignedKeyHolder....");
    
    //
    // set up for keyHolder
    //
    Document signedDoc = wsSign.build(doc, crypto, assertion, null, null, null, secHeader);
    LOG.info("After SAMLSignedKeyHolder....");

    String outputString = 
        org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Signed SAML message (key holder):");
        LOG.debug(outputString);
    }
    assertTrue(outputString.indexOf("http://www.w3.org/2001/04/xmlenc#sha256") != -1);
    assertTrue(outputString.indexOf("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256") != -1);
    
    Vector results = verify(signedDoc);
    WSSecurityEngineResult actionResult =
        WSSecurityUtil.fetchActionResult(results, WSConstants.ST_UNSIGNED);
    SAMLAssertion receivedAssertion = 
        (SAMLAssertion) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
    assertTrue(receivedAssertion != null);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:51,代码来源:TestWSSecurityNewST3.java


注:本文中的org.apache.axis.message.SOAPEnvelope.getAsDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。