Package org.forgerock.openig.tools.am
Class AmService
- java.lang.Object
-
- org.forgerock.openig.tools.am.AmService
-
public final class AmService extends Object
Creates a configuration class for AM.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AmService.Builder
Builder ofAmService
.
-
Field Summary
Fields Modifier and Type Field Description static AmVersion
DEFAULT_AM_VERSION
AM 5.0.0 (equivalent of OpenAM 14.0.0).static String
DEFAULT_COOKIE_NAME
The default cookie header name for the OpenAM Server.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AmService.Builder
builder(URI baseUri, Handler amHandler, Clock clock, String agentId, SecretReference<GenericSecret> agentPassword)
Returns a newAmService.Builder
for creating a newAmService
instance.static AmService.Builder
builder(AmService amService)
Returns a newAmService.Builder
for creating a newAmService
instance from a given one.String
getAgentId()
Returns the agent's ID.Handler
getAuthenticatedHandler()
Returns aHandler
that will perform automatic authentication with the provided agent credentials.AuthenticationService
getAuthenticationService()
Returns the service used to authenticate subjects to AM.URI
getBaseUri()
Return the base URI for this server.String
getCookieName()
Returns the cookie header name used by AM server.Handler
getHandler()
Returns the handler to use with this configuration.Optional<NotificationService>
getNotificationService()
Returns the AM notification service.Realm
getRealm()
Returns the realm to use with this configuration.SessionService
getSessionService()
Returns theSessionService
for this server.AsyncRefreshableSupplier<SsoToken,AuthenticationException>
getTokenProvider()
Returns theAsyncRefreshableSupplier
being used as aSsoToken
provider for this server.Version
getVersion()
Return the version of the configured OpenAM Server.String
json()
Build the endpoint URI for an endpoint located in the/json
namespace.String
json(String endpoint)
Build the endpoint URI for an endpoint located in the/json
namespace.URI
jsonUri()
Build the endpoint URI for an endpoint located in the/json
namespace.URI
jsonUri(String endpoint)
Build the endpoint URI for an endpoint located in the/json
namespace.String
oauth2(String endpoint)
Build the endpoint URI for an endpoint located in the/oauth2
namespace.URI
oauth2Uri(String endpoint)
Build the endpoint URI for an endpoint located in the/oauth2
namespace.void
start()
Starts this server instance (and associated services).Promise<Void,NeverThrowsException>
stop()
Stops this server instance (and associated services).String
sts()
Returns the transformation endpoint located in the/rest-sts
namespace.String
sts(String endpoint)
Returns the transformation endpoint located in the/rest-sts
namespace.URI
stsUri(String endpoint)
Returns the URI of the transformation endpoint located in the/rest-sts
namespace.String
uma(String endpoint)
Build the endpoint URI for an endpoint located in the/uma
namespace.URI
umaUri(String endpoint)
Build the endpoint URI for an endpoint located in the/uma
namespace.UriService
uriService(Realm realm)
Provides anUriService
instance that creates URI for the given realm.Handler
withHeadlessAuthentication(Handler delegate)
Returns aHandler
which wraps theHeadlessAuthenticationFilter
.
-
-
-
Field Detail
-
DEFAULT_COOKIE_NAME
public static final String DEFAULT_COOKIE_NAME
The default cookie header name for the OpenAM Server.- See Also:
- Constant Field Values
-
DEFAULT_AM_VERSION
public static final AmVersion DEFAULT_AM_VERSION
AM 5.0.0 (equivalent of OpenAM 14.0.0).
-
-
Method Detail
-
builder
public static AmService.Builder builder(URI baseUri, Handler amHandler, Clock clock, String agentId, SecretReference<GenericSecret> agentPassword)
Returns a newAmService.Builder
for creating a newAmService
instance.- Parameters:
baseUri
- AM base URI (ex: http://openam.example.com/openam), nevernull
.amHandler
- The handler to use theCrestSessionService
, notnull
.clock
- The clock to use when dealing with time, notnull
.agentId
- The agent id, notnull
.agentPassword
- The agent's password, notnull
.- Returns:
- a new builder
-
builder
public static AmService.Builder builder(AmService amService)
Returns a newAmService.Builder
for creating a newAmService
instance from a given one.- Parameters:
amService
- TheAmService
to copy.- Returns:
- a new builder based on the given
AmService
.
-
getHandler
public Handler getHandler()
Returns the handler to use with this configuration.- Returns:
- The handler used in this configuration.
-
getAuthenticationService
public AuthenticationService getAuthenticationService()
Returns the service used to authenticate subjects to AM.- Returns:
- the service used to authenticate subjects to AM.
-
getNotificationService
public Optional<NotificationService> getNotificationService()
Returns the AM notification service.- Returns:
- the AM notification service.
-
getAgentId
public String getAgentId()
Returns the agent's ID.- Returns:
- the agent's ID.
-
start
public void start() throws Exception
Starts this server instance (and associated services).- Throws:
Exception
- if startup failed
-
stop
public Promise<Void,NeverThrowsException> stop()
Stops this server instance (and associated services).- Returns:
- Promise completing the service being stopped
-
getRealm
public Realm getRealm()
Returns the realm to use with this configuration.- Returns:
- The realm used in this configuration.
-
getCookieName
public String getCookieName()
Returns the cookie header name used by AM server.- Returns:
- the cookie header name used by AM server.
-
getBaseUri
public URI getBaseUri()
Return the base URI for this server.- Returns:
- the base URI for this server.
-
getVersion
public Version getVersion()
Return the version of the configured OpenAM Server.- Returns:
- the version of the configured OpenAM Server.
-
getAuthenticatedHandler
public Handler getAuthenticatedHandler()
Returns aHandler
that will perform automatic authentication with the provided agent credentials.- Returns:
- the
Handler
that will perform automatic authentication.
-
withHeadlessAuthentication
public Handler withHeadlessAuthentication(Handler delegate)
Returns aHandler
which wraps theHeadlessAuthenticationFilter
.- Parameters:
delegate
- The delegate Handler.- Returns:
- a
Handler
which wraps theHeadlessAuthenticationFilter
.
-
getSessionService
public SessionService getSessionService()
Returns theSessionService
for this server.- Returns:
- the
SessionService
in use for this server.
-
getTokenProvider
public AsyncRefreshableSupplier<SsoToken,AuthenticationException> getTokenProvider()
Returns theAsyncRefreshableSupplier
being used as aSsoToken
provider for this server.- Returns:
- the
AsyncRefreshableSupplier
being used as aSsoToken
provider for this server.
-
json
public String json()
Build the endpoint URI for an endpoint located in the/json
namespace.- Returns:
- an absolute endpoint URI.
-
json
public String json(String endpoint)
Build the endpoint URI for an endpoint located in the/json
namespace.- Parameters:
endpoint
- endpoint name, such as policies or /serverinfo/version. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI.
-
jsonUri
public URI jsonUri()
Build the endpoint URI for an endpoint located in the/json
namespace.- Returns:
- an absolute endpoint URI.
-
jsonUri
public URI jsonUri(String endpoint)
Build the endpoint URI for an endpoint located in the/json
namespace.- Parameters:
endpoint
- endpoint name, such as policies or /serverinfo/version. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI
-
oauth2
public String oauth2(String endpoint)
Build the endpoint URI for an endpoint located in the/oauth2
namespace.- Parameters:
endpoint
- endpoint name, such as .well-known/openid-configuration or /authorize. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI
-
oauth2Uri
public URI oauth2Uri(String endpoint)
Build the endpoint URI for an endpoint located in the/oauth2
namespace.- Parameters:
endpoint
- endpoint name, such as .well-known/openid-configuration or /authorize. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI.
-
uma
public String uma(String endpoint)
Build the endpoint URI for an endpoint located in the/uma
namespace.- Parameters:
endpoint
- endpoint name, such as .well-known/uma-configuration or /authz_request. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI.
-
sts
public String sts()
Returns the transformation endpoint located in the/rest-sts
namespace.- Returns:
- the transformation endpoint located in the
/rest-sts
namespace.
-
sts
public String sts(String endpoint)
Returns the transformation endpoint located in the/rest-sts
namespace.- Parameters:
endpoint
- The endpoint name, such as rest-sts/username-transformer. The endpoint MUST be a proper encoded path.- Returns:
- the transformation endpoint located in the
/rest-sts
namespace.
-
stsUri
public URI stsUri(String endpoint)
Returns the URI of the transformation endpoint located in the/rest-sts
namespace.- Parameters:
endpoint
- The endpoint name, such as rest-sts/username-transformer. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI.
-
umaUri
public URI umaUri(String endpoint)
Build the endpoint URI for an endpoint located in the/uma
namespace.- Parameters:
endpoint
- endpoint name, such as .well-known/uma-configuration or /authz_request. The endpoint MUST be a proper encoded path.- Returns:
- an absolute endpoint URI.
-
uriService
public UriService uriService(Realm realm)
Provides anUriService
instance that creates URI for the given realm.- Parameters:
realm
- the realm we want URIs for (nevernull
)- Returns:
- the associated UriService
-
-