use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class DNMapper method normalizeDN.
/**
* Normalized the DN as per the Realm requirements for organization name
*/
static String normalizeDN(String orgName) {
String orgAttr = "";
StringBuilder buf = new StringBuilder(orgName.length());
if (debug.messageEnabled()) {
debug.message("DNMapper.normalizeDN():orgName " + orgName);
}
if (!realmEnabled) {
orgAttr = OrgConfigViaAMSDK.getNamingAttrForOrg();
}
String placeHold = (realmEnabled) ? SMSEntry.ORGANIZATION_RDN : orgAttr;
DN dn = DN.valueOf(orgName);
for (RDN rdn : dn) {
// Check if orgName is a hidden internal realm,if so prepend with o
if (orgName.toLowerCase().startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX)) {
buf.append(SMSEntry.ORGANIZATION_RDN);
} else {
buf.append(placeHold);
}
buf.append(SMSEntry.EQUALS).append(rdnValue(rdn)).append(SMSEntry.COMMA);
}
debug.message("DNMapper.normalizeDN():finalorgdn {}", buf);
return buf.toString();
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class OrgConfigViaAMSDK method hideOrgUnits.
/**
* This method checks if the dn starts with org unit naming attr.
* If yes, then it replaces values of all ou's by prefixing
* SMSEntry.SUN_INTERNAL_REALM_NAME because all realms mapping to
* orgUnits are hidden.
* If the dn does not start with org unit naming attr then it is
* returned as-is.
* For example,
* ou=X,ou=Y,o=DevSample,dc=red,dc=iplanet,dc=com
* is replaced with
* ou=sunamhiddenrealmX,ou=sunamhiddenrealmY,o=DevSample,dc=red,dc=iplanet,dc=com
*
* @param orgUnitDN String can not be null
*/
private static String hideOrgUnits(String orgUnitDN) {
String ou = getNamingAttrForOrgUnit();
if (!orgUnitDN.startsWith(ou)) {
return orgUnitDN;
}
DN result = DN.rootDN();
DN rdns = DN.valueOf(orgUnitDN);
for (int i = rdns.size() - 1; i >= 0; i--) {
RDN rdn = rdns.parent(i).rdn();
if (rdnType(rdn).equals(ou)) {
result = result.child(new RDN(ou, SMSEntry.SUN_INTERNAL_REALM_NAME + rdnValue(rdn)));
} else {
result = result.child(rdn);
}
}
return result.toString();
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class AMUserImpl method getAllRoleDNs.
/**
* Gets all the static and filtered roles the user is in.
*
* @return The Set of static and filtered role DN's the user is in.
*/
public Set getAllRoleDNs() throws AMException, SSOException {
Set nsroleANSet = new HashSet(1);
nsroleANSet.add(nsroleAN);
Map nsrolesMap = getAttributesFromDataStore(nsroleANSet);
Set nsroles = (Set) nsrolesMap.get(nsroleAN);
Set result = new HashSet();
Iterator iter = nsroles.iterator();
getAMStoreConnection();
while (iter.hasNext()) {
String nsrole = (String) iter.next();
DN nsroleDN = DN.valueOf(nsrole);
RDN rdn = nsroleDN.rdn();
if (!rdn.equals(ContainerDefaultTemplateRoleRDN) && isAMManagedRole(nsrole)) {
result.add(nsroleDN.toString());
}
}
return result;
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class ConfigManagerUMS method replaceCreationTemplate.
/**
* Replaces an existing template.
*
* @param guid the GUID it is looking under.
* @param templateName Name of the template.
* @param attrSet attribute-values pair to be replaced.
* @exception ConfigManagerException.
*/
public void replaceCreationTemplate(Guid guid, String templateName, AttrSet attrSet) throws ConfigManagerException {
if (guid == null) {
guid = new Guid(_rootDN);
}
DN dn = DN.valueOf(guid.getDn());
String org = "";
List<RDN> rdns = new ArrayList<>();
for (RDN rdn : dn) {
rdns.add(0, rdn);
}
for (RDN rdn : rdns) {
org = org + "/" + LDAPUtils.rdnValue(rdn);
}
String service = CREATIONPATH + "/" + templateName;
Map map = convertToMap(attrSet);
try {
replaceServiceAttributes(org, service, map);
} catch (SMSException e) {
String[] args = new String[1];
args[0] = e.toString();
throw new ConfigManagerException(i18n.getString(IUMSConstants.ERROR_CM, args));
} catch (SSOException se) {
String[] args = new String[1];
args[0] = se.toString();
throw new ConfigManagerException(i18n.getString(IUMSConstants.ERROR_CM, args));
}
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class OrganizationConfigManagerImpl method objectChanged.
public void objectChanged(String dn, int type) {
// Check for listeners
if (listenerObjects.isEmpty()) {
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("OrgConfigMgrImpl::entryChanged" + " No listeners registered: " + dn + "\norgNotificationSearchString: " + orgNotificationSearchString);
}
return;
}
// check for service name, version and type
int index = 0;
int orgIndex = 0;
// ou=services,o=hpq,ou=services,dc=iplanet,dc=com
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("OrgConfigMgrImpl::entryChanged " + " DN: " + dn + "\norgNotificationSearchString: " + orgNotificationSearchString);
}
// Check if the DN matches with organization name
if ((index = dn.indexOf(orgNotificationSearchString)) != -1) {
orgIndex = SMSEntry.SERVICES_RDN.length();
// Initialize parameters
String serviceName = "";
String version = "";
String groupName = "";
String compName = "";
// Get the DN ignoring the organization name
if (index != 0) {
DN ndn = DN.valueOf(dn.substring(0, index - 1));
int size = ndn.size();
// Needs to check if the DN has more realm names
if (size != 0 && "o".equals(LDAPUtils.rdnValue(ndn.rdn()))) {
// this organization
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("OrgConfigMgrImpl::entryChanged Notification " + "not sent since realms names donot match. \nDN: " + dn + " And orgNotificationSearchString: " + orgNotificationSearchString);
}
return;
}
Iterator<RDN> rdnIterator = ndn.iterator();
// Get the version, service, group and component name
if (size > 0) {
serviceName = LDAPUtils.rdnValue(rdnIterator.next());
}
if (size > 1) {
version = LDAPUtils.rdnValue(rdnIterator.next());
}
if (size >= 4) {
//Skip 1 RDNs
rdnIterator.next();
groupName = LDAPUtils.rdnValue(rdnIterator.next());
}
// The subconfig names should be "/" separated and left to right
if (ndn.size() >= 5) {
StringBuilder sbr = new StringBuilder();
while (rdnIterator.hasNext()) {
sbr.append('/').append(LDAPUtils.rdnValue(rdnIterator.next()));
}
compName = sbr.toString();
} else {
compName = "/";
}
}
// Convert changeType from JNDI to com.sun.identity.shared.ldap
switch(type) {
case NamingEvent.OBJECT_ADDED:
type = ServiceListener.ADDED;
break;
case NamingEvent.OBJECT_REMOVED:
type = ServiceListener.REMOVED;
break;
default:
type = ServiceListener.MODIFIED;
}
// Get organization name
String orgName = dn.substring(index + orgIndex + 1);
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() serviceName " + serviceName);
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() version " + version);
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() orgName " + orgName);
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() groupName " + groupName);
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() compName " + compName);
SMSEntry.eventDebug.message("OrganizationConfigManagerImpl:" + "entryChanged() type " + type);
}
// Send notifications to listeners
notifyOrgConfigChange(serviceName, version, orgName, groupName, compName, type);
}
}
Aggregations