8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: SMSObject.java,v 1.9 2009/10/28 04:24:26 hengming Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington * Portions Copyrighted 2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.sm;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOToken;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.debug.Debug;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Iterator;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport javax.naming.directory.ModificationItem;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Abstract class that needs to be implemented to store configuration data in a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * data store. An implementation of this can be configured via
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>AMConfig.properties</code> by setting the property <code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * com.sun.identity.sm.sms_object_class_name</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to the fully qualified class name (i.e., including the package name) without
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the <code>.class</code> extension. Only one instance of this class will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * instantiated within a single JVM, hence the function must be reentrant. The
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * implementation of this class must provide an empty constructor that will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * used to create an instance of this class.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic abstract class SMSObject {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Initialization parameters that are configured via system properties or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * can be dynamically set during run-time.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void initialize(Map initParams) throws SMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Reads in the object from persistent store. It assumes the object name and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the ssoToken are valid. If the entry does not exist the method should
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * return <code>null</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Map<String, Set<String>> read(SSOToken token, String objName)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates an entry in the persistent store. Throws an exception if the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * entry already exists
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract void create(SSOToken token, String objName, Map attributes)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Modifies the attributes to the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract void modify(SSOToken token, String objName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ModificationItem[] mods) throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Delete the entry in the datastore. This should delete sub-entries also
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract void delete(SSOToken token, String objName)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the suborganization names. Returns a set of SMSEntry objects that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * are suborganization names. The paramter <code>numOfEntries</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identifies the number of entries to return, if <code>0</code> returns
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * all the entries.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Set<String> searchSubOrgNames(SSOToken token, String dn,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String filter, int numOfEntries, boolean sortResults,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean ascendingOrder, boolean recursive) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the organization names. Returns a set of SMSEntry objects that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * are organization names. The paramter <code>numOfEntries</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * identifies the number of entries to return, if <code>0</code> returns
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * all the entries.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Set<String> searchOrganizationNames(SSOToken token, String dn,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, boolean sortResults, boolean ascendingOrder,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String serviceName, String attrName, Set values)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the sub-entries. Returns a set of SMSEntry objects that are
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * sub-entries. The paramter <code>numOfEntries</code> identifies the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * number of entries to return, if <code>0</code> returns all the entries.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Set<String> subEntries(SSOToken token, String dn, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, boolean sortResults, boolean ascendingOrder)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the sub-entries. Returns a set of SMSEntry objects that are
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * sub-entries. The paramter <code>numOfEntries</code> identifies the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * number of entries to return, if <code>0</code> returns all the entries.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Set<String> schemaSubEntries(SSOToken token, String dn,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String filter, String sidFilter, int numOfEntries,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean sortResults, boolean ascendingOrder) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Searchs the data store for objects that match the filter
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Set<String> search(SSOToken token, String startDN, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, int timeLimit, boolean sortResults,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean ascendingOrder) throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Searchs the data store for objects that match the filter
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public abstract Iterator<SMSDataEntry> search(SSOToken token, String startDN,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String filter, int numOfEntries, int timeLimit, boolean sortResults,
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington boolean ascendingOrder, Set<String> excludes) throws SMSException, SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if the provided DN exists. Used by PolicyManager.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract boolean entryExists(SSOToken token, String objName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Registration of Notification Callbacks
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void registerCallbackHandler(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSObjectListener changeListener) throws SMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // default implementation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * De-Registration of Notification Callbacks
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void deregisterCallbackHandler(String listenerID) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // default implementation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the root suffix (i.e., base DN) for the SMS objects. All
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * SMSEntries will end with this root suffix.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract String getRootSuffix();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the AMSDK BaseDN for the UM objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public abstract String getAMSdkBaseDN();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Non-abstract convenience methods for implementation classes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the naming attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getNamingAttribute() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.PLACEHOLDER_RDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the organization naming attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getOrgNamingAttribute() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.ORGANIZATION_RDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns all the SMS attribute names
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String[] getAttributeNames() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.SMS_ATTRIBUTES);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns search (LDAP) filter to search for SMS objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getSearchFilter() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.FILTER_PATTERN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns search (LDAP) filter to search for SMS objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getServiceIdSearchFilter() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.FILTER_PATTERN_ALL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Debug debug() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.debug);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean cacheResults() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (SMSEntry.cacheSMSEntries);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Method to close the resources held by the plugins
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void shutdown() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Default empty implementation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}