AMCommonUtils.java revision a14393818a78c503f7715c393044b33c86e90195
/*
* 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: AMCommonUtils.java,v 1.7 2009/01/28 05:34:46 ww203982 Exp $
*
* Portions Copyright 2015 ForgeRock AS.
*/
/**
* This class contains all the miscellaneous utility methods used in the
* <code>com.iplanet.am.sdk</code> package.
*
* @deprecated As of Sun Java System Access Manager 7.1.
*/
public class AMCommonUtils implements AMConstants {
// Constants
/**
* Debug variable to be used by AM SDK package
*/
private static final String LOCALE_INTEGRATION_PROPERTY =
"locale.integration";
private static final String EXTERNAL_ATTRIBUTES_FETCH_ENABLED_ATTR =
"iplanet-am-admin-console-external-attribute-fetch-enabled";
protected static boolean integrateLocale = true;
static {
integrateLocale = true;
if (debug.messageEnabled()) {
}
} else {
integrateLocale = false;
}
try {
} catch (Throwable t) {
if (debug.messageEnabled()) {
+ " Caught exception in static block", t);
}
}
}
/**
* Method to get the user locale.
*
* @param token
* SSOToken of the authenticated user
* @return a String value representing the user locale
*/
try {
if (debug.messageEnabled()) {
+ locale);
}
return locale;
} catch (SSOException ssoe) {
+ "setting to null");
return null;
}
}
/**
* Combines 2 AttrSets and returns the result set. The original sets are not
* modified.
*
* @param attrSet1
* the first AttrSet
* @param attrSet2
* the second AttrSet
* @return an AttrSet which has combined values of attrSet1 & attrSet2
*/
{
for (int i = 0; i < count; i++) {
}
}
for (int i = 0; i < count; i++) {
}
}
return retAttrSet;
}
/**
* Merge the values in two maps and return the result map. The values in the
* smaller map are merged with the larger map and the larger map is
* returned.
*
* @param mapA
* the first map
* @param mapB
* the second map
* @return a result map which the biggest of the two maps with values merged
* from the smaller one.
*/
return null;
}
return mapB;
return mapA;
}
// Find the map with smaller size and iterate through it.
} else {
}
}
return bigMap;
}
}
} else {
}
}
}
} else {
}
}
}
}
return copyValues;
}
/**
* Method to convert a String array to a set
*
* @param strs
* the String array
* @return a Set representing the String array
*/
for (int i = 0; i < count; i++) {
}
return set;
}
return attrSetToMap(attrSet, false);
}
/**
* Method to convert a AttrSet object to Map.
*
* @param attrSet
* the AttrSet to be converted to a Map
* @param fetchByteValues
* if false stringValues are added, if true byteValues are added.
* @return a Map containing attribute names as key's and a Set of attribute
* values or byte Values
*/
{
return attributesMap;
}
if (!fetchByteValues) {
for (int i = 0; i < attrSetSize; i++) {
}
} else {
for (int i = 0; i < attrSetSize; i++) {
}
}
return attributesMap;
}
/**
* Method to convert a Map to AttrSet.
*
* @param map
* a map contaning attribute names as keys and a Set of attribute
* values corresponding to each map key.
* @return an AttrSet having the contents of the supplied map
*/
return mapToAttrSet(map, false);
}
/**
* Method to convert a Map to AttrSet.
*
* @param map
* a map contaning attribute names as keys and a Set of attribute
* values corresponding to each map key.
* @param byteValues
* if true then values are bytes otherwise strings
* @return an AttrSet having the contents of the supplied map
*/
return attrSet;
}
if (!byteValues) {
}
} else {
}
}
return attrSet;
}
/**
* Gets the principal DN String in RFC lowercase format from the SSOToken
*
* @param token
* a valid SSOToken
* @return a principal DN corresponding to token
* @throws SSOException
* if the token is not valid
*/
}
/**
* Combines two sets which contains objectclass values of an entry in a case
* insensitive manner. OC values are sometimes returned by LDAP in mixed
* case and when duplicate values for Objectclass exists in a mixed case,
* there is a Object class violation Note: there is a possibility that this
* method will return null
*/
return two;
}
return one;
}
}
}
return resultSet;
}
/**
* Method to compare all the object classes in the Set with the specfied
* object class. Will do a case insensitive comparision.
*
* @param objectClasses
* Set of object classes
* @param objectClass
* the specified object class
* @return true if the specified object class is present. False otherwise.
*/
return true;
}
}
}
return false;
}
/**
* Method which removes the specified object class from original set and
* returns the set of object classes that were removed.
*
* @param origSet
* the original Set
* @param removeOCs
* the Set of object classes to be removed
* @return the Set of object classes that were removed.
*/
// The remove OCs will be removed from the origSet and only the ones
// that were removed will be returned
// Can't remove from orig set directly. Will throw
// ConcurrentModificatiomException
break;
}
}
}
}
return returnOCs;
}
/**
* Removes Empty sets from attribute-value maps. So that SDK does not try to
* remove these attributes from newly created entries. Such empty sets
* should be ignored, when entry is being created.
*
* @param attrMap
* @return map without empty set.
*/
if (!s.isEmpty()) {
}
}
return finalMap;
}
protected static boolean populateManagedObjects() {
try {
if (debug.messageEnabled()) {
+ "managedObjects=" + managedObjects);
}
return false;
// populateManagedObjectsWithDefaults();
}
mo);
/*
* Default to parent Type as an organization, if no value
* defined.
*/
// Assumes a type is always defined in the config.
// TODO be careful with NPE here.
}
}
}
if (stAttrName != null) {
}
}
}
if (debug.messageEnabled()) {
+ creationtemplateMap.toString());
+ supportedTypes.toString());
+ statusAttributeMap.toString());
}
} catch (SMSException se) {
if (debug.messageEnabled()) {
+ " Got SMSException :", se);
}
return false;
// populateManagedObjectsWithDefaults();
} catch (SSOException ssoe) {
return false;
// populateManagedObjectsWithDefaults();
}
return true;
}
/**
* Returns a Set of supported entity types
*
*/
protected static Set getSupportedEntityTypes() {
return supportedEntities;
}
/**
* Method to check if the CallBack plugins are enabled for reading external
* attributes.
*/
// Obtain the ServiceConfig
try {
// Get the org config
} else {
}
}
boolean enabled = false;
}
if (debug.messageEnabled()) {
+ enabled);
}
return enabled;
}
// Org Config may not exist. Get default values
if (debug.messageEnabled()) {
+ "Organization config for service ("
+ ") not found. Obtaining default service "
+ "config values ..");
}
try {
if (defaultValues != null) {
}
} catch (Exception e) {
if (debug.warningEnabled()) {
+ "Unable to get default global config information", e);
}
}
return null;
}
protected static void populateManagedObjectsWithDefaults() {
}
return null;
}
}
}