/*
* 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: DNMapper.java,v 1.13 2009/11/20 23:52:56 ww203982 Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
* This class is used to convert a DN to iplanet UID and vice versa.
*/
public class DNMapper {
// Look for realmEnabled and cache the value.
// This set is used in reversing the realm names to sdk format.
static boolean migration = false;
static {
}
/**
* Converts orgname which is "/" seperated to DN, else if DN normalize the
* DN and return
*/
// Check if it is null or empty
}
// Check in cache
return (orgdn);
}
/*
* Check if orgName is a valid DN. If so, check if realmEnabled. if
* realmEnabled, 1) Check if rest of the DN (before the baseDN) has "o"
* as the naming attribute. If not, replace it with 'o' and concat the
* value with the previous naming attribute. eg.,if orgName is
* dc=abc,l=xyz,o=coke,ou=services,dc=iplanet,dc=com then, the final
* string should be
* o=dc_abc,o=l_xyz,o=coke,ou=services,dc=iplanet,dc=com 2) Check if
* "ou=services" is present in the orgName. If not add it to the
* orgName.
*/
// If orgName is either the baseDN or root service's DN
// return the baseDN
// Check if orgdn is a hidden internal realm, if so return
// Add to cache and return
return orgdn;
}
// Check for root suffix and SMS base DN
// Add to cache and return
}
// If realm is enabled, normalize the DN and return
if (realmEnabled) {
if (ndx == -1) {
// Check for baseDN
}
if (ndx > 0) {
}
if (indx >= 0) {
}
}
if (debug.messageEnabled()) {
}
if (debug.messageEnabled()) {
+ answer);
}
// Add to cache and return
return (answer);
} else if (!migration) {
// Check if "ou=services" is present, if present remove it
// Add to cache and return
return (orgdn);
} else {
// When SMS Migration to 7.0 happens, the coexist mode is
// 'true' and realm is 'false'. In coexist mode, the
// 'ou=services' gets removed. But we need the new realm node
// for data migration from old DIT to new realm tree.
// So after creation of the realm during SMSMigration70,
// we set the DNMapper.migration flag to true to avoid
// removal of 'ou=services' from the newly formed realm DN
// and return the orgdn as such to the serviceconfig* class.
return (orgdn);
}
}
}
// The org name is "/" separated, construct the DN
if (realmEnabled
}
if (debug.messageEnabled()) {
}
// Add to cache
return (answer);
}
// %%% TODO Need to check the size and remove least recently used
}
/**
* Converts realm name to AMSDK compliant organization name
*/
if (debug.messageEnabled()) {
+ realmName);
}
// Check for baseDN and internal hidden realm names
return (SMSEntry.amsdkbaseDN);
}
}
// If realm is not enabled, remove "ou=services" node
// If orgAttr is null or is "o", return after removing "ou=services"
if (debug.messageEnabled()) {
+ answer);
}
return (answer);
}
// Remove the baseDN and parse the DN
if (index == -1) {
// Try the baseDN
}
}
// Append baseDN and return
if (debug.messageEnabled()) {
}
}
/**
* Returns realm name in "/" separated format for the provided
* realm/organization name in DN format.
*
* @param orgName Name of organization.
* @return DN format "/" separated realm name of organization name.
*/
return "/";
}
) {
return "/";
}
return orgName;
}
// Check if orgName ends with baseDN or serviceDN
}
}
}
/*
* Splits a string and returns the tokens.
*
* @param str original String.
* @return a String Array object of tokens after split.
*/
if (idx != -1) {
}
return strArray;
}
/*
* Replaces a string with another string in a String object.
*
* @param originalString original String.
* @param token string to be replaced.
* @param newString new string to replace token.
* @return a String object after replacement.
*
*/
if (idx >= 0) {
int slashndx =
// This is to escape "/" embedded in realm names.
while (slashndx != -1) {
slashndx =
}
}
}
while (idx != -1) {
}
if (debug.messageEnabled()) {
}
return originalString;
}
/**
* Normalized the DN as per the Realm requirements for organization name
*/
if (debug.messageEnabled()) {
}
if (!realmEnabled) {
}
// Check if orgName is a hidden internal realm,if so prepend with o
if (orgName.toLowerCase().
} else {
}
}
}
/**
* Converts "/" separted organization names to DN
*/
while (strtok.hasMoreElements()) {
}
}
for (int i = 0; i < size; i++) {
// Check if orgdn is a hidden internal realm, if so prepend with o
}
if (i != size - 1) {
}
}
if (debug.messageEnabled()) {
}
if (debug.messageEnabled()) {
}
if (debug.messageEnabled()) {
}
}
return (buf);
}
static void clearCache() {
}
}