public final class CredentialsServer extends java.rmi.server.UnicastRemoteObject implements CredentialsService
System.setProperty("java.rmi.server.hostname", CredentialServer.LOCALHOST);
CredentialsServer credentialsServer = new CredentialsServer(12345, 30000, 60000);
String jnlpUrl = getApplicationJNLPUrl();
UUID token = UUID.randomUUID();
credentialServer.addAuthenticationToken(token, user);
new ProcessBuilder().command("javaws", "-open", token.toString(), jnlpUrl).start();
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LOCALHOST |
Constructor and Description |
---|
CredentialsServer(int port,
int tokenValidity,
int cleanupInterval)
Starts a server on the given port
|
Modifier and Type | Method and Description |
---|---|
void |
addAuthenticationToken(java.util.UUID authenticationToken,
User user)
Adds an authenticationToken associated with the given user, with the default token validity period
|
void |
exit()
Removes this server from the registry
|
User |
getUser(java.util.UUID authenticationToken) |
clone, exportObject, exportObject, exportObject, unexportObject
public static final java.lang.String LOCALHOST
public CredentialsServer(int port, int tokenValidity, int cleanupInterval) throws java.rmi.AlreadyBoundException, java.rmi.RemoteException
port
- the porttokenValidity
- the number of milliseconds a token is validcleanupInterval
- the expired token cleanup interval in millisecondsjava.rmi.RemoteException
- in case of a communication errorjava.rmi.AlreadyBoundException
- if a credential server is already runningpublic void addAuthenticationToken(java.util.UUID authenticationToken, User user)
authenticationToken
- the one-time tokenuser
- the user credentials associated with the tokenpublic User getUser(java.util.UUID authenticationToken) throws java.rmi.RemoteException
getUser
in interface CredentialsService
authenticationToken
- the tokenjava.rmi.RemoteException
- in case of a communication errorpublic void exit()