/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: SMSJAXRPCObject.java,v 1.21 2009/10/28 04:24:26 hengming Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
* JAXRPC Version String variable name.
*/
/**
* JAXRPC Version String.
*/
// Since we introduced the new API getAMSdkBaseDN, now the client
// version is 11 in opensso & AM 7.1 patch 1.
"com.sun.identity.sm.notification.enabled";
public SMSJAXRPCObject() {
// Construct the SOAP client
}
private void initializeNotification() {
if (!initializedNotification) {
// If cache is enabled, register for notification to maintian
// internal cache of entriesPresent
// Add this object to receive notifications to maintain
// internal cache of entries present and not present
if (SMSNotificationManager.isCacheEnabled()) {
this);
}
initializedNotification = true;
}
}
/**
* Reads in the object from persistent store. It assumes the object name and
* the ssoToken are valid. If the entry does not exist the method should
* return <code>null</code>
*/
try {
// Return CaseInsesitiveHashMap to be consistent with server side
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Creates an entry in the persistent store. Throws an exception if the
* entry already exists
*/
throws SMSException, SSOException {
try {
attributes };
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Modifies the attributes to the object.
*/
throws SMSException, SSOException {
try {
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Delete the entry in the datastore. This should delete sub-entries also
*/
try {
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Returns the suborganization names. Returns a set of SMSEntry objects that
* are suborganization names. The paramter <code>numOfEntries</code>
* identifies the number of entries to return, if <code>0</code> returns
* all the entries.
*/
try {
};
null));
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Returns the organization names. Returns a set of SMSEntry objects that
* are organization names. The paramter <code>numOfEntries</code>
* identifies the number of entries to return, if <code>0</code> returns
* all the entries.
*/
throws SMSException, SSOException {
try {
values};
"searchOrganizationNames", objs),
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Returns the sub-entries. Returns a set of SMSEntry objects that are
* sub-entries. The paramter <code>numOfEntries</code> identifies the
* number of entries to return, if <code>0</code> returns all the entries.
*/
throws SMSException, SSOException {
try {
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Returns the sub-entries. Returns a set of SMSEntry objects that are
* sub-entries. The paramter <code>numOfEntries</code> identifies the
* number of entries to return, if <code>0</code> returns all the entries.
*/
try {
null));
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
throw (new SMSException(re,
"sms-JAXRPC-schemasubentry-cannot-search"));
}
}
/**
* Searches the data store for objects that match the filter
*/
throws SMSException, SSOException {
try {
null));
}
} else {
}
return result;
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Searchs the data store for objects that match the filter
*/
try {
null));
} catch (SSOException ssoe) {
throw ssoe;
} catch (SMSException smse) {
throw smse;
}
}
/**
* Checks if the provided DN exists. Used by PolicyManager.
*/
// Check the caches
if (SMSNotificationManager.isCacheEnabled() &&
if (debug.messageEnabled()) {
}
return (true);
} else if (SMSNotificationManager.isCacheEnabled() &&
if (debug.messageEnabled()) {
+ "not-present-cache: " + dn);
}
return (false);
}
// Since not present in cache, make a RPC
boolean entryExists = false;
try {
"entryExists", objs),
entryExists = b.booleanValue();
return (false);
}
// Update the cache
// Remove the first entry
synchronized (entriesPresent) {
}
}
}
} else if (SMSNotificationManager.isCacheEnabled()) {
// Remove the first entry
synchronized (entriesNotPresent) {
}
}
}
}
return (entryExists);
}
/**
* Returns the root suffix (i.e., base DN) for the SMS objects. All
* SMSEntries will end with this root suffix.
*/
try {
}
}
return (baseDN);
}
/**
* Returns the session root suffix (i.e., base DN) for the SMS objects. All
* SMSEntries will end with this root suffix.
*/
try {
}
}
return (baseDN);
}
/**
* Returns the root suffix (i.e., base DN) for the UMS objects.
* All UMSEntries will end with this root suffix.
*/
if (amsdkbaseDN == null) {
try {
}
}
return (amsdkbaseDN);
}
/**
* Validates service configuration attributes.
*
* @param token Single Sign On token.
* @param validatorClass validator class name.
* @return <code>true</code> of values are valid.
* @param values Values to be validated.
* @throws SSOException if single sign on token is in valid.
* @throws SMSException if value is invalid.
*/
public boolean validateServiceAttributes(
) throws SMSException, SSOException {
try {
values};
return b.booleanValue();
} catch (SSOException e) {
throw e;
} catch (SMSException smse) {
throw smse;
throw new SMSException(re,
"sms-JAXRPC-attribute-values-validation-failed");
}
}
/**
* Registration for event change notifications.
* Only SMSNotificationManager would be calling this method to
* register itself
*/
throws SMSException {
if (!notificationInitialized) {
// Check if notification is enabled
// Default the notification enabled to true if the property
// is not found for backward compatibility.
NOTIFICATION_PROPERTY, "true");
// Check if notification URL is provided
try {
// Register with PLLClient for notificaiton
new SMSNotificationHandler());
// Register for notification with SMS Server
if (debug.messageEnabled()) {
"notification mechanism for cache updates: " + url);
}
} catch (Exception e) {
// Use polling mechanism to update caches
if (debug.warningEnabled()) {
"notification via URL failed: " + e.getMessage() +
"\nUsing polling mechanism for updates");
}
// Start Polling thread only if enabled.
}
} else {
// Start Polling thread only if enabled.
}
notificationInitialized = true;
}
}
/**
* Returns the polling interval in minutes
* @return polling interval in minutes
*/
private int getCachePollingInterval() {
// If the property is not configured, default it to 1 minute.
if (cachePollingTimeStr != null) {
try {
} catch (NumberFormatException nfe) {
+ "Invalid Polling Time: " + cachePollingTimeStr +
" Defaulting to " +
}
}
return cachePollingInterval;
}
if (cachePollingInterval > 0) {
if (debug.messageEnabled()) {
"Starting the polling thread..");
}
// Run in polling mode
* 1000));
} else {
if (debug.warningEnabled()) {
}
}
}
// Remove from entriesPresent Set
}
}
public void allObjectsChanged() {
// do nothing
}
// Converts ModificationItem to String
return (null);
switch (mods[i].getModificationOp()) {
case DirContext.ADD_ATTRIBUTE:
break;
case DirContext.REPLACE_ATTRIBUTE:
break;
case DirContext.REMOVE_ATTRIBUTE:
break;
}
for (int j = 0; j < size; j++) {
try {
} catch (NamingException ne) {
throw (new SMSException(ne,
"sms-JAXRPC-cannot-copy-fromModItemToString"));
}
}
}
if (debug.messageEnabled()) {
}
}
// sends notifications
// Send notification
}
// Static variables
// Used to update entriesPresent & entriesNotPresent
private static boolean initializedNotification;
// Used to register for notifications from Server
private static boolean notificationInitialized;
protected static boolean isLocal;
// Inner class to check for notifications
// 1 minute
int pollingTime;
volatile long sleepTime;
}
// Get the modification list and send notifications
public void run() {
try {
if (debug.messageEnabled()) {
+ "NotificationRunnable retrived changes: "
+ mods);
}
}
} catch (NumberFormatException nfe) {
// Should not happend
+ "Number Format Exception for polling Time: "
+ pollingTime, nfe);
} catch (SMSException smse) {
if (smse.getExceptionCode() !=
+ "SMSException", smse);
} catch (InterruptedException ie) {
+ "Interrupted Exception", ie);
+ "Exception", re);
}
}
public long getRunPeriod() {
return sleepTime;
}
return false;
}
return false;
}
public boolean isEmpty() {
return false;
}
}
// Inner class handle SMS change notifications
// Empty constructor
}
// Process the notification objects
.elementAt(i);
if (debug.messageEnabled()) {
+ " received notification: " + content);
}
// Send notification
}
}
}
}