org.systinet.wasp.security.ws
Class Signature

java.lang.Object
  extended byorg.systinet.wasp.security.ws.ReferrableElement
      extended byorg.systinet.wasp.security.ws.SecurityElement
          extended byorg.systinet.wasp.security.ws.Signature

public class Signature
extends SecurityElement

Represents signature. To sign a message part, you need to create a token for signing and initialize Signature instance using that token. Then you may add references to message part(s), or specify that message body is to be signed by calling setSignBody() method.

Default values

signature method:

canonicalization method: digest method: key info security token reference:

Examples

Signing message body:

 // create service client instance
 ServiceClient serviceClient = ServiceClient.create("http://...");

 // authenticate client and set the credentials
 Credentials creds = WaspSecurity.acquireClientCredentials("Chris", "sirhC", "WS-Security");
 WaspSecurity.setCredentials(serviceClient, new Credentials[]{creds});
 WaspSecurity.setInitiatingProvider(serviceClient, "WS-Security");

 // create service proxy
 ServiceSoap svc = (ServiceSoap) serviceClient.createProxy(ServiceSoap.class);

 // create new call security configuration
 MessageSecurity ms = new MessageSecurity();

 // create signing token
 X509Token signingX509token = new X509Token();

 // add the token to message security
 ms.addToken(signingX509token);

 // create new signature
 Signature sig = new Signature(signingX509token);

 // set body signing
 sig.setSignBody();

 // add the signature to message security
 ms.addSecurityElement(sig);

 // set call security
 ms.setCallSecurity(serviceClient);

 // invoke service method
 svc.ping("EchoString");
 

Since:
4.6
See Also:
UsernameToken, X509Token, SharedSecretToken, MessageSecurity
Component:
Security-Providers

Constructor Summary
Signature(SecurityToken token)
          Initializes a new signature with the specified signing token.
Signature(SecurityToken token, UriReference reference)
          Initializes a new signature with the specified signing token and resource reference to be signed.
 
Method Summary
 void addReference(UriReference reference)
          Adds a reference to a resource to be included in the signature.
 void setCanonicalizationMethod(java.lang.String canonicalizationMethod)
          Sets canonicalization method.
 void setSecurityTokenReferenceId(java.lang.String strId)
          Sets value of the wsu:Id set on the SecurityTokenReference subelement of the tag Signature/KeyInfo.
 void setSignBody()
          Instructs the signature to sign message body.
 
Methods inherited from class org.systinet.wasp.security.ws.SecurityElement
getToken
 
Methods inherited from class org.systinet.wasp.security.ws.ReferrableElement
getId, getIdForced, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Signature

public Signature(SecurityToken token)
Initializes a new signature with the specified signing token.

Parameters:
token - token

Signature

public Signature(SecurityToken token,
                 UriReference reference)
Initializes a new signature with the specified signing token and resource reference to be signed. Equivalent to
 Signature sig = new Signature(token);
 sig.addReference(new UriReference("..."));
 

Parameters:
token - token
Method Detail

addReference

public void addReference(UriReference reference)
Adds a reference to a resource to be included in the signature.

Parameters:
reference - resource reference

setSignBody

public void setSignBody()
Instructs the signature to sign message body.


setCanonicalizationMethod

public void setCanonicalizationMethod(java.lang.String canonicalizationMethod)
Sets canonicalization method. Supported methods are:

Parameters:
canonicalizationMethod - canonicalization method

setSecurityTokenReferenceId

public void setSecurityTokenReferenceId(java.lang.String strId)
Sets value of the wsu:Id set on the SecurityTokenReference subelement of the tag Signature/KeyInfo.

Parameters:
strId - the wsu:Id attribute value