Skip to content

AuthenticationStrategy

tylertreat edited this page Jan 17, 2013 · 1 revision

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.

AuthenticationStrategy Example

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");
    }

}
Clone this wiki locally