com.metamatrix.platform.security.membership.service
Class MembershipServiceImpl

java.lang.Object
  extended by com.metamatrix.platform.service.controller.AbstractService
      extended by com.metamatrix.platform.security.membership.service.MembershipServiceImpl
All Implemented Interfaces:
EventObjectListener, MembershipServiceInterface, ServiceInterface, java.util.EventListener

public class MembershipServiceImpl
extends AbstractService
implements MembershipServiceInterface

This class serves as the primary implementation of the Membership Service, and logically consists of a set of one or more MembershipDomainInterface instances. The Service is responsible for creating and intializing the set of domains, receiving requests from clients, and determining which domain or domains are to handle those requests.


Field Summary
 
Fields inherited from interface com.metamatrix.platform.security.api.service.MembershipServiceInterface
ADMIN_PASSWORD, ADMIN_USERNAME, DEFAULT_ADMIN_USERNAME, DEFAULT_WSDL_USERNAME, DOMAIN_ACTIVE, DOMAIN_NAME, DOMAIN_ORDER, DOMAIN_PROPERTIES, NAME, SECURITY_ENABLED
 
Fields inherited from interface com.metamatrix.platform.service.api.ServiceInterface
WAIT_TO_DIE_TIME
 
Constructor Summary
MembershipServiceImpl()
           
 
Method Summary
 AuthenticationToken authenticateUser(java.lang.String username, Credentials credential, java.io.Serializable trustedPayload, java.lang.String applicationName)
          Authenticate a user with the specified username and credential for use with the specified application.
protected  void closeService()
          Close the service to new work if applicable.
 java.util.List getDomainNames()
           
protected  java.util.List getDomains()
           
 java.util.Set getGroupNames()
          Obtain the collection of group names.
 java.util.Set getGroupsForDomain(java.lang.String domainName)
           
 java.util.Set getGroupsForUser(java.lang.String userName)
          Obtain the set of groups to which this user belongs to.
 MetaMatrixPrincipal getPrincipal(MetaMatrixPrincipalName principal)
          Obtain the principal object that is representative of the principal
protected  void initService(java.util.Properties env)
          Perform initialization and commence processing.
 boolean isSecurityEnabled()
           
 boolean isSuperUser(java.lang.String username)
           
 boolean isWsdlUser(java.lang.String username)
           
protected  void killService()
          Terminate all processing and reclaim resources.
static java.util.Properties loadFile(java.lang.String fileName, java.lang.Class clazz)
          Loads the given file by searching multiple loading mechanisms
 java.lang.String toString()
          Display contents of this membership service by outputting all its domains.
protected  void waitForServiceToClear()
          Wait until the service has completed all outstanding work.
 
Methods inherited from class com.metamatrix.platform.service.controller.AbstractService
checkState, die, dieNow, getCurrentState, getDeployedComponentID, getHostname, getID, getInitException, getInstanceName, getProcessName, getProperties, getQueueStatistics, getQueueStatistics, getResourceName, getServiceName, getServiceType, getStartTime, getStateChangeTime, init, isAlive, isClosed, isInitialized, isOpen, processEvent, registerForEvents, setInitException, unregisterForEvents, updateState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.metamatrix.platform.service.api.ServiceInterface
checkState, die, dieNow, getCurrentState, getHostname, getID, getInitException, getProcessName, getProperties, getQueueStatistics, getQueueStatistics, getServiceType, getStartTime, getStateChangeTime, init, isAlive, setInitException, updateState
 

Constructor Detail

MembershipServiceImpl

public MembershipServiceImpl()
Method Detail

initService

protected void initService(java.util.Properties env)
Perform initialization and commence processing. This method is called only once.

Note: In order to perform the chaining of membership domains, this method assumes there exists a property in the given environment properties named DOMAIN_ORDER that has an ordered value in the form of "A, X, ..., D"

Specified by:
initService in class AbstractService

closeService

protected void closeService()
                     throws java.lang.Exception
Close the service to new work if applicable. After this method is called the service should no longer accept new work to perform but should continue to process any outstanding work. This method is called by die().

Specified by:
closeService in class AbstractService
Throws:
java.lang.Exception

waitForServiceToClear

protected void waitForServiceToClear()
                              throws java.lang.Exception
Wait until the service has completed all outstanding work. This method is called by die() just before calling dieNow().

Specified by:
waitForServiceToClear in class AbstractService
Throws:
java.lang.Exception

killService

protected void killService()
Terminate all processing and reclaim resources. This method is called by dieNow() and is only called once.

Specified by:
killService in class AbstractService

authenticateUser

public AuthenticationToken authenticateUser(java.lang.String username,
                                            Credentials credential,
                                            java.io.Serializable trustedPayload,
                                            java.lang.String applicationName)
Authenticate a user with the specified username and credential for use with the specified application. The application name may also be used by the Membership Service to determine the appropriate authentication mechanism.

This method iterates through the domains and, on each domain, attempts to authenticate the principal with the specified credentials. Authentication is successful upon the first domain encountered that authenticates the principals.

Specified by:
authenticateUser in interface MembershipServiceInterface
Parameters:
username -
credential -
trustedPayload -
applicationName -
Returns:
Throws:
MetaMatrixSecurityException
MembershipServiceException

getPrincipal

public MetaMatrixPrincipal getPrincipal(MetaMatrixPrincipalName principal)
                                 throws MembershipServiceException,
                                        InvalidPrincipalException
Obtain the principal object that is representative of the principal

Specified by:
getPrincipal in interface MembershipServiceInterface
Parameters:
principalName -
type -
Returns:
Throws:
MetaMatrixSecurityException
InvalidPrincipalException
MembershipServiceException

getGroupsForUser

public java.util.Set getGroupsForUser(java.lang.String userName)
                               throws MembershipServiceException,
                                      InvalidPrincipalException
Obtain the set of groups to which this user belongs to. The result will come from the first domain that has the specified user.

Specified by:
getGroupsForUser in interface MembershipServiceInterface
Returns:
a set of Strings
Throws:
MembershipServiceException
InvalidPrincipalException

toString

public java.lang.String toString()
Display contents of this membership service by outputting all its domains.

Overrides:
toString in class java.lang.Object

getGroupNames

public java.util.Set getGroupNames()
                            throws MembershipServiceException
Description copied from interface: MembershipServiceInterface
Obtain the collection of group names.

Specified by:
getGroupNames in interface MembershipServiceInterface
Throws:
MembershipServiceException
See Also:
MembershipServiceInterface.getGroupNames()

getDomains

protected java.util.List getDomains()
Returns:
Returns the domains.

getDomainNames

public java.util.List getDomainNames()
Specified by:
getDomainNames in interface MembershipServiceInterface

getGroupsForDomain

public java.util.Set getGroupsForDomain(java.lang.String domainName)
                                 throws MembershipServiceException
Specified by:
getGroupsForDomain in interface MembershipServiceInterface
Throws:
MembershipServiceException

isSuperUser

public boolean isSuperUser(java.lang.String username)
Specified by:
isSuperUser in interface MembershipServiceInterface

isWsdlUser

public boolean isWsdlUser(java.lang.String username)

isSecurityEnabled

public boolean isSecurityEnabled()
                          throws MembershipServiceException
Specified by:
isSecurityEnabled in interface MembershipServiceInterface
Throws:
MembershipServiceException
See Also:
MembershipServiceInterface.isSecurityEnabled()

loadFile

public static java.util.Properties loadFile(java.lang.String fileName,
                                            java.lang.Class clazz)
                                     throws ServiceStateException
Loads the given file by searching multiple loading mechanisms

Parameters:
fileName -
clazz -
Returns:
Throws:
ServiceStateException


Copyright © 2009. All Rights Reserved.