org.jscep.client
Class Client.Builder

java.lang.Object
  extended by org.jscep.client.Client.Builder
Enclosing class:
Client

public static class Client.Builder
extends Object

This class is used for building immutable instances of the Client class.

Instances of this class can be configured by invoking the methods declared below. Following configuration, the build() method should be invoked to retrieve the new Client instance.

In order to create a valid Client, adopters must adhere to the following pre-conditions. The client must be able to...

If an instance of this class is not correctly configured according to the above pre-conditions, the build() method will throw an IllegalStateException.

Example Usage:

 URL url = new URL("http://www.example.org/scep/pkiclient.exe");
 X509Certificate id = ...;
 KeyPair pair = ...;
 CallbackHandler handler = ...;
 
 Client client = new Client.Builder().url(url).identity(id, pair).callbackHandler(handler).build();
 

Author:
David Grant

Constructor Summary
Client.Builder()
           
 
Method Summary
 Client build()
          Constructs a new immutable instance of Client.
 Client.Builder caFingerprint(byte[] fingerprint, String hashAlgorithm)
          Sets the expected CA fingerprint.
 Client.Builder caIdentifier(String caIdentifier)
          Sets the CA identity string.
 Client.Builder callbackHandler(CallbackHandler callbackHandler)
          Sets a CallbackHandler to use for handling the fingerprint verification callback.
 Client.Builder identity(X509Certificate identity, KeyPair keyPair)
          Sets the identity of the SCEP client.
 Client.Builder proxy(Proxy proxy)
          Sets the Proxy needed to access the SCEP server, if any.
 Client.Builder url(URL url)
          Sets the URL of the SCEP server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client.Builder

public Client.Builder()
Method Detail

url

public Client.Builder url(URL url)
Sets the URL of the SCEP server.

The URL should be of the following form:

 http(s?)://<host>[:<port>]/[<path>]pkiclient.exe
 

Parameters:
url - the URL.
Returns:
the builder.

proxy

public Client.Builder proxy(Proxy proxy)
Sets the Proxy needed to access the SCEP server, if any.

Parameters:
proxy - the Proxy.
Returns:
the builder.

caFingerprint

public Client.Builder caFingerprint(byte[] fingerprint,
                                    String hashAlgorithm)
Sets the expected CA fingerprint.

If the fingerprint is not known, the callbackHandler(CallbackHandler) method MUST be used instead.

Parameters:
fingerprint - the expected fingerprint.
hashAlgorithm - the algorithm used to create the fingerprint.
Returns:
the builder.

caIdentifier

public Client.Builder caIdentifier(String caIdentifier)
Sets the CA identity string.

This property should be set if the CA supports multiple profiles.

Parameters:
caIdentifier - the CA identity string.
Returns:
the builder.

identity

public Client.Builder identity(X509Certificate identity,
                               KeyPair keyPair)
Sets the identity of the SCEP client.

The arguments provided to this method represent the identity of the SCEP client, and not necessarily the entity to be enrolled.

Parameters:
identity - the client identity.
keyPair - the RSA keypair of the client.
Returns:
the builder.

callbackHandler

public Client.Builder callbackHandler(CallbackHandler callbackHandler)
Sets a CallbackHandler to use for handling the fingerprint verification callback.

This method should be used if the CA fingerprint is not known at the time of client creation. If a fingerprint is already known, the caFingerprint(byte[], String) method should be used instead.

The provided CallbackHandler MUST be able to handle the FingerprintVerificationCallback callback.

Parameters:
callbackHandler - the callback handler.
Returns:
the builder.

build

public Client build()
             throws IllegalStateException
Constructs a new immutable instance of Client.

Returns:
a new instance of Client
Throws:
IllegalStateException - if any pre-conditions have been violated.


Copyright © 2010. All Rights Reserved.