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: Misc.java,v 1.6 2009/01/28 05:34:48 ww203982 Exp $
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington * Portions Copyright 2015 ForgeRock AS.
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunningtonimport org.forgerock.opendj.ldap.SearchScope;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The Misc class contains various misc methods :)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String localDsameServer = SystemProperties
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // default is false to ensure more stringent (security-wise) check
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final boolean isCaseInsensitiveDN = Boolean.valueOf(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SystemProperties.get(Constants.CASE_INSENSITIVE_DN)).booleanValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This method is a convenience to get a single attribute from a Map
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * returned by SMS and the dpro SDK. SDK returns a Map with a tuple of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute name and a Set for the values. When all you want is a string
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * this method is nice.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of OpenSSO version 8.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * {@link com.sun.identity.shared.datastruct.CollectionHelper#getMapAttr(Map, String)}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String getMapAttr(Map m, String name) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of OpenSSO version 8.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * {@link com.sun.identity.shared.datastruct.CollectionHelper#getMapAttr(Map, String, String)}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String getMapAttr(Map m, String name, String defaultValue) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This method is a convenience to get a single int value from a Map
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * returned by SMS and the dpro SDK. This method picks up the first value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (String) of the attribute, and returns the int value of the string. If
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * there is no value for the attribute, or the first value could not be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * parsed as a valid integer, returns the default value as an integer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map, key is attribute name, value is String Set which contains
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * all the values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Attribute name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param defaultValue
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * default value for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param debug
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return int value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws NumberFormatException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * when fails to parse the defaultValue argument as a signed
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * decimal integer for return
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of OpenSSO version 8.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * {@link com.sun.identity.shared.datastruct.CollectionHelper#getIntMapAttr(Map, String, String, Debug)}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static int getIntMapAttr(Map m, String name, String defaultValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return Integer.parseInt(getMapAttr(m, name, defaultValue));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This method is a convenience to get a single int value from a Map
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * returned by SMS and the dpro SDK. This method picks up the first value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (String) of the attribute, and returns the int value of the string. If
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * there is no value for the attribute, or the first value could not be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * parsed as a valid integer, returns the default value as an integer.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map, key is attribute name, value is String Set which contains
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * all the values for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Attribute name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param defaultValue
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * default value for the attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param debug
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return int value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of OpenSSO version 8.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * {@link com.sun.identity.shared.datastruct.CollectionHelper#getIntMapAttr(Map, String, int, Debug)}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static int getIntMapAttr(Map m, String name, int defaultValue,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This convenience method is for getting server specific attributes from a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * list attribute. Server specific is determined by prefixing a list
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * attribute value with DSAME local server name followed by the | character.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If the list has more than one entry but no matching local server prefixes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * than null is returned as this is an invalid configuration for these type
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of attributes. This allows services like authentication to support a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * geographic directory configuration.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of OpenSSO version 8.0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * {@link com.sun.identity.shared.datastruct.CollectionHelper#getServerMapAttr(Map, String)}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String getServerMapAttr(Map m, String attrName) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (attrValues == null || attrValues.isEmpty()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a canonicalized form of the DN String
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String representing a DN.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a canonicalized form of the DN String
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // CAUTION! toLowerCase() canonicalization
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // is technically too agressive as DN might
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // be having attributes with caseExactSyntax
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // LDAP SDK owners convinced us that it is hardly
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // possible (and practical) in all the existing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // LDAP server/client implementations to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // implement any non-trivial matching rules
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // (including mixture of attributes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // differences (given that it requires schema queries)
bee2440354b4bc8796e1de0b6cbd60e1f68deba0Phill Cunnington String canonicalizedDN = DN.valueOf(dn).toString();