|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.systinet.wasp.security.ws.MessageSecurity
Manages high-level WS-Security runtime configuration at both context and call scope.
There are several security elements which allows you to compose message security: tokens, signatures and encrypted data. The order in which you add security elements to configuration determines the order of their processing.
Security configuration scope
Context scope WS-Security configuration is shared across all invocations in the same
context. To set up context WS-Security configuration, use setContextSecurity(ServiceClient)
or setContextSecurity(ServiceEndpoint) method.
Before calling these methods, you may need or want to:
X509Token
is needed, for data encrypted with shared secret key, instance of SharedSecretToken
is needed.
Use addExternalToken(SecurityToken) method to add a token to external
context tokens. See X509Token and SharedSecretToken for examples.
Username tokens without
Nonce and Created subelements (see setAcceptUsernameTokenWithoutNonceAndCreated()
method).
Timestamp header to outgoing messages (see setCreateTimestampHeader()
method).
Call scope WS-Security configuration is valid only for the next call. To set up
call WS-Security configuration, use setCallSecurity(ServiceClient)
or setCallSecurity(ServiceEndpoint) method.
Before calling these methods, you may want to:
Timestamp header to outgoing message (see setCreateTimestampHeader()
method).
Please note that once setContextSecurity or setCallSecurity
method is called, further security configuration using the same MessageSecurity
instance is not possible and IllegalStateException will be thrown.
Response encryption using requestor's public key
In many situations, you may want to encrypt the response for the requestor using
its public key. For such scenario, X509Token may be instantiated with received credentials
(see X509Token.X509Token(java.lang.String)),
provided that WSO2 SOA Enablement Server successfuly authenticated the requestor.
At present, WSO2 SOA Enablement Server attempts to authenticates the requestor only
when incoming message contains username token or when the message body is signed.
But there are situations when the requestor signs only a part of the message or does not attach
username token to the message, but requires the response encrypted with its public key.
For such situations, it is possible to write simple validator (which implements
IncomingValidator interface) and add it to the context configuration.
In the validator's IncomingValidator.validate(MessageConf) method, incoming message
security configuration may be analysed and suitable token selected, and the requestor
authenticated using the selected token data. Later on, token with received credentials
for response encryption may be instantiated and used.
UsernameToken,
X509Token,
SharedSecretToken,
Signature,
EncryptedData| Nested Class Summary | |
static class |
MessageSecurity.Version
WS-Security version enumeration. |
| Constructor Summary | |
MessageSecurity()
Creates a new MessageSecurity instance. |
|
MessageSecurity(MessageSecurity.Version version)
Creates a new MessageSecurity instance with the specified version. |
|
| Method Summary | |
void |
addExternalToken(SecurityToken token)
Adds external (context) token to configuration. |
void |
addSecurityElement(SecurityElement securityElement)
Adds a security element to configuration. |
void |
addToken(SecurityToken token)
Adds a token to configuration. |
void |
setAcceptUsernameTokenWithoutNonceAndCreated()
Disables Nonce and Created username token
subelements checking (context-scope setting). |
void |
setCallSecurity(ServiceClient serviceClient)
Sets message configuration for the current call. |
void |
setCallSecurity(ServiceEndpoint serviceEndpoint)
Sets message configuration for the current call. |
void |
setContextSecurity(ServiceClient serviceClient)
Sets service client context security configuration. |
void |
setContextSecurity(ServiceEndpoint serviceEndpoint)
Sets service endpoint context security configuration. |
void |
setCreateTimestampHeader()
wsu:Timestamp header will be created. |
void |
setIgnoreTimestampHeaderExpiration()
Disables wsu:Timestamp expiration check (context-scope setting). |
void |
setSecureFault()
Sets a flag to apply security to faults as well. |
void |
setSecurity(ServiceClient serviceClient)
Sets client security configuration. |
void |
setSecurity(ServiceEndpoint serviceEndpoint)
Sets endpoint security configuration. |
void |
setTimestampHeaderExpiration(int millis)
Overrides default timestamp header expiration. |
void |
setTimestampHeaderMaxAge(int millis)
Overrides default timestamp header max age accepted. |
void |
setTimestampId(java.lang.String id)
Sets ID of the timestamp header so it can be referenced using UriReference. |
void |
setValidator(IncomingValidator validator)
Sets incoming validator. |
void |
setWsseNamespace(java.lang.String wsseNamespace)
Deprecated. Use #MessageSecurity(Version) to specify version of WS-Security. |
void |
setWsuNamespace(java.lang.String wsuNamespace)
Deprecated. Use #MessageSecurity(Version) to specify version of WS-Security. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MessageSecurity()
MessageSecurity instance.
public MessageSecurity(MessageSecurity.Version version)
MessageSecurity instance with the specified version.
version - | Method Detail |
public void addToken(SecurityToken token)
token - security tokenpublic void addExternalToken(SecurityToken token)
Use only for context-scope configuration.
token - context security tokenpublic void addSecurityElement(SecurityElement securityElement)
securityElement - security elementpublic void setSecureFault()
public void setAcceptUsernameTokenWithoutNonceAndCreated()
Nonce and Created username token
subelements checking (context-scope setting).
public void setCreateTimestampHeader()
wsu:Timestamp header will be created.
setTimestampId(String)public void setTimestampId(java.lang.String id)
UriReference.
setCreateTimestampHeader()public void setTimestampHeaderExpiration(int millis)
millis - expire timeWSSEConf.setTimestampHeaderExpiration(Integer)public void setTimestampHeaderMaxAge(int millis)
millis - max age time; -1 for no limitWSSEConf.setTimestampHeaderMaxAge(Integer)public void setIgnoreTimestampHeaderExpiration()
wsu:Timestamp expiration check (context-scope setting).
WSSEConf.setIgnoreTimestampHeaderExpiration(Boolean)public void setSecurity(ServiceClient serviceClient)
setContextSecurity(ServiceClient serviceClient).
serviceClient - service clientpublic void setSecurity(ServiceEndpoint serviceEndpoint)
setContextSecurity(ServiceEndpoint serviceEndpoint).
serviceEndpoint - service endpointpublic void setContextSecurity(ServiceClient serviceClient)
serviceClient - instance of ServiceClientpublic void setCallSecurity(ServiceClient serviceClient)
serviceClient - instance of ServiceClientpublic void setContextSecurity(ServiceEndpoint serviceEndpoint)
serviceEndpoint - instance of ServiceEndpointpublic void setCallSecurity(ServiceEndpoint serviceEndpoint)
serviceEndpoint - instance of ServiceEndpointpublic void setValidator(IncomingValidator validator)
IncomingValidator for more.
validator - validatorpublic void setWsseNamespace(java.lang.String wsseNamespace)
#MessageSecurity(Version) to specify version of WS-Security.
wsseNamespace - wsse namespaceConstants.DEFAULT_WSSE_NAMESPACEpublic void setWsuNamespace(java.lang.String wsuNamespace)
#MessageSecurity(Version) to specify version of WS-Security.
wsuNamespace - wsu namespaceConstants.DEFAULT_WSU_NAMESPACE
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||