Package com.sun.identity.sm.flatfile
Class SMSFlatFileObjectBase
- java.lang.Object
-
- com.sun.identity.sm.SMSObject
-
- com.sun.identity.sm.SMSObjectDB
-
- com.sun.identity.sm.flatfile.SMSFlatFileObjectBase
-
- Direct Known Subclasses:
SMSEnhancedFlatFileObject,SMSFlatFileObject
public abstract class SMSFlatFileObjectBase extends SMSObjectDB
This is the base implementation of flat file data store object.
-
-
Field Summary
Fields Modifier and Type Field Description protected DebugmDebugprotected booleanmInitializedprotected StringmRootDirprotected FilemRootDirHandleprotected StringmRootDNprotected ReaderWriterLockmRWLock
-
Constructor Summary
Constructors Modifier Constructor Description protectedSMSFlatFileObjectBase()Constructor for SMSFlatFileObject.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringdecodeVal(String v)Decodes a value, %2C to comma and %25 to percent.voidderegisterCallbackHandler(String id)De-Register a listener.protected StringencodeVal(String v)Encodes special characters in a value.protected abstract Set<String>getSubEntries(String objName, String filter, String sidFilter, boolean isSubConfig, int numOfEntries, boolean sortResults, boolean ascendingOrder)Real routine to get sub entries, used by subEntries() and schemaSubEntries().protected voidinitialize()Initializes the SMSFlatFileObject: Gets the flat file directory and default organization DN from AMConfig.properties, creates the root directory if it does not exist.protected PropertiesloadProperties(File filehandle, String objName)Loads properties from the attribute file handle.protected voidmodifyValues(String objName, ModificationItem modItem, Properties props)StringregisterCallbackHandler(SSOToken token, SMSObjectListener changeListener)Register a listener.protected voidsaveProperties(Properties props, File filehandle, String header)Saves properties to the attributes file handle, with given objName in the file header.Set<String>schemaSubEntries(SSOToken token, String objName, String filter, String sidFilter, int numOfEntries, boolean sortResults, boolean ascendingOrder)Returns a Set of sub entry names that match the given filter and the given sun service id filter.Set<String>search(SSOToken token, String objName, String filter, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder)Search for a config object with the given filter.Iterator<SMSDataEntry>search(SSOToken token, String objName, String filter, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder, Set excludes)Search for a config object with the given filter.Set<String>searchOrganizationNames(SSOToken token, String objName, int numOfEntries, boolean sortResults, boolean ascendingOrder, String serviceName, String attrName, Set values)Returns the organization names.Set<String>searchSubOrgNames(SSOToken token, String objName, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder, boolean recursive)Returns the suborganization names.Set<String>subEntries(SSOToken token, String objName, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder)Returns a Set of sub-entry names that match the given filter.protected SettoValSet(String attrName, String vals)Converts a string of values from the attributes properties file to a Set, decoding special characters in each value.protected StringtoValString(Enumeration en)Converts an enumeration of values for an attribute into a string, encoding special characters in the values as necessary.protected StringtoValString(Set vals)Converts a Set of values for an attribute into a string, encoding special characters in the values as necessary.-
Methods inherited from class com.sun.identity.sm.SMSObjectDB
getAMSdkBaseDN, getRootSuffix
-
Methods inherited from class com.sun.identity.sm.SMSObject
cacheResults, create, debug, delete, entryExists, getAttributeNames, getNamingAttribute, getOrgNamingAttribute, getSearchFilter, getServiceIdSearchFilter, initialize, modify, read, registerCallbackHandler, shutdown
-
-
-
-
Field Detail
-
mRootDir
protected String mRootDir
-
mRootDirHandle
protected File mRootDirHandle
-
mRootDN
protected String mRootDN
-
mInitialized
protected boolean mInitialized
-
mDebug
protected Debug mDebug
-
mRWLock
protected ReaderWriterLock mRWLock
-
-
Constructor Detail
-
SMSFlatFileObjectBase
protected SMSFlatFileObjectBase() throws SMSExceptionConstructor for SMSFlatFileObject.- Throws:
SMSException
-
-
Method Detail
-
loadProperties
protected Properties loadProperties(File filehandle, String objName) throws SMSException
Loads properties from the attribute file handle.- Returns:
- Properties object of the configuration object.
- Throws:
ServiceNotFoundException- if the attributes file is not found.SMSException- if an IO error occurred while reading the attributes properties file.SchemaException- if a format error occurred while reading the attributes properties file.
-
saveProperties
protected void saveProperties(Properties props, File filehandle, String header) throws SMSException
Saves properties to the attributes file handle, with given objName in the file header.- Throws:
SMSException
-
toValString
protected String toValString(Set vals)
Converts a Set of values for an attribute into a string, encoding special characters in the values as necessary.
-
modifyValues
protected void modifyValues(String objName, ModificationItem modItem, Properties props)
-
toValString
protected String toValString(Enumeration en)
Converts an enumeration of values for an attribute into a string, encoding special characters in the values as necessary. This is used by the modify() method where the values needs to be in a particular order.
-
encodeVal
protected String encodeVal(String v)
Encodes special characters in a value. percent to %25 and comma to %2C.
-
toValSet
protected Set toValSet(String attrName, String vals)
Converts a string of values from the attributes properties file to a Set, decoding special characters in each value.
-
initialize
protected void initialize() throws SMSExceptionInitializes the SMSFlatFileObject: Gets the flat file directory and default organization DN from AMConfig.properties, creates the root directory if it does not exist.- Throws:
SMSException
-
subEntries
public Set<String> subEntries(SSOToken token, String objName, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException, SSOException
Returns a Set of sub-entry names that match the given filter.- Specified by:
subEntriesin classSMSObject- Parameters:
token- Ignored argument. Access check is assumed to have occurred before reaching this method.objName- Name of the configuration object to get sub entries for. Name is expected to be a dn.filter- Filter of sub entry names to get. Only the wildcard character '*' is currently supported.numOfEntries- Number of entries to return, or 0 to return all entries.sortResults- Whether to sort results. If true will return a Set that will return entries in a sorted order.ascendingOrder- Whether the sorted results should be in alphabetically ascending or decending order. This argument is ignored if sortResults is false.- Returns:
- Set of sub entry names that match the given filter, or an empty Set if the objName is not found or if no sub entries are found with the given filter.
- Throws:
IllegalArgumentException- if objName or filter is null or empty, or if numOfEntries is less than 0.SchemaException- if a sub directory name is not in the expected "ou=..." format.SMSExceptionSSOException
-
schemaSubEntries
public Set<String> schemaSubEntries(SSOToken token, String objName, String filter, String sidFilter, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException, SSOException
Returns a Set of sub entry names that match the given filter and the given sun service id filter.- Specified by:
schemaSubEntriesin classSMSObject- Parameters:
token- Ignored argument. Access check is assumed to have occurred before reaching this method.objName- Name of the configuration object to get sub entries for. Name is expected to be a dn.filter- Filter of sub entry names to get. Only the wildcard character '*' is currently supported.sidFilter- Filter of Sun Service ID for the sub entries.numOfEntries- Number of entries to return, or 0 to return all entries.sortResults- Whether to sort results. If true will return a Set that will return entries in a sorted order.ascendingOrder- Whether the sorted results should be in alphabetically ascending or decending order. This argument is ignored if sortResults is false.- Returns:
- Set of sub entry names that match the given filter and sun service id filter, or an empty Set if the objName is not found or if no sub entries are found with the given filters.
- Throws:
IllegalArgumentException- if objName or filter is null or empty, or if numOfEntries is less than 0.SchemaException- if a sub directory name is not in the expected "ou=..." format.SMSExceptionSSOException
-
search
public Iterator<SMSDataEntry> search(SSOToken token, String objName, String filter, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder, Set excludes) throws SSOException, SMSException
Search for a config object with the given filter. Do some cheating here - callers of this method only pass service name and version in the filter in a ldap filter format. So return entries matching service name and version in the filter.- Specified by:
searchin classSMSObject- Parameters:
token- Ignored argument. Access check is assumed to have occurred before reaching this method.objName- Name of the configuration object to begin search. Name is expected to be a dn.filter- Filter of service name and version. Expected to be in SMSEntry.FILTER_PATTERN_SERVICE format.numOfEntries- number of max entries, 0 means unlimitedtimeLimit- maximum number of seconds for the search to spend, 0 means unlimitedsortResults-trueto have result sorted.ascendingOrder-trueto have result sorted in ascending order.excludes- Set of DNs to excluded.- Returns:
- a Map of entries (dn's) that match the given filter.
- Throws:
IllegalArgumentException- if objName or filter is null or empty, or if filter is not in the expected format.SSOExceptionSMSException
-
search
public Set<String> search(SSOToken token, String objName, String filter, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder) throws SSOException, SMSException
Search for a config object with the given filter. Do some cheating here - callers of this method only pass service name and version in the filter in a ldap filter format. So return entries matching service name and version in the filter.- Specified by:
searchin classSMSObject- Parameters:
token- Ignored argument. Access check is assumed to have occurred before reaching this method.objName- Name of the configuration object to begin search. Name is expected to be a dn.filter- Filter of service name and version. Expected to be in SMSEntry.FILTER_PATTERN_SERVICE format.numOfEntries- number of max entries, 0 means unlimitedtimeLimit- maximum number of seconds for the search to spend, 0 means unlimitedsortResults-trueto have result sorted.ascendingOrder-trueto have result sorted in ascending order.- Returns:
- a Set of entries (dn's) that match the given filter.
- Throws:
IllegalArgumentException- if objName or filter is null or empty, or if filter is not in the expected format.SSOExceptionSMSException
-
searchSubOrgNames
public Set<String> searchSubOrgNames(SSOToken token, String objName, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder, boolean recursive) throws SMSException, SSOException
Returns the suborganization names. Returns a set of SMSEntry objects that are suborganization names. The paramternumOfEntriesidentifies the number of entries to return, if0returns all the entries.- Specified by:
searchSubOrgNamesin classSMSObject- Throws:
SMSExceptionSSOException
-
searchOrganizationNames
public Set<String> searchOrganizationNames(SSOToken token, String objName, int numOfEntries, boolean sortResults, boolean ascendingOrder, String serviceName, String attrName, Set values) throws SMSException, SSOException
Returns the organization names. Returns a set of SMSEntry objects that are organization names. The paramternumOfEntriesidentifies the number of entries to return, if0returns all the entries.- Specified by:
searchOrganizationNamesin classSMSObject- Throws:
SMSExceptionSSOException
-
registerCallbackHandler
public String registerCallbackHandler(SSOToken token, SMSObjectListener changeListener) throws SMSException, SSOException
Register a listener. Not yet implemented.- Throws:
SMSExceptionSSOException
-
deregisterCallbackHandler
public void deregisterCallbackHandler(String id)
De-Register a listener. Not yet implemented- Overrides:
deregisterCallbackHandlerin classSMSObject
-
getSubEntries
protected abstract Set<String> getSubEntries(String objName, String filter, String sidFilter, boolean isSubConfig, int numOfEntries, boolean sortResults, boolean ascendingOrder) throws SMSException
Real routine to get sub entries, used by subEntries() and schemaSubEntries().- Throws:
ServiceNotFoundException- if the configuration object is not found.SchemaException- if a sub directory name is not in the expected "ou=..." format.SMSException
-
-