|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.feide.moria.authorization.AuthorizationManager
public final class AuthorizationManager
The AuthorizationManager class is used to parse and store authorization data.
The authorization data source is XML which is passed as a properties object
through the setConfig method. The config data must contain information about
every web service allowed to access Moria, and which attributes, operations
and subsystems the service can access.
When a new set of data arrives, the authorization manager parses it and
replaces the old dataset if the parsing was successful. The authorization
manager can then be used to answer authorization questions, most likely from
the Moria controller.
When the controller receives a request, it asks the authorization manager if
the web service is authorized to perform the request. Every request includes
the service principal.
Field Summary | |
---|---|
private boolean |
activated
True if the authorization manager is ready to be used. |
private java.util.HashMap |
authzClients
List of client authorization objects. |
private java.util.HashSet |
cachableAttributes
List of attributes that is allowed to be cached. |
private no.feide.moria.log.MessageLogger |
messageLogger
For logging of error messages that cannot be sent to the calling layer. |
Constructor Summary | |
---|---|
AuthorizationManager()
|
Method Summary | |
---|---|
boolean |
allowAccessTo(java.lang.String servicePrincipal,
java.lang.String[] requestedAttributes)
Validates a request for access to attributes for a given client/service. |
boolean |
allowOperations(java.lang.String servicePrincipal,
java.lang.String[] requestedOperations)
Validates a request for access to operations for a given client/service. |
boolean |
allowSSOForAttributes(java.lang.String servicePrincipal,
java.lang.String[] requestedAttributes)
Validates a request for access to SSO for a given client/service. |
boolean |
allowUserorg(java.lang.String servicePrincipal,
java.lang.String userorg)
Checks if the organization is allowed to use the service. |
java.util.HashSet |
getAttributes(java.lang.String servicePrincipal)
Returns the configured attributes for a given service. |
private AuthorizationClient |
getAuthzClient(java.lang.String servicePrincipal)
Returns a client object for a given identifier. |
java.util.HashSet |
getCachableAttributes()
Returns the set of SSO attributes names (the attributes that can be cached). |
private static java.lang.String |
getChildContent(org.jdom.Element element,
java.lang.String childName)
Retrieves the content of an XML element. |
java.lang.String[] |
getNonSSOAttributeNames(java.lang.String servicePrincipal)
Get the list of attribute names not allowed for use in an SSO context for a given service. |
java.util.HashSet |
getOperations(java.lang.String servicePrincipal)
Returns the configured operations for a given service. |
java.util.HashSet |
getOrgsAllowed(java.lang.String servicePrincipal)
Returns the organizations that can use this service. |
int |
getSecLevel(java.lang.String servicePrincipal,
java.lang.String[] requestedAttributes)
Returns the security level for a set of attributes for a given service. |
java.util.HashMap |
getServiceProperties(java.lang.String servicePrincipal)
Returns the service properties for a given service. |
java.util.HashSet |
getSubsystems(java.lang.String servicePrincipal)
Returns the configured subsystems for a given service. |
(package private) static AuthorizationAttribute |
parseAttributeElem(org.jdom.Element element)
Parses an XML element and creates an AuthorizationAttribute object in return. |
(package private) static java.util.HashMap |
parseAttributesElem(org.jdom.Element element)
Parses the content of an Attributes element. |
(package private) static java.lang.String |
parseChildElem(org.jdom.Element element)
Parses 'operation' and 'organization' elements and returns the name attribute. |
(package private) static AuthorizationClient |
parseClientElem(org.jdom.Element element)
Creates an AuthorizationClient object based on the supplied XML element. |
(package private) static java.util.HashSet |
parseListElem(org.jdom.Element element)
Parses the content of an Attributes element. |
(package private) static java.util.HashMap |
parseRootElem(org.jdom.Element element)
Parses a configuration root element with client elements. |
(package private) void |
setAuthzClients(java.util.HashMap newClients)
Swaps the old client database with the supplied HashMap. |
void |
setConfig(java.util.Properties properties)
Sets the configuration data for this manager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final no.feide.moria.log.MessageLogger messageLogger
private java.util.HashMap authzClients
private java.util.HashSet cachableAttributes
private boolean activated
Constructor Detail |
---|
public AuthorizationManager()
Method Detail |
---|
static AuthorizationAttribute parseAttributeElem(org.jdom.Element element) throws IllegalConfigException
element
- The XML element to parse.
element
.
IllegalConfigException
- If the element's sso attribute is not true
or
false
.
java.lang.IllegalArgumentException
- If the AuthorizationAttribute
constructor
throws an exception.static java.util.HashMap parseAttributesElem(org.jdom.Element element) throws IllegalConfigException
element
- The DOM element that contains Attribute
child
elements.
IllegalConfigException
- If element
is not of type
Attributes
.
java.lang.IllegalArgumentException
- If element
is null
.static java.lang.String parseChildElem(org.jdom.Element element) throws IllegalConfigException
element
- The operation element.
IllegalConfigException
- If the element is not of type Operation
,
Subsystem
or Organization
OR
element's name
attribute is not set.
java.lang.IllegalArgumentException
- If element
is null
or an empty
string.static java.util.HashSet parseListElem(org.jdom.Element element) throws IllegalConfigException
element
- The DOM element that contains Attribute child elements.
IllegalConfigException
- If element is not of type Operations
,
Affiliation
, Subsystems
or
OrgsAllowed
.
java.lang.IllegalArgumentException
- If element
is null
.static AuthorizationClient parseClientElem(org.jdom.Element element) throws IllegalConfigException
element
- The XML element representing the client service.
IllegalConfigException
- If the name
attribute is not set for the given
element, or if any of the following tags are missing:
- DisplayName
- URL
- Language
- Home
- Attributes
- Operations
- Affiliation
- OrgsAllowed
java.lang.IllegalArgumentException
- If element
is null
.static java.util.HashMap parseRootElem(org.jdom.Element element) throws IllegalConfigException
element
- The root element.
IllegalConfigException
- If the element is not of type
ClientAuthorizationConfig
.
java.lang.IllegalArgumentException
- If element
is null
.AuthorizationClient
private static java.lang.String getChildContent(org.jdom.Element element, java.lang.String childName) throws IllegalConfigException
element
- Parent element.childName
- Name of the child node.
IllegalConfigException
- If the content of the child element is null.private AuthorizationClient getAuthzClient(java.lang.String servicePrincipal)
servicePrincipal
- The client object identifier.
NoConfigException
- If the authorization manager is not activated.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.public boolean allowAccessTo(java.lang.String servicePrincipal, java.lang.String[] requestedAttributes) throws UnknownServicePrincipalException
servicePrincipal
- The identifier of the client.requestedAttributes
- The list of requested attributes.
UnknownServicePrincipalException
- If the service principal does not exist.public boolean allowSSOForAttributes(java.lang.String servicePrincipal, java.lang.String[] requestedAttributes) throws UnknownServicePrincipalException
servicePrincipal
- The identifier of the client.requestedAttributes
- The list of requested attributes.
UnknownServicePrincipalException
- If the service principal does not exist.public boolean allowOperations(java.lang.String servicePrincipal, java.lang.String[] requestedOperations) throws UnknownServicePrincipalException
servicePrincipal
- The identifier of the client.requestedOperations
- The list of requested operations.
UnknownServicePrincipalException
- If the servicePrincipal does not exist.public boolean allowUserorg(java.lang.String servicePrincipal, java.lang.String userorg) throws UnknownServicePrincipalException
servicePrincipal
- The identifier of the client.userorg
- The user's organization.
UnknownServicePrincipalException
- If the servicePrincipal does not exist.void setAuthzClients(java.util.HashMap newClients)
newClients
- The new client database.
java.lang.IllegalArgumentException
- If newClients
is null
.public void setConfig(java.util.Properties properties)
properties
- The properties containing the authorization database.
java.lang.IllegalArgumentException
- If properties
is null
.public java.util.HashMap getServiceProperties(java.lang.String servicePrincipal) throws UnknownServicePrincipalException
servicePrincipal
- The principal of the service.
UnknownServicePrincipalException
- If the service principal does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.AuthorizationClient.getProperties()
public int getSecLevel(java.lang.String servicePrincipal, java.lang.String[] requestedAttributes) throws UnknownServicePrincipalException, UnknownAttributeException
servicePrincipal
- The service principal of the requested service.requestedAttributes
- The requested attributes.
UnknownServicePrincipalException
- If the service principal does not exist.
UnknownAttributeException
- If one or more of the requested attributes does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string, or if requestedAttributes
is
null
.AuthorizationClient.getSecLevel(java.lang.String[])
public java.util.HashSet getAttributes(java.lang.String servicePrincipal) throws UnknownServicePrincipalException
servicePrincipal
- The principal of the requested service.
UnknownServicePrincipalException
- If the servicePrincipal does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.AuthorizationClient.getAttributes()
public java.util.HashSet getOrgsAllowed(java.lang.String servicePrincipal) throws UnknownServicePrincipalException
servicePrincipal
- The principal of the requested service.
UnknownServicePrincipalException
- If the servicePrincipal does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.AuthorizationClient.getOrgsAllowed()
public java.util.HashSet getSubsystems(java.lang.String servicePrincipal) throws UnknownServicePrincipalException
servicePrincipal
- The principal of the requested service,
UnknownServicePrincipalException
- If the servicePrincipal does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.AuthorizationClient.getSubsystems()
public java.util.HashSet getOperations(java.lang.String servicePrincipal) throws UnknownServicePrincipalException
servicePrincipal
- The principal of the requested service.
UnknownServicePrincipalException
- If the servicePrincipal does not exist.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.AuthorizationClient.getOperations()
public java.util.HashSet getCachableAttributes()
public java.lang.String[] getNonSSOAttributeNames(java.lang.String servicePrincipal) throws UnknownServicePrincipalException, java.lang.IllegalArgumentException
servicePrincipal
- The service principal. Must be a non-empty string.
null
.
UnknownServicePrincipalException
- If the servicePrincipal
is unknown.
java.lang.IllegalArgumentException
- If servicePrincipal
is null
or
an empty string.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |