Package org.apache.activemq.security
Class SimpleCachedLDAPAuthorizationMap
java.lang.Object
org.apache.activemq.security.SimpleCachedLDAPAuthorizationMap
- All Implemented Interfaces:
AuthorizationMap
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classListener implementation for directory changes that maps change events to destination types.protected static enumprotected static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DirContextprotected Map<org.apache.activemq.command.ActiveMQDestination,AuthorizationEntry> protected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidapplyAcl(AuthorizationEntry entry, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType, Set<Object> acls) Applies policy to the entry given the actual principals that will be applied to the policy entry.protected voidapplyACL(AuthorizationEntry entry, SearchResult result, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Applies the policy from the directory to the given entry within the context of the provided permission type.protected voidPerforms a check for updates from the server in the event that synchronous updates are enabled and are the refresh interval has elapsed.protected DirContextvoiddestroy()protected org.apache.activemq.command.ActiveMQDestinationformatDestination(LdapName dn, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Parses a DN into the equivalentActiveMQDestination.protected org.apache.activemq.command.ActiveMQDestinationformatDestination(Rdn destinationName, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Parses RDN values representing the destination name/pattern and destination type into the equivalentActiveMQDestination.protected StringformatDestinationName(Rdn destinationName) Parses the RDN representing a destination name/pattern into the standard string representation of the name/pattern.getAdminACLs(org.apache.activemq.command.ActiveMQDestination destination) Provides synchronized access to the admin ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.protected AuthorizationEntrygetEntry(DefaultAuthorizationMap map, LdapName dn, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Retrieves or creates theAuthorizationEntrythat corresponds to the DN indn.protected StringReturns the filter string for the given permission type.protected intReturns the DN prefix size based on the given destination type.getReadACLs(org.apache.activemq.command.ActiveMQDestination destination) Provides synchronized access to the read ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.intProvides synchronized and defensive access to the admin ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.Provides synchronized and defensive access to the read ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.Provides synchronized and defensive access to the write ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.getWriteACLs(org.apache.activemq.command.ActiveMQDestination destination) Provides synchronized access to the write ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.protected booleanbooleanbooleanvoidnamingExceptionThrown(NamingExceptionEvent namingExceptionEvent) Handler for exception events from the registry.voidobjectAdded(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for new policy entries in the directory.voidobjectChanged(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for changed policy entries in the directory.voidobjectRemoved(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for removed policy entries in the directory.voidobjectRenamed(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for renamed policy entries in the directory.protected DirContextopen()Returns the existing open context or creates a new one and registers listeners for push notifications if such an update style is enabled.protected voidprocessQueryResults(DefaultAuthorizationMap map, NamingEnumeration<SearchResult> results, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Processes results from a directory query in the context of a given destination type and permission type.protected voidquery()Queries the directory and initializes the policy based on the data in the directory.voidsetAdminPermissionGroupSearchFilter(String adminPermissionGroupSearchFilter) voidsetAuthentication(String authentication) voidsetConnectionPassword(String connectionPassword) voidsetConnectionProtocol(String connectionProtocol) voidsetConnectionURL(String connectionURL) voidsetConnectionUsername(String connectionUsername) voidsetGroupClass(String groupClass) voidsetGroupNameAttribute(String groupNameAttribute) voidsetGroupObjectClass(String groupObjectClass) voidsetLegacyGroupMapping(boolean legacyGroupMapping) voidsetPermissionGroupMemberAttribute(String permissionGroupMemberAttribute) voidsetQueueSearchBase(String queueSearchBase) voidsetReadPermissionGroupSearchFilter(String readPermissionGroupSearchFilter) voidsetRefreshDisabled(boolean refreshDisabled) voidsetRefreshInterval(int refreshInterval) voidsetTempSearchBase(String tempSearchBase) voidsetTopicSearchBase(String topicSearchBase) voidsetUserNameAttribute(String userNameAttribute) voidsetUserObjectClass(String userObjectClass) voidsetWritePermissionGroupSearchFilter(String writePermissionGroupSearchFilter) protected <T> Set<T>transcribeSet(Set<T> source) Transcribes an existing set into a new set.protected voidupdated()Marks the time at which the authorization state was last refreshed.
-
Field Details
-
groupClass
-
context
-
entries
-
-
Constructor Details
-
SimpleCachedLDAPAuthorizationMap
public SimpleCachedLDAPAuthorizationMap()
-
-
Method Details
-
createContext
- Throws:
NamingException
-
isContextAlive
protected boolean isContextAlive() -
open
Returns the existing open context or creates a new one and registers listeners for push notifications if such an update style is enabled. This implementation should not be invoked concurrently.- Returns:
- the current context
- Throws:
NamingException- if there is an error setting things up
-
query
Queries the directory and initializes the policy based on the data in the directory. This implementation should not be invoked concurrently.- Throws:
Exception- if there is an unrecoverable error processing the directory contents
-
processQueryResults
protected void processQueryResults(DefaultAuthorizationMap map, NamingEnumeration<SearchResult> results, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) throws Exception Processes results from a directory query in the context of a given destination type and permission type. This implementation should not be invoked concurrently.- Parameters:
results- the results to processdestinationType- the type of the destination for which the directory results applypermissionType- the type of the permission for which the directory results apply- Throws:
Exception- if there is an error processing the results
-
updated
protected void updated()Marks the time at which the authorization state was last refreshed. Relevant for synchronous policy updates. This implementation should not be invoked concurrently. -
getEntry
protected AuthorizationEntry getEntry(DefaultAuthorizationMap map, LdapName dn, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Retrieves or creates theAuthorizationEntrythat corresponds to the DN indn. This implementation should not be invoked concurrently.- Parameters:
map- the DefaultAuthorizationMap to operate on.dn- the DN representing the policy entry in the directorydestinationType- the type of the destination to get/create the entry for- Returns:
- the corresponding authorization entry for the DN
- Throws:
IllegalArgumentException- if destination type is not one ofSimpleCachedLDAPAuthorizationMap.DestinationType.QUEUE,SimpleCachedLDAPAuthorizationMap.DestinationType.TOPIC,SimpleCachedLDAPAuthorizationMap.DestinationType.TEMPor if the policy entry DN is malformed
-
applyACL
protected void applyACL(AuthorizationEntry entry, SearchResult result, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) throws NamingException Applies the policy from the directory to the given entry within the context of the provided permission type.- Parameters:
entry- the policy entry to apply the policy toresult- the results from the directory to apply to the policy entrypermissionType- the permission type of the data in the directory- Throws:
NamingException- if there is an error applying the ACL
-
applyAcl
protected void applyAcl(AuthorizationEntry entry, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType, Set<Object> acls) Applies policy to the entry given the actual principals that will be applied to the policy entry.- Parameters:
entry- the policy entry to which the policy should be appliedpermissionType- the type of the permission that the policy will be applied toacls- the principals that represent the actual policy
-
formatDestination
protected org.apache.activemq.command.ActiveMQDestination formatDestination(LdapName dn, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Parses a DN into the equivalentActiveMQDestination. The default implementation expects a format of cn=,ou= ,.... or ou= ,.... for permission and destination entries, respectively. For example cn=admin,ou=$,ou=...orou=$,ou=....- Parameters:
dn- the DN to parsedestinationType- the type of the destination that we are parsing- Returns:
- the destination that the DN represents
- Throws:
IllegalArgumentException- ifdestinationTypeisSimpleCachedLDAPAuthorizationMap.DestinationType.TEMPor if the format ofdnis incorrect for for a topic or queue- See Also:
-
formatDestination
protected org.apache.activemq.command.ActiveMQDestination formatDestination(Rdn destinationName, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Parses RDN values representing the destination name/pattern and destination type into the equivalentActiveMQDestination.- Parameters:
destinationName- the RDN representing the name or pattern for the destinationdestinationType- the type of the destination- Returns:
- the destination that the RDN represent
- Throws:
IllegalArgumentException- ifdestinationTypeis not one ofSimpleCachedLDAPAuthorizationMap.DestinationType.TOPICorSimpleCachedLDAPAuthorizationMap.DestinationType.QUEUE.- See Also:
-
formatDestinationName
Parses the RDN representing a destination name/pattern into the standard string representation of the name/pattern. This implementation does not care about the type of the RDN such that the RDN could be a CN or OU.- Parameters:
destinationName- the RDN representing the name or pattern for the destination- See Also:
-
#formatDestination(Rdn, Rdn)
-
transcribeSet
Transcribes an existing set into a new set. Used to make defensive copies for concurrent access.- Parameters:
source- the source set ornull- Returns:
- a new set containing the same elements as
sourceornullifsourceisnull
-
getFilterForPermissionType
protected String getFilterForPermissionType(SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Returns the filter string for the given permission type.- Throws:
IllegalArgumentException- ifpermissionTypeis not supported- See Also:
-
getPrefixLengthForDestinationType
protected int getPrefixLengthForDestinationType(SimpleCachedLDAPAuthorizationMap.DestinationType destinationType) Returns the DN prefix size based on the given destination type.- Throws:
IllegalArgumentException- ifdestinationTypeis not supported- See Also:
-
checkForUpdates
protected void checkForUpdates()Performs a check for updates from the server in the event that synchronous updates are enabled and are the refresh interval has elapsed. -
getTempDestinationAdminACLs
Provides synchronized and defensive access to the admin ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.- Specified by:
getTempDestinationAdminACLsin interfaceAuthorizationMap
-
getTempDestinationReadACLs
Provides synchronized and defensive access to the read ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.- Specified by:
getTempDestinationReadACLsin interfaceAuthorizationMap
-
getTempDestinationWriteACLs
Provides synchronized and defensive access to the write ACLs for temp destinations as the super implementation returns live copies of the ACLs andAuthorizationEntryis not setup for concurrent access.- Specified by:
getTempDestinationWriteACLsin interfaceAuthorizationMap
-
getAdminACLs
Provides synchronized access to the admin ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.- Specified by:
getAdminACLsin interfaceAuthorizationMap
-
getReadACLs
Provides synchronized access to the read ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.- Specified by:
getReadACLsin interfaceAuthorizationMap
-
getWriteACLs
Provides synchronized access to the write ACLs for the destinations asAuthorizationEntryis not setup for concurrent access.- Specified by:
getWriteACLsin interfaceAuthorizationMap
-
objectAdded
public void objectAdded(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for new policy entries in the directory.- Parameters:
namingEvent- the new entry event that occurreddestinationType- the type of the destination to which the event appliespermissionType- the permission type to which the event applies
-
objectRemoved
public void objectRemoved(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for removed policy entries in the directory.- Parameters:
namingEvent- the removed entry event that occurreddestinationType- the type of the destination to which the event appliespermissionType- the permission type to which the event applies
-
objectRenamed
public void objectRenamed(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for renamed policy entries in the directory. This handler deals with the renaming of destination entries as well as permission entries. If the permission type is not null, it is assumed that we are dealing with the renaming of a permission entry. Otherwise, it is assumed that we are dealing with the renaming of a destination entry.- Parameters:
namingEvent- the renaming entry event that occurreddestinationType- the type of the destination to which the event appliespermissionType- the permission type to which the event applies
-
objectChanged
public void objectChanged(NamingEvent namingEvent, SimpleCachedLDAPAuthorizationMap.DestinationType destinationType, SimpleCachedLDAPAuthorizationMap.PermissionType permissionType) Handler for changed policy entries in the directory.- Parameters:
namingEvent- the changed entry event that occurreddestinationType- the type of the destination to which the event appliespermissionType- the permission type to which the event applies
-
namingExceptionThrown
Handler for exception events from the registry.- Parameters:
namingExceptionEvent- the exception event
-
afterPropertiesSet
- Throws:
Exception
-
destroy
- Throws:
Exception
-
getConnectionURL
-
setConnectionURL
-
getConnectionUsername
-
setConnectionUsername
-
getConnectionPassword
-
setConnectionPassword
-
getConnectionProtocol
-
setConnectionProtocol
-
getAuthentication
-
setAuthentication
-
getQueueSearchBase
-
setQueueSearchBase
-
getTopicSearchBase
-
setTopicSearchBase
-
getTempSearchBase
-
setTempSearchBase
-
getPermissionGroupMemberAttribute
-
setPermissionGroupMemberAttribute
-
getAdminPermissionGroupSearchFilter
-
setAdminPermissionGroupSearchFilter
-
getReadPermissionGroupSearchFilter
-
setReadPermissionGroupSearchFilter
-
getWritePermissionGroupSearchFilter
-
setWritePermissionGroupSearchFilter
-
isLegacyGroupMapping
public boolean isLegacyGroupMapping() -
setLegacyGroupMapping
public void setLegacyGroupMapping(boolean legacyGroupMapping) -
getGroupObjectClass
-
setGroupObjectClass
-
getUserObjectClass
-
setUserObjectClass
-
getGroupNameAttribute
-
setGroupNameAttribute
-
getUserNameAttribute
-
setUserNameAttribute
-
isRefreshDisabled
public boolean isRefreshDisabled() -
setRefreshDisabled
public void setRefreshDisabled(boolean refreshDisabled) -
getRefreshInterval
public int getRefreshInterval() -
setRefreshInterval
public void setRefreshInterval(int refreshInterval) -
getGroupClass
-
setGroupClass
-