|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.idoox.wasp.SecurityHelper
Contains static methods that simplify authentication actions.
It is strongly recommended that WaspSecurity
is used for authentication
purposes instead.
You should follow these instructions to set up authentication of a client:
WASP 4.5 Actions:
authenticateClient
method with
user name, password and authentication mechanism.org.systinet.wasp.webservice.ServiceClient create method
.org.systinet.wasp.webservice.Registry lookup method
.WASP 4.5 Code:
import org.systinet.wasp.Wasp org.systinet.wasp.Wasp;
import org.systinet.wasp.webservice.ServiceClient;
import org.systinet.wasp.webservice.Registry;
import demo.ServiceInterface; // interface of service you would like to connect
...
// acquire credentials and set initiating provider to execution context
SecurityHelper.authenticateClient("test", "test", SecurityHelper.HttpBasic);
// create service client
ServiceClient sc = ServiceClient.create
("http://yourhost:port/serviceURI", ServiceInterface.class);
ServiceInterface serviceProxy = = (ServiceInterface)Registry.lookup
(sc);
// optional step - store current authentication result in your proxy (it is not thread aware
// for thread aware API see WaspSecurity
SecurityHelper.setAuthenticationSecurity(serviceProxy);
WASP 4.0 Actions:
WebServiceLookup
using
(WebServiceLookup)Context.getInstance(Context.WEBSERVICE_LOOKUP)
authenticateClient
method with
user name, password and authentication mechanism.WebServiceLookup
instance.WASP 4.0 Code:
import org.idoox.wasp.client.SecurityHelper;
import org.idoox.webservice.client.WebServiceLookup;
import org.idoox.wasp.Context;
import demo.ServiceInterface; // interface of service you would like to connect
...
// obtain lookup instance
WebServiceLookup lookup = (WebServiceLookup)Context.getInstance(Context.WEBSERVICE_LOOKUP);
// authenticate
SecurityHelper.authenticateClient("test", "test", SecurityHelper.HttpBasic);
// get service stub
ServiceInterface serviceProxy = (ServiceInterface)
lookup.lookup("http://yourhost/serviceURI", ServiceInterface.class);
// optional step - store current authentication result in your proxy (it
// simplifies your work if you are invoking more services)
SecurityHelper.setAuthenticationSecurity(serviceProxy);
If your service requires mutual authentication, you can invoke the
authenticateClient
to associate an identity with your service. You can also ask for web
service endpoint authentication requirements using the
getAnRequirementsForEndpoint
static method. Note also that SecurityHelper
methods are not
thread-aware. Use underlying WaspSecurity
that
allows to work in multi-thread environment (authentication mechanisms and credentials can be set
to proxies and service endpoints independetly on execution context).
Field Summary | |
static java.lang.String |
HttpBasic
Http basic authentication mechanism, its value is "HttpBasic". |
static java.lang.String |
HttpDigest
Http digest authentication mechanism, its value is "HttpDigest". |
static java.lang.String |
Kerberos
Kerberos authentication mechanism, its value is "Kerberos". |
static java.lang.String |
SoapDSig
SOAP Digital Signature authentication mechanism, its value is "SoapDSig". |
static java.lang.String |
SPKM
SPKM authentication mechanism, its value is "SPKM". |
static java.lang.String |
SSL
SSL authentication mechanism (client certificate) , its value is "SSL". |
Constructor Summary | |
SecurityHelper()
|
Method Summary | |
static void |
authenticateClient(java.lang.Object stub,
Credentials[] creds)
Authenticates client with given credentials and sets the security provider for the stub using provider obtained from first credentials. |
static boolean |
authenticateClient(java.lang.String userName,
java.lang.String password,
java.lang.String authenticationMechanism)
Authenticates the client using user name, password and authentication mechanism. |
static boolean |
authenticateServer(java.lang.String userName,
java.lang.String password,
java.lang.String authenticationMechanism)
Authenticates the service using user name, password and authentication mechanism. |
static Credentials |
createCredentials(java.lang.String userName,
java.lang.String password,
java.lang.String authenticationMechanism)
Creates client credentials for given name, password and authentication mechanism. |
static java.lang.String[] |
getAnRequirementsForEndpoint(java.lang.String serverURL,
java.lang.String serviceEndpointPath)
Returns authentication requirements for specified web service endpoint in the context of server URL. |
static void |
resetAuthentication()
Resets client credentials for all working threads. |
static void |
setAuthenticationSecurity(java.lang.Object stub)
Applies current authentication settings permanently for stub . |
static void |
setAuthenticationSecurity(java.lang.Object stub,
java.lang.String authenticationMechanism)
Gets current credentials, set them to the stub, and configures the stub to use given authentication mechanism. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String HttpBasic
public static final java.lang.String HttpDigest
public static final java.lang.String SSL
public static final java.lang.String SPKM
public static final java.lang.String SoapDSig
public static final java.lang.String Kerberos
Constructor Detail |
public SecurityHelper()
Method Detail |
public static boolean authenticateClient(java.lang.String userName, java.lang.String password, java.lang.String authenticationMechanism) throws java.security.NoSuchProviderException
null
.
userName
- user namepassword
- password of the userauthenticationMechanism
- authentication mechanism (e.g. SSL,
HttpBasic, HttpDigest, SPKM, SoapDSig, Kerberos), it can be null
to use default authentication mechanism
true
if the credentials can be created for
given authentication mechanism, user name and password,
false
otherwise
java.security.NoSuchProviderException
- if there is no provider for
specified authentication mechanismpublic static Credentials createCredentials(java.lang.String userName, java.lang.String password, java.lang.String authenticationMechanism) throws java.security.NoSuchProviderException
authenticateClient(java.lang.String, java.lang.String, java.lang.String)
method.
userName
- user namepassword
- password of the userauthenticationMechanism
- authentication mechanism (e.g.
SSL, HttpBasic, HttpDigest, SPKM, SoapDSig, Kerberos),
true
if the credentials can be created for
given authentication mechanism, user name and password,
false
otherwise
java.security.NoSuchProviderException
- if there is no provider for
specified authentication mechanismpublic static void authenticateClient(java.lang.Object stub, Credentials[] creds) throws java.security.NoSuchProviderException
creds
parameter is null or empty, credentials are removed from the stub and no security provider ise set to it.
Otherwise array of credentials is set to the stub and the first
credentials are used set security provider for it.
stub
- web service stubcreds
- information about principal, can be null
to reset credentials.
java.security.NoSuchProviderException
- if there is no provider for
authentication mechanism specified in the first credentialspublic static boolean authenticateServer(java.lang.String userName, java.lang.String password, java.lang.String authenticationMechanism) throws java.security.NoSuchProviderException
authenticateClient(java.lang.String, java.lang.String, java.lang.String)
method, this one does
not set security providers. This methods is especially useful for
authentication mechanism that allows mutual authentication on per
service basis (e.g. SPKM).
userName
- user namepassword
- password of the userauthenticationMechanism
- authentication mechanism (e.g. SSL,
HttpBasic, HttpDigest, SPKM), it can be null
to use default authentication mechanism
java.security.NoSuchProviderException
- if there is no provider for
authentication mechanism specifiedpublic static void setAuthenticationSecurity(java.lang.Object stub)
stub
. More precisely, it
WaspSecurity.getInstance().getCredentials(null)
method and sets these credentials to the given stub,
stub
- web service stubpublic static void setAuthenticationSecurity(java.lang.Object stub, java.lang.String authenticationMechanism) throws java.security.NoSuchProviderException
stub
- web service stub
java.security.NoSuchProviderException
- if there is no provider for
specified authentication mechanismpublic static void resetAuthentication()
SecurityHelper
.
public static java.lang.String[] getAnRequirementsForEndpoint(java.lang.String serverURL, java.lang.String serviceEndpointPath) throws WebServiceLookupException
serverURL
- server URL (e.g. "http://localhost:6060")serviceEndpointPath
- service endpoint path (e.g. "/admin/DeployService")
WebServiceLookupException
- if unable to lookup the service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |