use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class PolicyUtils method getDNDisplayString.
/**
* Returns a display string for an LDAP distinguished name.
*
* @param strDN distinguished name.
* @return display string for the LDAP distinguished name.
*/
public static String getDNDisplayString(String strDN) {
String displayString = null;
/*
* Given a value of cn=Accounting Managers,ou=groups,dc=iplanet,dc=com,
* this method returns com > iplanet > groups > Accounting Managers
*/
DN dn = DN.valueOf(strDN);
if (!LDAPUtils.isDN(strDN)) {
displayString = strDN;
} else {
List<RDN> rdns = new ArrayList<>();
for (RDN rdn : dn) {
rdns.add(0, rdn);
}
StringBuilder buff = new StringBuilder(1024);
for (int i = 0; i < rdns.size(); i++) {
RDN rdn = rdns.get(i);
buff.append(LDAPUtils.rdnValue(rdn));
if (i < rdns.size() - 1) {
buff.append(" > ");
}
}
displayString = buff.toString();
}
return displayString;
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class ServiceConfigManagerImpl method objectChanged.
public void objectChanged(String dn, int type) {
// Check for listeners
if ((listenerObjects == null) || listenerObjects.isEmpty()) {
// No listeners registered
return;
}
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("ServiceConfigManagerImpl(" + serviceName + "):objectChanged Received notification for " + "DN: " + dn);
}
// check for service name, version and type
boolean globalConfig = false;
boolean orgConfig = false;
int index = 0, orgIndex = 0;
dn = DNUtils.normalizeDN(dn);
if ((index = dn.indexOf(orgNotificationSearchString)) != -1) {
orgConfig = true;
if (index == 0) {
// No data is stored in this node
return;
}
orgIndex = orgNotificationSearchString.length();
} else if ((index = dn.indexOf(glbNotificationSearchString)) != -1) {
globalConfig = true;
} else if ((index = dn.indexOf(schemaNotificationSearchString)) != -1) {
// Global schema changes, resulting in config change
globalConfig = true;
orgConfig = true;
} else if (serviceName.equalsIgnoreCase("sunidentityrepositoryservice") && (dn.startsWith(SMSEntry.ORG_PLACEHOLDER_RDN) || dn.equalsIgnoreCase(DNMapper.serviceDN))) {
// Since sunIdentityRepositoryService has realm creation
// attributes, we need to send notification
orgConfig = true;
} else {
// Notification DN does not match the servic ename
return;
}
// Get the group and component name
String groupName = "";
String compName = "";
if (index > 1) {
DN compDn = DN.valueOf(dn.substring(0, index - 1));
List<RDN> rdns = new ArrayList<>();
for (RDN rdn : compDn) {
rdns.add(rdn);
}
groupName = rdnValue(rdns.get(rdns.size() - 1));
for (int i = rdns.size() - 2; i > -1; i--) {
compName = compName + "/" + rdnValue(rdns.get(i));
}
}
// 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;
if (globalConfig && orgConfig) {
// Schema change, use base DN
orgName = ServiceManager.getBaseDN();
} else if ((index >= 0) && orgConfig) {
// Get org name
orgName = dn.substring(index + orgIndex + 1);
}
if (globalConfig) {
notifyGlobalConfigChange(groupName, compName, type);
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("ServiceConfigManagerImpl(" + serviceName + "):entryChanged Sending global config change " + "notifications for DN " + dn);
}
}
if (orgConfig) {
notifyOrgConfigChange(orgName, groupName, compName, type);
if (SMSEntry.eventDebug.messageEnabled()) {
SMSEntry.eventDebug.message("ServiceConfigManagerImpl(" + serviceName + "):entryChanged Sending org config change " + "notifications for DN " + dn);
}
}
}
use of org.forgerock.opendj.ldap.RDN in project OpenAM by OpenRock.
the class DefaultPartnerAccountMapper method getUser.
protected void getUser(Subject subject, String sourceID, Map<String, String> map) {
// No need to check SSO in SubjectConfirmation here
// since AssertionManager will handle it without calling account mapper
NameIdentifier nameIdentifier = subject.getNameIdentifier();
if (nameIdentifier != null) {
String name = nameIdentifier.getName();
String org = nameIdentifier.getNameQualifier();
String rootSuffix = SMSEntry.getRootSuffix();
if (name != null && (name.length() != 0)) {
if (org != null && (org.length() != 0)) {
DN dn1 = DN.valueOf(name);
DN dn2 = DN.valueOf(org);
if (dn1.isInScopeOf(dn2, SearchScope.SUBORDINATES)) {
StringBuilder sb = new StringBuilder(50);
for (RDN rdn : dn1) {
sb.append(rdn.toString()).append(",");
}
sb.append(rootSuffix);
if (SAMLUtils.debug.messageEnabled()) {
SAMLUtils.debug.message("DefaultPAccountMapper: " + "name = " + sb.toString());
}
map.put(NAME, sb.toString());
} else {
SAMLUtils.debug.warning("DefaultPAMapper:to anonymous");
// map to anonymous user
map.put(NAME, ANONYMOUS_USER);
}
} else {
SAMLUtils.debug.warning("DefaultAccountMapper: Org null.");
// map to anonymous user
map.put(NAME, ANONYMOUS_USER);
}
} else {
SAMLUtils.debug.warning("DefaultAccountMapper: Name is null");
// map to anonymous user
map.put(NAME, ANONYMOUS_USER);
}
map.put(ORG, "/");
}
}
Aggregations