-
Notifications
You must be signed in to change notification settings - Fork 1
AuthenticationStrategy
In order to support communication with web services which require some sort of request authentication, Infinitum provides the AuthenticationStrategy
interface. AuthenticationStrategy
describes how web service requests are authenticated. This interface should be implemented for specific web service authentication strategies. If a web service uses token or shared-secret authentication, SharedSecretAuthentication should be used.
AuthenticationStrategy
has a single method which must be implemented called authenticate
. This method is used by the framework to add the necessary authentication information to outgoing web requests.
The example below shows how AuthenticationStrategy
can be implemented to add authentication credentials as a header in the request. This example is contrived as SharedSecretAuthentication
already provides this functionality. Note that authentication information might also be added to the request URI.
public class MyAuthenticator implements AuthenticationStrategy {
public void authenticate(RequestWrapper request) {
request.addHeader("secret-token", "foobar");
}
}