AMAdminUtils.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: AMAdminUtils.java,v 1.9 2009/10/19 18:17:37 asyhuang Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/* - NEED NOT LOG - */
/**
* This provides a set helper methods to access
* Access and Service Management SDKs.
*/
public class AMAdminUtils {
/**
* Returns the Single-Sign-On Token of super administrator.
*
* @return Single-Sign-On Token of super administrator.
* @throws SecurityException if security check fails.
*/
public static final SSOToken getSuperAdminSSOToken()
throws SecurityException
{
return (SSOToken)
}
/**
* Returns the first value of a collection. Returns empty string if set is
* collection or null.
*
* @param collection Collection to act on.
*/
}
/**
* Returns the first value of a set. Returns -1 if set is empty or null.
* Returns int equals of the string.
*
* @param set Set to act on.
* @param defaultValue Default Value of set is empty.
* @throws NumberFormatException if the item in the set is not an integer
*/
throws NumberFormatException
{
int value = defaultValue;
}
}
return value;
}
/**
* Returns a hash set containing a given object.
*
* @param obj Object to be added in set.
* @return a hash set containing a given object.
*/
} else {
}
return set;
}
/**
* Returns a set that contains all items in array.
*
* @param array Array which contains the items.
* @return a set that contains all items in array.
*/
}
}
}
/**
* Returns a set that contains all items in array.
*
* @param array Array which contains the items.
* @return a set that contains all items in array.
*/
set = new OrderedSet();
}
}
}
/**
* Returns a list that contains all items in array.
*
* @param array Array which contains the items.
* @return a list that contains all items in array.
*/
}
}
}
/**
* Returns integer value of a item in a set.
*
* @param set Set that contains the item.
* @param defaultValue default value if set is null or empty.
* @return integer value of a item in a set.
* @throws NumberFormatException if the item in the set in non integer.
*/
throws NumberFormatException
{
int val = defaultValue;
}
return val;
}
/**
* Removes the mapping of which keys matches with items in a given set.
*
* @param map Map object.
* @param set Set of keys to be removed from <code>map</code>.
*/
}
}
}
/**
* Returns a map of upper cased keys.
*
* @param map Map to operate on.
* @return a map of upper cased keys.
*/
}
return uc;
}
/**
* Returns the integer value of an attribute.
*
* @param svcSchemaMgr service schema manager
* @param type schema type
* @param attribute name
* @return string value of an attribute
* @throws NumberFormatException if value is not numeric
* @throws SMSException if operation fails
*/
public static int getIntegerAttribute(
) throws NumberFormatException, SMSException
{
int value = -1;
}
}
}
return value;
}
/**
* Returns the default value of an attribute from the service schema.
*
* @param svcSchemaMgr Service schema manager.
* @param type Schema type.
* @param attribute Attribute name.
* @return values of service schema attribute.
* @throws SMSException if operations fails.
*/
public static Set getAttribute(
throws SMSException
{
}
}
}
try {
}
} catch (IOException e) {
}
}
}
/**
* Removes a set of string entries in a set with case insensitivity check.
*
* @param master Master Set.
* @param deletingSet Set that contains strings to be removed from master
* set.
*/
}
}
}
}
}
return lcSet;
}
/**
* Returns the parent DN for the given DN.
*
* @param dn name of the child object
* @return parent of <code>dn</code>
*/
}
return "";
}
/**
* Returns the first <code>String</code> element from the given set.
* If the set is empty, or null, an empty string will be returned.
*
* @param set where element resides
* @return first String element from the set.
*/
}
/**
* Gets search results warning message. <code>SearchResult</code>
* returns an error code whenever size or time limit is reached.
* This method interprets the error code and return the appropriate
* warning message. Empty string is returned if no limits are reached.
*
* @param results Access Management Search Result object.
* @param model to retrieve localized string.
* @return search results warning message.
*/
public static String getSearchResultWarningMessage(
) {
"sizeLimitExceeded.message");
"timeLimitExceeded.message");
}
}
}
/**
* Returns a concatenation string of all entries in a collection.
*
* @param collection Collection.
* @param delimiter Delimiter
* @param reverse true to traversal the entries from bottom up.
* @return a concatenation string of all entries in a collection.
*/
boolean reverse
) {
boolean empty = true;
if (!reverse) {
if (empty) {
empty = false;
} else {
}
} else {
}
}
}
}
/**
* Returns the string value of an attribute.
*
* @param svcSchemaMgr service schema manager
* @param type schema type
* @param attribute name
* @return string value of an attribute
* @throws SMSException if operation fails
*/
public static String getStringAttribute(
throws SMSException
{
}
}
return value;
}
/**
* Replaces character/s in a string with another.
*
* @param string String to work on.
* @param orig Original character/s.
* @param substitution Substitution.
* @return Manipulated string.
*/
public static String replaceString(
) {
while (idx != -1) {
}
return string;
}
/**
* Replaces character/s in a string with another
*
* @param list List of string.
* @param orig Original character/s.
* @param substitution Substitution.
* @return Manipulated list.
*/
public static List replaceString(
) {
}
return manipulated;
}
/**
* Returns a map of String of String from a delimited string. Example
* <code>key1=x|key2=y</code>.
*
* @param deString Delimited String
* @param delimiter Delimiter.
* @return a map of String of String from a delimited string.
*/
public static Map getValuesFromDelimitedString(
) {
while (st.hasMoreTokens()) {
if (idx != -1) {
}
}
return map;
}
/**
* Returns a set of string from a delimited string. Example
* <code>val1,val2,...,valN</code>.
*
* @param deString Delimited String
* @param delimiter Delimiter.
* @return Set of string from a delimited string.
*/
while (st.hasMoreTokens()) {
}
}
return set;
}
/**
* Returns attribute schema object.
*
* @param serviceName Name of service.
* @param schemaType Type of Schema.
* @param subSchemaName Name of sub schema.
* @param attributeName Name of attribute schema.
* @return attribute schema object.
*/
public static AttributeSchema getAttributeSchema(
) {
attrSchema = as;
}
}
return attrSchema;
}
private static Set getAttributeSchemas(
) {
try {
if (subSchemaName != null) {
}
}
}
} catch (SSOException e) {
} catch (SMSException e) {
}
return (attributeSchemas != null) ?
}
private static Set getAttributeSchemas(
) {
}
/**
* Returns a set of attribute schemas that can be displayed in console
* for a service of a given schema type.
*
* @param serviceName Name of Service.
* @param schemaType Schema Type.
* @return set of attribute schemas that can be displayed in console.
*/
public static Set getDisplayableAttributeNames(
) {
}
}
}
}
/**
* Returns service schema for an IdType.
*
* @param serviceName Name of Service.
* @param idType IdType.
* @return service schema for an IdType.
*/
public static ServiceSchema getSchemaSchema(
) {
try {
} catch (SSOException e) {
} catch (SMSException e) {
}
return serviceSchema;
}
}
}
}
}
}
return list;
}
/**
* Returns a list of strings in the order of string length. Longest
* string is in front of the list.
*
* @param collection Collections of String.
* @return a list of strings in the order of string length.
*/
return ordered;
}
/**
* Returns a clone map of String to Set.
*
* @param orig Map to be cloned.
* @return cloned map.
*/
}
}
}
}
return cloned;
}
/**
* Removes all matching entries from a set if entries exist in another set.
* entries in the sets are LDAP entries.
*
* @param originalSet Original Set.
* @param toDelete Collection of entries to be deleted.
*/
}
}
}
}
return setDNs;
}
boolean contain = false;
}
return contain;
}
public static Set getUserAttributeNames() {
try {
) {
}
}
}
}
}
} catch (SSOException e) {
} catch (SMSException e) {
}
return userAttributeNames;
}
}