|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.feide.moria.controller.MoriaController
public final class MoriaController
Intermediator for the sub modules of Moria. The controller is the only entry
point for accessing Moria. Basically, all work is done by the authorization
module, the distributed store, the directory manager and the logger. The
controller must be initialized from the servlets that are using it. This can
be done by calling the initController
method.
initController(javax.servlet.ServletContext)
Field Summary | |
---|---|
private static no.feide.moria.log.AccessLogger |
accessLogger
Used for access logging. |
private static boolean |
amReady
Flag set to true if the authorization manager is ready. |
private static no.feide.moria.authorization.AuthorizationManager |
authzManager
The single instance of the authorization manager. |
private static java.lang.String |
CAUGHT_DENIED_USERORG
Log message for AuthorizationException. |
private static java.lang.String |
CAUGHT_INVALID_TICKET
Standard log message for InvalidTicketException. |
private static java.lang.String |
CAUGHT_NONEXISTENT_TICKET
Standard log message for NonExistentTicketException. |
private static java.lang.String |
CAUGHT_STORE
Standard log message for InvalidTicketException. |
private static ConfigurationManager |
configManager
The single instance of the configuration manager. |
private static java.lang.String |
DIRECT_AUTH_OPER
Operation type for local authentication. |
private static no.feide.moria.directory.DirectoryManager |
directoryManager
The single instance of the directory manager. |
private static boolean |
dmReady
Flag set to true if the directory manager is ready. |
private static java.lang.String |
INTERACTIVE_AUTH_OPER
Operation type for interactive authentication. |
private static java.lang.Boolean |
isInitialized
Flag set to true if the controller has been initialized. |
private static no.feide.moria.log.MessageLogger |
messageLogger
Used for message/error logging. |
private static java.lang.String |
NONEXISTENT_TICKET
Standard exception message for indication that ticket does not exist. |
private static java.lang.String |
NOT_READY
Standard exception message for indication that the controller is not ready. |
private static java.lang.String |
PROXY_AUTH_OPER
Operation type for interactive authentication. |
private static boolean |
ready
Flag set to true if the controller and all modules are ready. |
static java.lang.String |
SERVICE_TICKET
Ticket type constant, indicating a login ticket, for use when returning a HashMap with multiple tickets. |
private static javax.servlet.ServletContext |
servletContext
The servlet context for the servlets using the controller. |
private static boolean |
smReady
Flag set to true if the store manager is ready. |
static java.lang.String |
SSO_TICKET
Ticket type constant, indicating an SSO ticket, for use when returning a HashMap of two tickets. |
private static no.feide.moria.store.MoriaStore |
store
The single instance of the data store. |
private static java.lang.String |
STORE_DOWN
Standard exception message for indication that the store is unavailable. |
(package private) static java.lang.String |
TGT_IDENTIFIER
Identifier for the TGT used in attribute requests. |
private static java.lang.String |
VERIFY_USER_EXISTENCE_OPER
Operation type for verify user existence. |
Constructor Summary | |
---|---|
private |
MoriaController()
Private constructor. |
Method Summary | |
---|---|
static java.util.Map |
attemptLogin(java.lang.String loginTicketId,
java.lang.String ssoTicketId,
java.lang.String userId,
java.lang.String password,
boolean denySSO)
Performs interactive login attempt using tickets and credentials. |
static java.lang.String |
attemptSingleSignOn(java.lang.String loginTicketId,
java.lang.String ssoTicketId)
Attempts single sign on (non-interactive) with an SSO ticket together with the login ticket. |
private static java.util.HashMap |
authenticate(java.lang.String sessionTicket,
no.feide.moria.directory.Credentials userCredentials,
java.lang.String[] attributeRequest)
Convenience method to assure certain pre-authentication checks. |
private static void |
authorizationCheck(java.lang.String servicePrincipal,
java.lang.String[] attributes,
java.lang.String operation)
Performs an authorization validation of a service request; can the service perform the requested operation? |
static java.util.Map |
directNonInteractiveAuthentication(java.lang.String[] requestedAttributes,
java.lang.String userId,
java.lang.String password,
java.lang.String servicePrincipal)
Performs a direct authentication without the use of tickets. |
static java.lang.String |
getProxyTicket(java.lang.String ticketGrantingTicket,
java.lang.String proxyServicePrincipal,
java.lang.String servicePrincipal)
Generates a proxy ticket based on a TGT. |
static java.lang.String |
getRedirectURL(java.lang.String serviceTicketId)
Creates a redirect URL for redirecting user back to web service. |
static java.lang.String[] |
getRequestedAttributes(java.lang.String loginTicket,
java.lang.String servicePrincipal)
Gets the name of the attributes a service requests, based on the loginTicket. |
static int |
getSecLevel(java.lang.String loginTicketId)
Gets the security level of an authentication attempt. |
static java.util.HashMap |
getServiceProperties(java.lang.String loginTicketId)
Returns the service configuration for the service that created the authentication attempt. |
static java.util.HashMap |
getStatus()
Gets the total status of the controller. |
static java.util.Map |
getUserAttributes(java.lang.String serviceTicketId,
java.lang.String servicePrincipal)
Retrieves user attributes from an authentication attempt. |
static java.lang.String |
getUserOrg(java.lang.String username)
Resolves a user's home organization through the Directory Manager. |
(package private) static void |
init()
Initiates the controller. |
static void |
initController(javax.servlet.ServletContext sc)
Starts the controller. |
static java.lang.String |
initiateAuthentication(java.lang.String[] attributes,
java.lang.String returnURLPrefix,
java.lang.String returnURLPostfix,
boolean forceInteractiveAuthentication,
java.lang.String servicePrincipal)
Initiates authentication through Moria. |
static void |
invalidateSSOTicket(java.lang.String ssoTicketId)
Invalidates an SSO ticket. |
(package private) static boolean |
isLegalURL(java.lang.String url)
Validates a URL. |
static boolean |
isOrganizationAllowedForService(java.lang.String servicePrincipal,
java.lang.String userOrganization)
Check whether a given service may allow users from a given organization. |
private static void |
organizationCheck(java.lang.String servicePrincipal,
java.lang.String userOrganization)
Checks whether the user's organization is allowed to use the service in question. |
static java.util.Map |
proxyAuthentication(java.lang.String[] requestedAttributes,
java.lang.String proxyTicketId,
java.lang.String servicePrincipal)
Performs a ticket based proxy authentication. |
static void |
setConfig(java.lang.String module,
java.util.Properties properties)
Sets config for a module. |
(package private) static void |
stop()
Shuts down the controller. |
static void |
stopController()
Stops the controller. |
static boolean |
verifyUserExistence(java.lang.String userId,
java.lang.String servicePrincipal)
Verifies the existence of a user. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SSO_TICKET
attemptLogin(java.lang.String, java.lang.String,
java.lang.String, java.lang.String, boolean)
,
attemptSingleSignOn(java.lang.String,
java.lang.String)
,
Constant Field Valuespublic static final java.lang.String SERVICE_TICKET
attemptLogin(java.lang.String, java.lang.String,
java.lang.String, java.lang.String, boolean)
,
attemptSingleSignOn(java.lang.String,
java.lang.String)
,
Constant Field Valuesprivate static final java.lang.String DIRECT_AUTH_OPER
private static final java.lang.String INTERACTIVE_AUTH_OPER
private static final java.lang.String PROXY_AUTH_OPER
private static final java.lang.String VERIFY_USER_EXISTENCE_OPER
static final java.lang.String TGT_IDENTIFIER
private static final java.lang.String STORE_DOWN
private static final java.lang.String NOT_READY
private static final java.lang.String NONEXISTENT_TICKET
private static final java.lang.String CAUGHT_NONEXISTENT_TICKET
private static final java.lang.String CAUGHT_INVALID_TICKET
private static final java.lang.String CAUGHT_STORE
private static final java.lang.String CAUGHT_DENIED_USERORG
private static no.feide.moria.store.MoriaStore store
private static ConfigurationManager configManager
private static no.feide.moria.authorization.AuthorizationManager authzManager
private static no.feide.moria.directory.DirectoryManager directoryManager
private static java.lang.Boolean isInitialized
private static boolean ready
private static boolean amReady
private static boolean dmReady
private static boolean smReady
private static javax.servlet.ServletContext servletContext
private static no.feide.moria.log.AccessLogger accessLogger
private static no.feide.moria.log.MessageLogger messageLogger
Constructor Detail |
---|
private MoriaController()
Method Detail |
---|
static void init() throws InoperableStateException
InoperableStateException
- If Moria is not ready for use.static void stop()
public static java.util.HashMap getStatus()
true
if the initController
method has been called, else false
.
true
if the
DirectoryManager.setConfig
method has been called, else
false
.
true
if the MoriaStore.setConfig
method has been called, else false
.
true
if the
AuthorizationManager.setConfig
method has been called,
else false
.
true
all the above are true (the controller is
ready to use).
HashMap
with all status fields for the
controller (init
,dm
,
sm
,am
and moria
).initController(javax.servlet.ServletContext)
,
DirectoryManager.setConfig(java.util.Properties)
,
MoriaStore.setConfig(java.util.Properties)
,
AuthorizationManager.setConfig(java.util.Properties)
public static java.lang.String attemptSingleSignOn(java.lang.String loginTicketId, java.lang.String ssoTicketId) throws UnknownTicketException, InoperableStateException, IllegalInputException, no.feide.moria.authorization.UnknownServicePrincipalException
loginTicketId
- The reference to the authentication attempt.ssoTicketId
- The SSO ticket received from the users browser.
UnknownTicketException
- If either the login ticket or the SSO ticket is invalid or
non-existing, the authetication attempt requires interactive
authentication, or the SSO ticket does not point to a cached
user data object with enough attributes.
InoperableStateException
- If the controller is not ready.
IllegalInputException
- If the loginTicketId
and/or
ssoTicketId
is null or empty.
no.feide.moria.authorization.UnknownServicePrincipalException
- If the service principal cannot be resolved, in which case
there is probably an issue with the Authentication Module
configuration.public static java.util.Map attemptLogin(java.lang.String loginTicketId, java.lang.String ssoTicketId, java.lang.String userId, java.lang.String password, boolean denySSO) throws UnknownTicketException, InoperableStateException, IllegalInputException, AuthenticationException, DirectoryUnavailableException, AuthorizationException
loginTicketId
.
A new cached userdata object is created and all cachable attributes are
stored in it. The existing SSO ticket is removed. After a successful
authentication a new service ticket, pointing to the same authentication
attempt, is created. A new SSO ticket is created, pointing to the cached
userdata object.
loginTicketId
- The ticket identifying the authentication attempt.ssoTicketId
- The ticket identifying the existing cached user data object.userId
- The user's userId.password
- The user's password.denySSO
- The user's SSO choice.
MoriaController.SSO_TICKET
and
MoiraController.LOGIN_TICKET
.
UnknownTicketException
- If the login ticket is invalid or does not exist.
InoperableStateException
- If the controller is not ready to be used, or the store
cannot be accessed.
IllegalInputException
- If any of loginTicketId
,userId
,
or password
are null
or an
empty string.
AuthenticationException
- If the authentication failed due to wrong credentials.
AuthorizationException
- If the user's organization is not allowed to use this service
DirectoryUnavailableException
- If the directory of the user's home organization is
unavailable.public static java.lang.String initiateAuthentication(java.lang.String[] attributes, java.lang.String returnURLPrefix, java.lang.String returnURLPostfix, boolean forceInteractiveAuthentication, java.lang.String servicePrincipal) throws AuthorizationException, IllegalInputException, InoperableStateException
attributes
- The requested attributes. Cannot be null
.returnURLPrefix
- Prefix of the redirect URL, used to direct the user back to
the web service. Cannot be null
or an empty
string.returnURLPostfix
- Postfix of the redirect URL, used to direct the user back to
the web service. Cannot be null
.forceInteractiveAuthentication
- If true
, do not use SSO.servicePrincipal
- The principal of the requesting service. Cannot be
null
or an empty string.
AuthorizationException
- If the service requests attributes it is not authorized to
receive.
IllegalInputException
- If attributes
or returnURLPostfix
is null
, or returnURLPrefix
or
servicePrincipal
is null
or an
empty string.
InoperableStateException
- If the controller is not yet ready for use, or if the store
cannot be accessed at this time.private static void authorizationCheck(java.lang.String servicePrincipal, java.lang.String[] attributes, java.lang.String operation) throws AuthorizationException
servicePrincipal
- The principal for the service performing the request. Must be
a non-empty string.attributes
- The requested attributes, if any.operation
- The requested operation. Must be a non-empty string.
AuthorizationException
- If the authorization failed, for some reason.
java.lang.IllegalArgumentException
- If servicePrincipal
is an empty string, or
operation
is unknown or null
.private static void organizationCheck(java.lang.String servicePrincipal, java.lang.String userOrganization) throws AuthorizationException
servicePrincipal
- The principal for the service performing the request.userOrganization
- The organization the user comes from. Must be a non-empty
string.
AuthorizationException
- If the user is not allowed to use this service.
java.lang.IllegalArgumentException
- If servicePrincipal
is an empty string.public static boolean isOrganizationAllowedForService(java.lang.String servicePrincipal, java.lang.String userOrganization) throws java.lang.IllegalArgumentException, no.feide.moria.authorization.UnknownServicePrincipalException
servicePrincipal
- The service's unique principal.userOrganization
- The home organization, in short form.
true
if users from this organization can access
this service.
java.lang.IllegalArgumentException
- If servicePrincipal
or
userOrganization
is null
or an
empty string.
no.feide.moria.authorization.UnknownServicePrincipalException
- If servicePrincipal
is unknown.public static java.lang.String[] getRequestedAttributes(java.lang.String loginTicket, java.lang.String servicePrincipal) throws IllegalInputException, UnknownTicketException, InoperableStateException, AuthorizationException
loginTicket
- the login ticketservicePrincipal
- the name of the service that requested the attributes
IllegalInputException
UnknownTicketException
InoperableStateException
AuthorizationException
public static java.util.Map getUserAttributes(java.lang.String serviceTicketId, java.lang.String servicePrincipal) throws IllegalInputException, UnknownTicketException, InoperableStateException, AuthorizationException
serviceTicketId
- The ticket associated with the authentication attempt. Cannot
be null
or an empty string.servicePrincipal
- The principal of the calling service. Cannot be
null
or an empty string.
Map
object containing the
requested user attributes, if found. Entries have a
String
key and a String[]
value.
AuthorizationException
- If userorg isn't set for ticket, userorg is denied access to
the service or service principal is unknown.
IllegalInputException
- If serviceTicketId
or
servicePrincipal
is null
or an
empty string.
UnknownTicketException
- If the service ticket does not exist in the store, or is
invalid.
InoperableStateException
- If Moria is not ready for use.public static java.util.Map directNonInteractiveAuthentication(java.lang.String[] requestedAttributes, java.lang.String userId, java.lang.String password, java.lang.String servicePrincipal) throws AuthorizationException, IllegalInputException, InoperableStateException, AuthenticationException, DirectoryUnavailableException
requestedAttributes
- The requested attributes.userId
- The user's username.password
- The user's password.servicePrincipal
- The principal (read: username) of the calling service.
String
(attribute name) as key and String[]
(user
attributes) as value.
AuthorizationException
- If the service is not allowed to perform this operation, or
if the user's organization does not allow the use of this
service.
IllegalInputException
- If requestedAttributes
is null
,
or userId
, password
, or
servicePrincipal
is null
or an
empty string.
InoperableStateException
- If Moria is not currently ready for use.
AuthenticationException
- If the authentication failed due to bad user credentials.
DirectoryUnavailableException
- If directory of the user's home organization is unavailable.public static java.util.Map proxyAuthentication(java.lang.String[] requestedAttributes, java.lang.String proxyTicketId, java.lang.String servicePrincipal) throws AuthorizationException, IllegalInputException, InoperableStateException, UnknownTicketException
requestedAttributes
- The requested attributes to retrieve.proxyTicketId
- The proxy ticket connected with the cached user data.servicePrincipal
- The principal of the requesting service.
String
(attribute name) as key and String[]
(user
attributes) as value.
AuthorizationException
- If the service is not allowed to perform this operation, or
if the user's organization does not allow the use of this
service.
IllegalInputException
- If requestedAttributes
is null, or
proxyTicketId
or servicePrincipal
is null
or an empty string.
InoperableStateException
- If the controller is not currently ready to use.
UnknownTicketException
- If the proxy ticket is invalid or does not exist.public static java.lang.String getProxyTicket(java.lang.String ticketGrantingTicket, java.lang.String proxyServicePrincipal, java.lang.String servicePrincipal) throws AuthorizationException, IllegalInputException, InoperableStateException, UnknownTicketException
ticketGrantingTicket
- The TGT to generate a proxy ticket for.proxyServicePrincipal
- The principal of the service that the proxy ticket is created
for.servicePrincipal
- The principal of the service requesting the ticket generation.
String
containing the proxy ticket.
AuthorizationException
- If the requesting service is not allowed to perform the
operation, or if the user's organization does not allow the
use of this service.
IllegalInputException
- If ticketGrantingTicket
,
proxyServicePrincipal
or
servicePrincipal
is null
or an
empty string.
InoperableStateException
- If Moria is not currently ready for use.
UnknownTicketException
- If the ticketGrantingTicket
is invalid or does
not exist, or userorg
is not set in ticket.public static boolean verifyUserExistence(java.lang.String userId, java.lang.String servicePrincipal) throws AuthorizationException, IllegalInputException, InoperableStateException, DirectoryUnavailableException
userId
- The username to verify.servicePrincipal
- The principal of the requesting service.
true
if the user exists, otherwise
false
.
AuthorizationException
- If the requesting service is not allowed to perform the
operation, or if the user's organization does not allow the
use of this service.
IllegalInputException
- If userId
or servicePrincipal
is null
or an empty string.
InoperableStateException
- If the controller is not currently ready to use.
DirectoryUnavailableException
- If the directory for the user is not available.public static void setConfig(java.lang.String module, java.util.Properties properties)
module
- Name of the module to set config for.properties
- The configuration to transfer to the module.ConfigurationManager.MODULE_AM
,
ConfigurationManager.MODULE_DM
,
ConfigurationManager.MODULE_SM
,
ConfigurationManager.MODULE_WEB
public static void initController(javax.servlet.ServletContext sc) throws InoperableStateException
sc
- The servletContext from the caller.
InoperableStateException
- if Moria is not ready for use.public static void stopController()
static boolean isLegalURL(java.lang.String url)
url
- The URL to validate.
true
if the URL is valid, else false
.
java.lang.IllegalArgumentException
- if url
is null
or an empty
string.URI
public static java.util.HashMap getServiceProperties(java.lang.String loginTicketId) throws UnknownTicketException, InoperableStateException, IllegalInputException
loginTicketId
- The login ticket associated with the authentication attempt.
Cannot be null
or an empty string.
UnknownTicketException
- If the ticket does not exist in the store, if the ticket is
invalid, or if the ticket does not correspond to a service.
InoperableStateException
- If the controller or the store is not ready to use.
IllegalInputException
- If loginTicketId
is null
or an
empty string.public static int getSecLevel(java.lang.String loginTicketId) throws UnknownTicketException, InoperableStateException
loginTicketId
- The ticket associated with the authentication attempt.
UnknownTicketException
- If the ticket does not exist, is invalid, or is not
associated with a service.
InoperableStateException
- If Moria is not usable.
java.lang.IllegalArgumentException
- If loginTicketId is null or empty.public static void invalidateSSOTicket(java.lang.String ssoTicketId) throws IllegalInputException, InoperableStateException
ssoTicketId
- The ticket to be invalidated.
IllegalInputException
- If ssoTicketId
is null or empty.
InoperableStateException
- If Moria is not ready to use.public static java.lang.String getRedirectURL(java.lang.String serviceTicketId) throws InoperableStateException, IllegalInputException, UnknownTicketException
serviceTicketId
- The service ticket to generate redirect URL for.
String
containing the URL.
InoperableStateException
- If Moria is not ready for use.
IllegalInputException
- If serviceTicketId
is null or empty.
UnknownTicketException
- If the service ticket is invalid or does not exist.public static java.lang.String getUserOrg(java.lang.String username) throws AuthenticationException
username
- The full username of a user. Must be a non-empty string.
String
containing the user's organization.
AuthenticationException
- If the user's organization is not found.
java.lang.IllegalArgumentException
- If username
is null
or an empty
string.private static final java.util.HashMap authenticate(java.lang.String sessionTicket, no.feide.moria.directory.Credentials userCredentials, java.lang.String[] attributeRequest) throws no.feide.moria.directory.backend.AuthenticationFailedException, no.feide.moria.directory.backend.BackendException, java.lang.IllegalStateException
sessionTicket
- The session ticket.userCredentials
- The user's credentials.attributeRequest
- The attribute request.
no.feide.moria.directory.backend.AuthenticationFailedException
- If authentication fails.
no.feide.moria.directory.backend.BackendException
- If the backend fails to authenticate/retrieve attributes.
java.lang.IllegalStateException
- If Moria2 is in an illegal state.DirectoryManager.authenticate(java.lang.String,
no.feide.moria.directory.Credentials, java.lang.String[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |