Forum Discussion

CrazyFrog's avatar
CrazyFrog
Contributor
6 years ago

Unable to set the values of a Signature (WS-Security)

I am looking how i can change the values of "Signature" I use the follow code to create an outgoing WSS and add a entry "Signature" But i can't fill in the values that belongs to "Signature"   ...
  • CrazyFrog's avatar
    6 years ago

    I found out howto do it.

     

    I use the following code herefore.

     

    DefaultWssContainer wssContainer = wsdlOperation.getProject().getWssContainer();

    OutgoingWss outgoingWss = wssContainer.addOutgoingWss("Happy-flow");
    outgoingWss.setMustUnderstand(true);
    OutgoingWssConfig outgoingWssConfig = outgoingWss.getConfig();

    WSSEntryConfig wssEntryConfig = outgoingWssConfig.addNewEntry();
    wssEntryConfig.setType("Signature");

    wssEntryConfig.addNewConfiguration();

    //https://github.com/oysteing/soapui/tree/master/src/java/com/eviware/soapui/impl/wsdl/support/wss/entries

    //https://github.com/oysteing/soapui/blob/master/src/java/com/eviware/soapui/impl/wsdl/support/wss/entries/AddSignatureEntry.java
    XmlObjectConfigurationBuilder builder = new XmlObjectConfigurationBuilder();
    builder.add( "crypto", "alice.p12" );
    builder.add( "keyIdentifierType", 0 );
    builder.add( "signatureAlgorithm", XMLSignature.ALGO_ID_MAC_HMAC_SHA384 );
    builder.add( "signatureCanonicalization", WSConstants.C14N_OMIT_COMMENTS );
    builder.add( "useSingleCert", false );

    /* ADDED: digest algorithm to use */
    builder.add( "digestAlgorithm", MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256 );

    wssEntryConfig.getConfiguration().set(builder.finish());

     

    Only now i need to know howto add parts to.