You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by Mailindra <ma...@gmx.net> on 2004/09/24 23:36:27 UTC

How to encrypt element within SOAP?

Hai All,
I am new with wss4j and webservices security. I need to develop ws 
application that encrypt some element within SOAP  Body,  for eg.  the 
application only encrypt the <payment> element. 
Could someone assist me the steps to encrypt element within SOAP Body?
 Are there any API in WSS4J that I can use? or should I deal directly 
with XML-Security API?

TIA for any helps.

regards,

Mailindra

Re: How to encrypt element within SOAP?

Posted by Mailindra <ma...@gmx.net>.
Hai Jason and All,
Thanks you very much for the info.
It seems that I can use the WSDoAllSender handler to encrypt or signing 
(or both) document AUTOMAGICALLY.
I have tried following the info you gave, and it works !

After toying sometimes with the parameters, I found the handler is very 
flexible. for eg:  <parameter name="action"  value="..."> can be used to 
encrypt, signing or both.  the   <parameter 
name="encryptionSymAlgorithm" value="..." /> can be used to specify the 
algorithm for encrypting the symmetric key, etc.
Is there documentation explaining all the combination of parameter that 
can be used? Otherwise I have to tried all the possibilities :(

Any help will be appreciated.

Best regards,

Mailindra


Jason Essington wrote:

> you can define the parameter "encryptionParts" in your handler 
> definition. this parameter tells wss4j which parts of the soap message 
> to encrypt.
>
> from the WSHandlerConstants javadoc:
>
>  ENCRYPTION_PARTS
> public static final java.lang.String ENCRYPTION_PARTS
> Parameter to define which parts of the request shall be encrypted.
>
>  The value of this parameter is a list of semi-colon separated  
> element names that identify the elements to encrypt. An encryption 
> mode  specifier and a namespace identification, each inside a pair of 
> curly  brackets, may preceed each element name.
>
>  The encryption mode specifier is either {Content} or  {Element}. 
> Please refer to the W3C XML Encryption specification about the 
> differences between Element and Content  encryption. The encryption 
> mode defaults to Content if it is omitted. Example of a list:
>  <parameter name="encryptionParts"
>    value="{Content}{http://example.org/paymentv2}CreditCard;
>              {Element}{}UserName" />
>
>  The the first entry of the list identifies the element  CreditCard in 
> the namespace  http://example.org/paymentv2, and will encrypt its 
> content.  Be aware that the element name, the namespace identifier, 
> and the  encryption modifier are case sensitive.
>
>  The encryption modifier and the namespace identifier can be ommited.  
> In this case the encryption mode defaults to Content and  the 
> namespace is set to the SOAP namespace.
>
>  An empty encryption mode defaults to Content, an empty  namespace 
> identifier defaults to the SOAP namespace.  The second line of the 
> example defines Element as  encryption mode for an UserName element in 
> the SOAP  namespace.
>
>  If no list is specified, the handler encrypts the SOAP Body in  
> Content mode
>
> -jason
> On Sep 24, 2004, at 3:36 PM, Mailindra wrote:
>
>> Hai All,
>> I am new with wss4j and webservices security. I need to develop ws 
>> application that encrypt some element within SOAP  Body,  for eg.  
>> the application only encrypt the <payment> element. Could someone 
>> assist me the steps to encrypt element within SOAP Body?
>> Are there any API in WSS4J that I can use? or should I deal directly 
>> with XML-Security API?
>>
>> TIA for any helps.
>>
>> regards,
>>
>> Mailindra
>>
>
>


Re: How to encrypt element within SOAP?

Posted by Jason Essington <ja...@GreenRiverComputing.com>.
you can define the parameter "encryptionParts" in your handler 
definition. this parameter tells wss4j which parts of the soap message 
to encrypt.

from the WSHandlerConstants javadoc:

  ENCRYPTION_PARTS
public static final java.lang.String ENCRYPTION_PARTS
Parameter to define which parts of the request shall be encrypted.

  The value of this parameter is a list of semi-colon separated  element 
names that identify the elements to encrypt. An encryption mode  
specifier and a namespace identification, each inside a pair of curly  
brackets, may preceed each element name.

  The encryption mode specifier is either {Content} or  {Element}. 
Please refer to the W3C XML Encryption specification about the 
differences between Element and Content  encryption. The encryption 
mode defaults to Content if it is omitted. Example of a list:
  <parameter name="encryptionParts"
    value="{Content}{http://example.org/paymentv2}CreditCard;
              {Element}{}UserName" />

  The the first entry of the list identifies the element  CreditCard in 
the namespace  http://example.org/paymentv2, and will encrypt its 
content.  Be aware that the element name, the namespace identifier, and 
the  encryption modifier are case sensitive.

  The encryption modifier and the namespace identifier can be ommited.  
In this case the encryption mode defaults to Content and  the namespace 
is set to the SOAP namespace.

  An empty encryption mode defaults to Content, an empty  namespace 
identifier defaults to the SOAP namespace.  The second line of the 
example defines Element as  encryption mode for an UserName element in 
the SOAP  namespace.

  If no list is specified, the handler encrypts the SOAP Body in  
Content mode

-jason
On Sep 24, 2004, at 3:36 PM, Mailindra wrote:

> Hai All,
> I am new with wss4j and webservices security. I need to develop ws 
> application that encrypt some element within SOAP  Body,  for eg.  the 
> application only encrypt the <payment> element. Could someone assist 
> me the steps to encrypt element within SOAP Body?
> Are there any API in WSS4J that I can use? or should I deal directly 
> with XML-Security API?
>
> TIA for any helps.
>
> regards,
>
> Mailindra
>