Package org.apache.ws.security.message

Examples of org.apache.ws.security.message.WSSignEnvelope


                        actionToDo,
                        WSHandlerConstants.PW_CALLBACK_CLASS,
                        WSHandlerConstants.PW_CALLBACK_REF, reqData)
                .getPassword();

        WSSignEnvelope wsSign = new WSSignEnvelope(reqData.getActor(), mu);
        if (reqData.getSigKeyId() != 0) {
            wsSign.setKeyIdentifierType(reqData.getSigKeyId());
        }
        if (reqData.getSigAlgorithm() != null) {
            wsSign.setSignatureAlgorithm(reqData.getSigAlgorithm());
        }

        wsSign.setUserInfo(reqData.getUsername(), password);
        if (reqData.getSignatureParts().size() > 0) {
            wsSign.setParts(reqData.getSignatureParts());
        }

        try {
            wsSign.build(doc, reqData.getSigCrypto());
        } catch (WSSecurityException e) {
            throw new WSSecurityException("WSHandler: Signature: error during message procesing" + e);
        }
    }
View Full Code Here


        builder.setPasswordType(WSConstants.PASSWORD_TEXT);
        builder.preSetUsernameToken(doc, reqData.getUsername(), password);
        builder.addCreated(doc);
        builder.addNonce(doc);

        WSSignEnvelope sign = new WSSignEnvelope(reqData.getActor(), mu);
        if (reqData.getSignatureParts().size() > 0) {
            sign.setParts(reqData.getSignatureParts());
        }
        sign.setUsernameToken(builder);
        sign.setKeyIdentifierType(WSConstants.UT_SIGNING);
        sign.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
        try {
            sign.build(doc, null);
        } catch (WSSecurityException e) {
            throw new WSSecurityException("WSHandler: Error during Signatur with UsernameToken secret"
                    + e);
        }
        builder.build(doc, null, null);
View Full Code Here

        }
        String issuerKeyName = null;
        String issuerKeyPW = null;
        Crypto issuerCrypto = null;

        WSSignEnvelope wsSign = new WSSignEnvelope(reqData.getActor(), mu);
        String password = null;
        if (saml.isSenderVouches()) {
            issuerKeyName = saml.getIssuerKeyName();
            issuerKeyPW = saml.getIssuerKeyPassword();
            issuerCrypto = saml.getIssuerCrypto();
        } else {
            password =
                    getPassword(reqData.getUsername(),
                            actionToDo,
                            WSHandlerConstants.PW_CALLBACK_CLASS,
                            WSHandlerConstants.PW_CALLBACK_REF, reqData)
                    .getPassword();
            wsSign.setUserInfo(reqData.getUsername(), password);
        }
        if (reqData.getSigKeyId() != 0) {
            wsSign.setKeyIdentifierType(reqData.getSigKeyId());
        }
        try {
            wsSign.build(doc,
                    crypto,
                    assertion,
                    issuerCrypto,
                    issuerKeyName,
                    issuerKeyPW);
View Full Code Here

                        actionToDo,
                        WSHandlerConstants.PW_CALLBACK_CLASS,
                        WSHandlerConstants.PW_CALLBACK_REF, reqData)
                .getPassword();

        WSSignEnvelope wsSign = new WSSignEnvelope(reqData.actor, mu);
        if (reqData.sigKeyId != 0) {
            wsSign.setKeyIdentifierType(reqData.sigKeyId);
        }
        if (reqData.sigAlgorithm != null) {
            wsSign.setSignatureAlgorithm(reqData.sigAlgorithm);
        }

        wsSign.setUserInfo(reqData.username, password);
        if (reqData.signatureParts.size() > 0) {
            wsSign.setParts(reqData.signatureParts);
        }

        try {
            wsSign.build(doc, reqData.sigCrypto);
        } catch (WSSecurityException e) {
            throw new AxisFault("WSDoAllSender: Signature: error during message procesing" + e);
        }
    }
View Full Code Here

    builder.setPasswordType(WSConstants.PASSWORD_TEXT);
    builder.preSetUsernameToken(doc, reqData.username, password);
    builder.addCreated(doc);
    builder.addNonce(doc);

    WSSignEnvelope sign = new WSSignEnvelope(reqData.actor, mu);
        if (reqData.signatureParts.size() > 0) {
            sign.setParts(reqData.signatureParts);
        }
    sign.setUsernameToken(builder);
    sign.setKeyIdentifierType(WSConstants.UT_SIGNING);
    sign.setSignatureAlgorithm(XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
    try {
      sign.build(doc, null);
    } catch (WSSecurityException e) {
      throw new AxisFault("WSDoAllSender: Error during Signatur with UsernameToken secret"
          + e);
    }
    builder.build(doc, null, null);
View Full Code Here

        }
        String issuerKeyName = null;
        String issuerKeyPW = null;
        Crypto issuerCrypto = null;

        WSSignEnvelope wsSign = new WSSignEnvelope(reqData.actor, mu);
        String password = null;
        if (saml.isSenderVouches()) {
            issuerKeyName = saml.getIssuerKeyName();
            issuerKeyPW = saml.getIssuerKeyPassword();
            issuerCrypto = saml.getIssuerCrypto();
        } else {
            password =
                    getPassword(reqData.username,
                            actionToDo,
                            WSHandlerConstants.PW_CALLBACK_CLASS,
                            WSHandlerConstants.PW_CALLBACK_REF, reqData)
                    .getPassword();
            wsSign.setUserInfo(reqData.username, password);
        }
        if (reqData.sigKeyId != 0) {
            wsSign.setKeyIdentifierType(reqData.sigKeyId);
        }
        try {
            wsSign.build(doc,
                    crypto,
                    assertion,
                    issuerCrypto,
                    issuerKeyName,
                    issuerKeyPW);
View Full Code Here

     */
    public void testEncryptionSigning() throws Exception {
        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
        SOAPEnvelope envelope = null;
        WSEncryptBody encrypt = new WSEncryptBody();
        WSSignEnvelope sign = new WSSignEnvelope();
        encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
        sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
        log.info("Before Encryption....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document encryptedDoc = encrypt.build(doc, crypto);
        Document encryptedSignedDoc = sign.build(encryptedDoc, crypto);
        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
         * as a document again for further processing.
View Full Code Here

     *
     * @throws java.lang.Exception Thrown when there is any problem in signing or verification
     */
    public void testX509SignatureDirectSTR() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcert", "security");
        // builder.setUserInfo("john", "keypass");
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
        Vector parts = new Vector();
       
        /*
         * Set up to sign body and use STRTransorm to sign
         * the signature token (e.g. X.509 certificate)
         */
        WSEncryptionPart encP =
            new WSEncryptionPart(
                soapConstants.getBodyQName().getLocalPart(),
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);
        encP =
            new WSEncryptionPart(
                "STRTransform",
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);

        builder.setParts(parts);
        builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);

        log.info("Before Signing STR DirectReference....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        /*
         * convert the resulting document into a message first. The toSOAPMessage()
         * mehtod performs the necessary c14n call to properly set up the signed
         * document and convert it into a SOAP message. After that we extract it
View Full Code Here

     */
   

    public void testX509SignatureISSTR() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcert", "security");
        // builder.setUserInfo("john", "keypass");
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
        Vector parts = new Vector();
       
        /*
         * Set up to sign body and use STRTransorm to sign
         * the signature token (e.g. X.509 certificate)
         */
        WSEncryptionPart encP =
            new WSEncryptionPart(
                soapConstants.getBodyQName().getLocalPart(),    // define the body
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);
        encP =
            new WSEncryptionPart(
                "STRTransform",                // reserved word to use STRTransform
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);

        builder.setParts(parts);
        builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);

        log.info("Before Signing STR IS....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
        if (log.isDebugEnabled()) {
            log.debug("Signed message with STR IssuerSerial key identifier:");
            XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
View Full Code Here

     */
   

    public void testX509SignatureSKISTR() throws Exception {
        SOAPEnvelope envelope = null;
        WSSignEnvelope builder = new WSSignEnvelope();
        builder.setUserInfo("wss4jcert", "security");
        // builder.setUserInfo("john", "keypass");
        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
        Vector parts = new Vector();
       
        /*
         * Set up to sign body and use STRTransorm to sign
         * the signature token (e.g. X.509 certificate)
         */
        WSEncryptionPart encP =
            new WSEncryptionPart(
                soapConstants.getBodyQName().getLocalPart(),    // define the body
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);
        encP =
            new WSEncryptionPart(
                "STRTransform",                // reserved word to use STRTransform
                soapConstants.getEnvelopeURI(),
                "Content");
        parts.add(encP);

        builder.setParts(parts);
        builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);

        log.info("Before Signing STR SKI....");
        Document doc = unsignedEnvelope.getAsDocument();
        Document signedDoc = builder.build(doc, crypto);

        Message signedMsg = (Message) AxisUtil.toSOAPMessage(signedDoc);
        if (log.isDebugEnabled()) {
            log.debug("Signed message with STR SKI key identifier:");
            XMLUtils.PrettyElementToWriter(signedMsg.getSOAPEnvelope().getAsDOM(), new PrintWriter(System.out));
View Full Code Here

TOP

Related Classes of org.apache.ws.security.message.WSSignEnvelope

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.