8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
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 * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
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 * $Id: SMSJAXRPCObject.java,v 1.21 2009/10/28 04:24:26 hengming Exp $
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts * Portions Copyrighted 2011-2016 ForgeRock AS.
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpottsimport static org.forgerock.openam.utils.Time.*;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.comm.client.NotificationHandler;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.comm.client.PLLClient;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.comm.share.Notification;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.services.naming.WebtopNaming;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshottimport com.sun.identity.common.CaseInsensitiveHashMap;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.common.GeneralTaskRunnable;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.jaxrpc.SOAPClient;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshottimport com.sun.identity.sm.SMSNotificationManager;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshottimport org.forgerock.openam.session.SessionCookies;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshottimport javax.naming.directory.ModificationItem;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class SMSJAXRPCObject extends SMSObject implements SMSObjectListener {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * JAXRPC Version String variable name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String AMJAXRPCVERSIONSTR = "AM_JAXRPC_VERSION";
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott private final SessionCookies sessionCookies;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * JAXRPC Version String.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Since we introduced the new API getAMSdkBaseDN, now the client
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // version is 11 in opensso & AM 7.1 patch 1.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String AMJAXRPCVERSION = "11";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String NOTIFICATION_PROPERTY =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "com.sun.identity.sm.notification.enabled";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Construct the SOAP client
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster client = new SOAPClient(JAXRPCUtil.SMS_SERVICE);
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies = SessionCookies.getInstance();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If cache is enabled, register for notification to maintian
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // internal cache of entriesPresent
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Add this object to receive notifications to maintain
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // internal cache of entries present and not present
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSNotificationManager.getInstance().registerCallbackHandler(
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>
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public Map<String, Set<String>> read(SSOToken token, String objName) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] objs = { token.getTokenID().toString(), objName };
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott Map attrs = (Map) client.send(client.encodeMessage("read", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Return CaseInsesitiveHashMap to be consistent with server side
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((attrs == null) ? null : new CaseInsensitiveHashMap<String, Set<String>>(attrs));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:read -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-cannot-read"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates an entry in the persistent store. Throws an exception if the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * entry already exists
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void create(SSOToken token, String objName, Map attributes)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), objName,
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott client.send(client.encodeMessage("create", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:create -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-cannot-create"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Modifies the attributes to the object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void modify(SSOToken token, String objName, ModificationItem[] mods)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), objName,
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott client.send(client.encodeMessage("modify", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:modify -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-cannot-modify"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Delete the entry in the datastore. This should delete sub-entries also
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void delete(SSOToken token, String objName) throws SMSException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] objs = { token.getTokenID().toString(), objName };
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott client.send(client.encodeMessage("delete", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:delete -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-cannot-delete"));
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.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public Set<String> searchSubOrgNames(SSOToken token, String dn, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, boolean sortResults, boolean ascendingOrder,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean recursive) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), dn, filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new Integer(numOfEntries), Boolean.valueOf(sortResults),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean.valueOf(ascendingOrder), Boolean.valueOf(recursive)
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((Set<String>) client.send(client.encodeMessage("searchSubOrgNames",
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott objs), sessionCookies.getLBCookie(token.getTokenID().toString()),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject.searchSubOrgNames", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-suborg-cannot-search"));
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.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public 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 Object[] objs = { token.getTokenID().toString(), dn,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new Integer(numOfEntries), Boolean.valueOf(sortResults),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean.valueOf(ascendingOrder), serviceName, attrName,
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((Set<String>) client.send(client.encodeMessage(
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject.searchOrganizationNames", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-org-cannot-search"));
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.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public Set<String> subEntries(SSOToken token, String dn, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, boolean sortResults, boolean ascendingOrder)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), dn, filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new Integer(numOfEntries), Boolean.valueOf(sortResults),
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((Set<String>) client.send(client.encodeMessage("subEntries", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:subEntries -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-subentry-cannot-search"));
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.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public Set<String> schemaSubEntries(SSOToken token, String dn, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String sidFilter, int numOfEntries, boolean sortResults,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean ascendingOrder) throws SMSException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), dn, filter,
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((Set<String>) client.send(client.encodeMessage("schemaSubEntries",
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott objs), sessionCookies.getLBCookie(token.getTokenID().toString()),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:subEntries -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "sms-JAXRPC-schemasubentry-cannot-search"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Searches the data store for objects that match the filter
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public Iterator<SMSDataEntry> search(SSOToken token, String startDN, String filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int numOfEntries, int timeLimit, boolean sortResults,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), startDN, filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Integer.valueOf(numOfEntries), Integer.valueOf(timeLimit),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean.valueOf(sortResults), Boolean.valueOf(ascendingOrder), excludes };
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set<String> searchResults = ((Set<String>) client.send(client.encodeMessage("search3", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (searchResults != null && !searchResults.isEmpty()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set<SMSDataEntry> dataEntries = new HashSet<SMSDataEntry>(searchResults.size());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:search -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-error-in-searching"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Searchs the data store for objects that match the filter
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington public 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 Object[] objs = { token.getTokenID().toString(), startDN, filter,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster new Integer(numOfEntries), new Integer(timeLimit),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean.valueOf(sortResults), Boolean.valueOf(ascendingOrder) };
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington return ((Set<String>) client.send(client.encodeMessage("search2", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:search -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw (new SMSException(re, "sms-JAXRPC-error-in-searching"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Checks if the provided DN exists. Used by PolicyManager.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean entryExists(SSOToken token, String dn) {
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington dn = DN.valueOf(dn).toString().toLowerCase();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check the caches
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("SMSLdapObject: entry present in cache: " + dn);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (SMSNotificationManager.isCacheEnabled() &&
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("SMSLdapObject: entry present in "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Since not present in cache, make a RPC
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster boolean entryExists = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] objs = { token.getTokenID().toString(), dn };
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean b = (Boolean) client.send(client.encodeMessage(
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:entryExists -- Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Update the cache
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (entryExists && SMSNotificationManager.isCacheEnabled()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (entriesPresent.size() > entriesPresentCacheSize) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Remove the first entry
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster synchronized (entriesPresent) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (SMSNotificationManager.isCacheEnabled()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (entriesNotPresent.size() > entriesPresentCacheSize) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Remove the first entry
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster synchronized (entriesNotPresent) {
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 baseDN = (String) client.send(client.encodeMessage(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:getRootSuffix:Exception:", re);
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk * Returns the session root suffix (i.e., base DN) for the SMS objects. All
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk * SMSEntries will end with this root suffix.
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk baseDN = (String) client.send(client.encodeMessage(
8bb3e4cda81612f01c0254c263155f65506a018cjeff.schenk debug.error("SMSJAXRPCObject:getSessionRootSuffix:Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the root suffix (i.e., base DN) for the UMS objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * All UMSEntries will end with this root suffix.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster amsdkbaseDN = (String) client.send(client.encodeMessage(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObject:getAMSdkBaseDN:Exception:", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Validates service configuration attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param token Single Sign On token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param validatorClass validator class name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> of values are valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param values Values to be validated.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if single sign on token is in valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SMSException if value is invalid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = {token.getTokenID().toString(), validatorClass,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Boolean b = (Boolean)client.send(client.encodeMessage(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "validateServiceAttributes", objs), null, null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("SMSJAXRPCObjectvalidateServiceAttributes", re);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "sms-JAXRPC-attribute-values-validation-failed");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Registration for event change notifications.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Only SMSNotificationManager would be calling this method to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * register itself
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void registerCallbackHandler(SMSObjectListener changeListener)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if notification is enabled
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Default the notification enabled to true if the property
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // is not found for backward compatibility.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String notificationFlag = SystemProperties.get(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (notificationFlag.equalsIgnoreCase("true")) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Check if notification URL is provided
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Register with PLLClient for notificaiton
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Register for notification with SMS Server
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "notification mechanism for cache updates: " + url);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Use polling mechanism to update caches
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("SMSJAXRPCObject: Registering for " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "notification via URL failed: " + e.getMessage() +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "\nUsing polling mechanism for updates");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Start Polling thread only if enabled.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Start Polling thread only if enabled.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster startPollingThreadIfEnabled(getCachePollingInterval());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the polling interval in minutes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return polling interval in minutes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If the property is not configured, default it to 1 minute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String cachePollingTimeStr = SystemProperties.get(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int cachePollingInterval = Constants.DEFAULT_CACHE_POLLING_TIME;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cachePollingInterval = Integer.parseInt(cachePollingTimeStr);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("EventListener::NotificationRunnable:: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Invalid Polling Time: " + cachePollingTimeStr +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster " Defaulting to " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Constants.DEFAULT_CACHE_POLLING_TIME + " minute", nfe);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static void startPollingThreadIfEnabled(int cachePollingInterval) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("EventListener: Polling mode enabled. " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "Starting the polling thread..");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Run in polling mode
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster NotificationRunnable nr = new NotificationRunnable(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SystemTimerPool.getTimerPool().schedule(nr, new Date(
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts ((currentTimeMillis() + nr.getRunPeriod()) / 1000)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("EventListener: Polling mode DISABLED. " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void objectChanged(String dn, int type) {
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington dn = DN.valueOf(dn).toString().toLowerCase();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Remove from entriesPresent Set
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // do nothing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Converts ModificationItem to String
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static String toMods(ModificationItem[] mods) throws SMSException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SMSSchema.escapeSpecialCharacters((String)attr.get(j)));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "sms-JAXRPC-cannot-copy-fromModItemToString"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("SMSJAXRPCObject::ModsToString: " + sb.toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // sends notifications
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Send notification
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Static variables
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static int entriesPresentCacheSize = 1000;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Set entriesPresent = Collections.synchronizedSet(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Set entriesNotPresent = Collections.synchronizedSet(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Used to update entriesPresent & entriesNotPresent
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static boolean initializedNotification;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Used to register for notifications from Server
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static boolean notificationInitialized;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Debug debug = Debug.getInstance("amSMSClient");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static SMSObjectListener objectListener;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Inner class to check for notifications
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static class NotificationRunnable extends GeneralTaskRunnable {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster client = new SOAPClient(JAXRPCUtil.SMS_SERVICE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Get the modification list and send notifications
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set mods = (Set) client.send(client.encodeMessage(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "NotificationRunnable retrived changes: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Should not happend
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("SMSJAXRCPObject::NotificationRunnable:run "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Number Format Exception for polling Time: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("SMSJAXRPCObject::NotificationRunnable:run "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("SMSJAXRPCObject::NotificationRunnable:run "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("SMSJAXRPCObject::NotificationRunnable:run "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Inner class handle SMS change notifications
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static class SMSNotificationHandler implements NotificationHandler {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Empty constructor
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Process the notification objects
7eec4dacb6610121d1e70afd31e53034525e2ae6Dipu Seminlal public void process(Vector<Notification> notifications) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; i < notifications.size(); i++) {
7eec4dacb6610121d1e70afd31e53034525e2ae6Dipu Seminlal Notification notification = notifications.elementAt(i);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("SMSJAXRPCObject:SMSNotificationHandler: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Send notification