Search in sources :

Example 16 with RDN

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;
}
Also used : ArrayList(java.util.ArrayList) RDN(org.forgerock.opendj.ldap.RDN) DN(org.forgerock.opendj.ldap.DN) RDN(org.forgerock.opendj.ldap.RDN)

Example 17 with RDN

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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RDN(org.forgerock.opendj.ldap.RDN) DN(org.forgerock.opendj.ldap.DN) RDN(org.forgerock.opendj.ldap.RDN)

Example 18 with RDN

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, "/");
    }
}
Also used : NameIdentifier(com.sun.identity.saml.assertion.NameIdentifier) RDN(org.forgerock.opendj.ldap.RDN) DN(org.forgerock.opendj.ldap.DN) RDN(org.forgerock.opendj.ldap.RDN)

Aggregations

RDN (org.forgerock.opendj.ldap.RDN)18 DN (org.forgerock.opendj.ldap.DN)17 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 SSOException (com.iplanet.sso.SSOException)3 Map (java.util.Map)3 AMException (com.iplanet.am.sdk.AMException)2 AMStoreConnection (com.iplanet.am.sdk.AMStoreConnection)2 AttrSet (com.iplanet.services.ldap.AttrSet)2 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)2 TreeSet (java.util.TreeSet)2 AMObject (com.iplanet.am.sdk.AMObject)1 AMOrganization (com.iplanet.am.sdk.AMOrganization)1 AMOrganizationalUnit (com.iplanet.am.sdk.AMOrganizationalUnit)1 AMPreCallBackException (com.iplanet.am.sdk.AMPreCallBackException)1 AMRole (com.iplanet.am.sdk.AMRole)1 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)1 AMUser (com.iplanet.am.sdk.AMUser)1