SMSJAXRPCObjectImpl.java revision 6a490d4b01fde313651d02ca8d6ac8db32266d03
/**
* 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: SMSJAXRPCObjectImpl.java,v 1.22 2009/10/28 04:24:27 hengming Exp $
*
*/
/*
* Portions Copyrighted 2010-2013 ForgeRock AS
*/
static SSOTokenManager tokenMgr;
static SSOException initializationError;
static String amsdkbaseDN;
static boolean initialized;
// Cache of modified DNs for the last 30 minutes
static int cacheSize = 30;
// Default constructor
public SMSJAXRPCObjectImpl() {
// Empty constructor to avoid bootstraping when JAX-RPC
// initialized this object on the Serve
}
// Initialization to register the callback handler
private void initialize() {
if (!initialized) {
try {
} catch (SSOException ssoe) {
+ "Unable to get SSO Token Manager");
}
// Register for notifications & polling cache
if (SMSNotificationManager.isCacheEnabled()) {
.registerCallbackHandler(this);
if (debug.messageEnabled()) {
"Registered for notifications");
}
// Obtain the cache size, if configured
try {
if (cacheSize < 0) {
cacheSize = 30;
}
} catch (NumberFormatException e) {
//do nothing
}
if (debug.messageEnabled()) {
"EventNotification cache size is set to " + cacheSize);
}
}
// Construct server URL
if (index != -1) {
} else {
serverURL = "";
}
} else {
serverURL = "";
}
}
} else if (debug.messageEnabled()) {
}
initialized = true;
}
}
// Method to check if service is local and also to
// test if the server is down
public void checkForLocal() {
SMSJAXRPCObject.isLocal = true;
}
/**
* Returns the attribute names and values of the provided object using the
* identity of the provided SSO Token
*/
initialize();
if (debug.messageEnabled()) {
}
returnAttributes = new HashMap();
} else {
objName);
}
returnAttributes = new HashMap();
}
} else { // could be null or instance of HashMap - return as it is.
}
}
return returnAttributes;
}
/**
* Creates an entry in the persistent store. Throws an exception if the
* entry already exists
*/
initialize();
if (debug.messageEnabled()) {
}
}
/**
* Modifies the attributes to the object.
*/
initialize();
if (debug.messageEnabled()) {
}
}
/**
* Delete the entry in the datastore. This should delete sub-entries also
*/
initialize();
if (debug.messageEnabled()) {
}
}
/**
* 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.
*/
initialize();
if (debug.messageEnabled()) {
}
}
/**
* 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 {
initialize();
if (debug.messageEnabled()) {
+ dn);
}
}
/**
* 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 {
initialize();
if (debug.messageEnabled()) {
}
}
/**
* Returns the sub-entries matching the schema id. Returns a set of SMSEntry
* objects that are sub-entries for the provided schema id. The paramter
* <code>numOfEntries</code> identifies the number of entries to return,
* if <code>0</code> returns all the entries.
*/
throws SMSException, SSOException {
initialize();
if (debug.messageEnabled()) {
}
}
/**
* Searchs the data store for objects that match the filter
*/
initialize();
if (debug.messageEnabled()) {
+ " filter: " + filter);
}
false, false));
}
/**
* Searchs the data store for objects that match the filter
*/
boolean ascendingOrder)
initialize();
if (debug.messageEnabled()) {
+ " filter: " + filter);
}
}
/**
* Searches the data store for objects that match the filter with an exclude set
*/
initialize();
if (debug.messageEnabled()) {
}
while (i.hasNext()) {
try {
} catch (JSONException ex) {
}
}
return result;
}
/**
* Checks if the provided DN exists. Used by PolicyManager.
*/
throws SSOException, RemoteException {
initialize();
if (debug.messageEnabled()) {
}
boolean entryExists = false;
try {
objName);
}
} catch (SMSException smse) {
// Ignore the exception
}
return (entryExists);
}
/**
* Returns the root suffix (i.e., base DN) for the SMS objects. All
* SMSEntries will end with this root suffix.
*/
}
return (baseDN);
}
/**
* Returns the root suffix (i.e., amsdkbase DN) for the UMS objects.
* All UMSEntries will end with this root suffix.
*/
if (amsdkbaseDN == null) {
}
return (amsdkbaseDN);
}
/**
* Validates service configuration attributes.
*
* @param token Single Sign On token.
* @param validatorClass validator class name.
* @param values Values to be validated.
* @return <code>true</code> of values are valid.
* @throws SMSException if value is not valid.
* @throws SSOException if single sign on token is in valid.
* @throws RemoteException if remote method cannot be invoked.
*/
public boolean validateServiceAttributes(
initialize();
if (debug.messageEnabled()) {
}
try {
clazz.newInstance();
} catch (InstantiationException ex) {
throw new SMSException("sms-validator_cannot_instantiate_class");
} catch (IllegalAccessException ex) {
throw new SMSException("sms-validator_cannot_instantiate_class");
} catch (ClassNotFoundException ex) {
throw new SMSException("sms-validator_cannot_instantiate_class");
}
}
// Implementation to receive requests from clients
// Returns changes in the past <i>time</i> minutes
if (debug.messageEnabled()) {
}
// Get the cache index for times upto time+2
// Add 1 minute to offset, the initial lookup
}
return (answer);
}
// Implementation for SMSObjectListener
// Maintain cacheIndex
}
}
switch (type) {
case ADD:
break;
case DELETE:
break;
default:
}
// If notification URLs are present, send notifications
synchronized (notificationURLs) {
// Construct NotificationSet
try {
if (debug.messageEnabled()) {
}
} catch (SendNotificationException ne) {
if (debug.warningEnabled()) {
"URL from notification list.", ne);
}
// Remove the URL from Notification List
}
}
}
}
public void allObjectsChanged() {
// do nothing. Not sending to remote clients
}
// Methods to register notification URLs
initialize();
// Default value if there are any issues with the registration process.
try {
// Check URL is not the local server
synchronized (notificationURLs) {
// Don't add the URL again if we already have it registered
boolean alreadyRegistered = false;
// This allows us to return the existing entry ID to support clients being able to
// de-register the correct entry.
alreadyRegistered = true;
if (debug.messageEnabled()) {
}
break;
}
}
// If we didn't find the url in our list, add it
if (!alreadyRegistered) {
try {
} catch (ServerEntryNotFoundException e) {
if (debug.messageEnabled()) {
"had a problem getting our serverID ", e);
}
}
// Generate a unique value that includes the serverID to have a better chance of being unique
// in a cluster should a de-register request end up on the wrong server.
if (debug.messageEnabled()) {
}
}
}
} else {
// Cannot add this server for notifications
if (debug.warningEnabled()) {
+ "cannot add local server: " + url);
}
}
} catch (MalformedURLException e) {
if (debug.warningEnabled()) {
+ " invalid URL: " + url, e);
}
}
return id;
}
synchronized (notificationURLs) {
}
}
}
/**
* Processes object changed events from other severs
*
* @param name DN of the object changed
* @param type change type
* @throws java.rmi.RemoteException
*/
throws RemoteException {
}
// Get year, month, date, hour and minute
}
/**
* Returns SSOToken from token ID
*/
if (initializationError != null)
throw (initializationError);
}
/**
* Returns an array of ModificationItems converted from string
* representation of mods. The string representation is of the format:
* <pre>
* <Modifications size="xx"> <AttributeValuePair event="ADD | REPLACE |
* DELETE"> <Attribute name="attrName" /> <Value>...</Value>
* </AttributeValuePair> </Modifications>
* </pre>
*/
if (debug.messageEnabled()) {
}
try {
root, "size"));
for (int i = 0; i < modsSize; i++) {
"event");
attrNode, "name");
// Construct ModificationItem
}
}
}
} catch (Exception e) {
throw (new SMSException(e,
"sms-JAXRPC-cannot-copy-fromModStringToModItem"));
}
return (answer);
}
}