Search in sources :

Example 1 with ServerEntryNotFoundException

use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.

the class SMSJAXRPCObjectImpl method registerNotificationURL.

// Methods to register notification URLs
public String registerNotificationURL(String url) throws RemoteException {
    initialize();
    // Default value if there are any issues with the registration process.
    String id = "0";
    try {
        // Check URL is not the local server
        if (!url.toLowerCase().startsWith(serverURL)) {
            synchronized (notificationURLs) {
                URL notificationUrl = new URL(url);
                // Don't add the URL again if we already have it registered
                boolean alreadyRegistered = false;
                for (Map.Entry<String, URL> entry : notificationURLs.entrySet()) {
                    if (notificationUrl.equals(entry.getValue())) {
                        // This allows us to return the existing entry ID to support clients being able to
                        // de-register the correct entry.
                        id = entry.getKey();
                        alreadyRegistered = true;
                        if (debug.messageEnabled()) {
                            debug.message("SMSJAXRPCObjectImpl:registerNotificationURL() - URL " + url + " already registered, returning existing ID " + id);
                        }
                        break;
                    }
                }
                // If we didn't find the url in our list, add it
                if (!alreadyRegistered) {
                    String serverID = "";
                    try {
                        serverID = WebtopNaming.getAMServerID();
                    } catch (ServerEntryNotFoundException e) {
                        if (debug.messageEnabled()) {
                            debug.message("SMSJAXRPCObjectImpl:registerNotificationURL - " + "had a problem getting our serverID ", e);
                        }
                    }
                    // Generate a unique value that includes the serverID to have a better chance of being unique
                    // in a cluster should a de-register request end up on the wrong server.
                    id = SMSUtils.getUniqueID() + "_" + serverID;
                    notificationURLs.put(id, notificationUrl);
                    if (debug.messageEnabled()) {
                        debug.message("SMSJAXRPCObjectImpl:registerNotificationURL - " + "registered notification URL: " + url + " with ID " + id);
                    }
                }
            }
        } else {
            // Cannot add this server for notifications
            if (debug.warningEnabled()) {
                debug.warning("SMSJAXRPCObjectImpl:registerNotificationURL " + "cannot add local server: " + url);
            }
        }
    } catch (MalformedURLException e) {
        if (debug.warningEnabled()) {
            debug.warning("SMSJAXRPCObjectImpl:registerNotificationURL " + " invalid URL: " + url, e);
        }
    }
    return id;
}
Also used : MalformedURLException(java.net.MalformedURLException) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) URL(java.net.URL)

Example 2 with ServerEntryNotFoundException

use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.

the class DJLDAPv3Repo method initialize.

/**
     * Initializes the IdRepo instance, basically within this method we process
     * the configuration settings and set up the connection factories that will
     * be used later in the lifetime of the IdRepo plugin.
     *
     * @param configParams The IdRepo configuration as defined in the service
     * configurations.
     * @throws IdRepoException Shouldn't be thrown.
     */
@Override
public void initialize(Map<String, Set<String>> configParams) throws IdRepoException {
    if (DEBUG.messageEnabled()) {
        DEBUG.message("initialize invoked");
    }
    super.initialize(configParams);
    String hostServerId = null;
    String hostSiteId = "";
    try {
        hostServerId = WebtopNaming.getAMServerID();
        hostSiteId = WebtopNaming.getSiteID(hostServerId);
    } catch (ServerEntryNotFoundException senfe) {
        if (DEBUG.warningEnabled()) {
            DEBUG.warning("ServerEntryNotFoundException, hostServerId=" + hostServerId + ", hostSiteId=" + hostSiteId);
        }
    }
    dnCacheEnabled = CollectionHelper.getBooleanMapAttr(configMap, LDAP_DNCACHE_ENABLED, true);
    if (dnCacheEnabled) {
        dnCache = new Cache(CollectionHelper.getIntMapAttr(configParams, LDAP_DNCACHE_SIZE, 1500, DEBUG));
    }
    ldapServers = LDAPUtils.prioritizeServers(configParams.get(LDAP_SERVER_LIST), hostServerId, hostSiteId);
    defaultSizeLimit = CollectionHelper.getIntMapAttr(configParams, LDAP_MAX_RESULTS, 100, DEBUG);
    defaultTimeLimit = CollectionHelper.getIntMapAttr(configParams, LDAP_TIME_LIMIT, 5, DEBUG);
    int maxPoolSize = CollectionHelper.getIntMapAttr(configParams, LDAP_CONNECTION_POOL_MAX_SIZE, 10, DEBUG);
    String username = CollectionHelper.getMapAttr(configParams, LDAP_SERVER_USER_NAME);
    char[] password = CollectionHelper.getMapAttr(configParams, LDAP_SERVER_PASSWORD, "").toCharArray();
    heartBeatInterval = CollectionHelper.getIntMapAttr(configParams, LDAP_SERVER_HEARTBEAT_INTERVAL, "10", DEBUG);
    heartBeatTimeUnit = CollectionHelper.getMapAttr(configParams, LDAP_SERVER_HEARTBEAT_TIME_UNIT, "SECONDS");
    String connectionMode = CollectionHelper.getMapAttr(configParams, LDAP_CONNECTION_MODE);
    useStartTLS = LDAP_CONNECTION_MODE_STARTTLS.equalsIgnoreCase(connectionMode);
    isSecure = LDAP_CONNECTION_MODE_LDAPS.equalsIgnoreCase(connectionMode) || useStartTLS;
    bindConnectionFactory = createConnectionFactory(null, null, maxPoolSize);
    connectionFactory = createConnectionFactory(username, password, maxPoolSize);
    supportedTypesAndOperations = IdRepoUtils.parseSupportedTypesAndOperations(configParams.get(LDAP_SUPPORTED_TYPES_AND_OPERATIONS));
    userStatusAttr = CollectionHelper.getMapAttr(configParams, LDAP_USER_STATUS_ATTR_NAME);
    if (userStatusAttr == null || userStatusAttr.isEmpty()) {
        alwaysActive = true;
        userStatusAttr = DEFAULT_USER_STATUS_ATTR;
    }
    activeValue = CollectionHelper.getMapAttr(configParams, LDAP_STATUS_ACTIVE, STATUS_ACTIVE);
    inactiveValue = CollectionHelper.getMapAttr(configParams, LDAP_STATUS_INACTIVE, STATUS_INACTIVE);
    creationAttributeMapping = IdRepoUtils.parseAttributeMapping(configParams.get(LDAP_CREATION_ATTR_MAPPING));
    userNamingAttr = CollectionHelper.getMapAttr(configParams, LDAP_USER_NAMING_ATTR);
    groupNamingAttr = CollectionHelper.getMapAttr(configParams, LDAP_GROUP_NAMING_ATTR);
    roleNamingAttr = CollectionHelper.getMapAttr(configParams, LDAP_ROLE_NAMING_ATTR);
    filteredRoleNamingAttr = CollectionHelper.getMapAttr(configParams, LDAP_FILTERED_ROLE_NAMING_ATTR);
    userSearchAttr = CollectionHelper.getMapAttr(configParams, LDAP_USER_SEARCH_ATTR);
    userAttributesAllowed = new CaseInsensitiveHashSet();
    Set<String> allowAttrs = configParams.get(LDAP_USER_ATTRS);
    if (allowAttrs != null) {
        userAttributesAllowed.addAll(allowAttrs);
    }
    groupAttributesAllowed = new CaseInsensitiveHashSet();
    allowAttrs = configParams.get(LDAP_GROUP_ATTRS);
    if (allowAttrs != null) {
        groupAttributesAllowed.addAll(allowAttrs);
    }
    roleAttributesAllowed = new CaseInsensitiveHashSet();
    allowAttrs = configParams.get(LDAP_ROLE_ATTRS);
    if (allowAttrs != null) {
        roleAttributesAllowed.addAll(allowAttrs);
    }
    filteredRoleAttributesAllowed = new CaseInsensitiveHashSet();
    allowAttrs = configParams.get(LDAP_FILTERED_ROLE_ATTRS);
    if (allowAttrs != null) {
        filteredRoleAttributesAllowed.addAll(allowAttrs);
    }
    userObjectClasses = getNonNullSettingValues(LDAP_USER_OBJECT_CLASS);
    groupObjectClasses = getNonNullSettingValues(LDAP_GROUP_OBJECT_CLASS);
    roleObjectClasses = getNonNullSettingValues(LDAP_ROLE_OBJECT_CLASS);
    filteredRoleObjectClasses = getNonNullSettingValues(LDAP_FILTERED_ROLE_OBJECT_CLASS);
    defaultGroupMember = CollectionHelper.getMapAttr(configParams, LDAP_DEFAULT_GROUP_MEMBER);
    uniqueMemberAttr = CollectionHelper.getMapAttr(configParams, LDAP_UNIQUE_MEMBER, UNIQUE_MEMBER_ATTR);
    memberURLAttr = CollectionHelper.getMapAttr(configParams, LDAP_MEMBER_URL);
    memberOfAttr = CollectionHelper.getMapAttr(configParams, LDAP_MEMBER_OF);
    peopleContainerName = CollectionHelper.getMapAttr(configParams, LDAP_PEOPLE_CONTAINER_NAME);
    peopleContainerValue = CollectionHelper.getMapAttr(configParams, LDAP_PEOPLE_CONTAINER_VALUE);
    groupContainerName = CollectionHelper.getMapAttr(configParams, LDAP_GROUP_CONTAINER_NAME);
    groupContainerValue = CollectionHelper.getMapAttr(configParams, LDAP_GROUP_CONTAINER_VALUE);
    roleAttr = CollectionHelper.getMapAttr(configParams, LDAP_ROLE_ATTR, ROLE_ATTR);
    roleDNAttr = CollectionHelper.getMapAttr(configParams, LDAP_ROLE_DN_ATTR, ROLE_DN_ATTR);
    roleFilterAttr = CollectionHelper.getMapAttr(configParams, LDAP_ROLE_FILTER_ATTR, ROLE_FILTER_ATTR);
    rootSuffix = CollectionHelper.getMapAttr(configParams, LDAP_SERVER_ROOT_SUFFIX);
    userSearchFilter = LDAPUtils.parseFilter(CollectionHelper.getMapAttr(configParams, LDAP_USER_SEARCH_FILTER), Filter.objectClassPresent());
    groupSearchFilter = LDAPUtils.parseFilter(CollectionHelper.getMapAttr(configParams, LDAP_GROUP_SEARCH_FILTER), Filter.objectClassPresent());
    roleSearchFilter = LDAPUtils.parseFilter(CollectionHelper.getMapAttr(configParams, LDAP_ROLE_SEARCH_FILTER), DEFAULT_ROLE_SEARCH_FILTER);
    filteredRoleSearchFilter = LDAPUtils.parseFilter(CollectionHelper.getMapAttr(configParams, LDAP_FILTERED_ROLE_SEARCH_FILTER), DEFAULT_FILTERED_ROLE_SEARCH_FILTER);
    String serviceInfo = CollectionHelper.getMapAttr(configParams, LDAP_SERVICE_ATTRS);
    serviceMap = new HashMap<String, Map<String, Set<String>>>(new SOAPClient("dummy").decodeMap(serviceInfo));
    defaultScope = LDAPUtils.getSearchScope(CollectionHelper.getMapAttr(configParams, LDAP_SEARCH_SCOPE), SearchScope.WHOLE_SUBTREE);
    roleScope = LDAPUtils.getSearchScope(CollectionHelper.getMapAttr(configParams, LDAP_ROLE_SEARCH_SCOPE), SearchScope.WHOLE_SUBTREE);
    if (configParams.containsKey(LDAP_ADAM_TYPE)) {
        helper = new ADAMHelper();
    } else if (configParams.containsKey(LDAP_AD_TYPE)) {
        helper = new ADHelper();
    } else {
        helper = new DirectoryHelper();
    }
    if (DEBUG.messageEnabled()) {
        DEBUG.message("IdRepo configuration:\n" + IdRepoUtils.getAttrMapWithoutPasswordAttrs(configMap, asSet(LDAP_SERVER_PASSWORD)));
    }
}
Also used : ADHelper(org.forgerock.openam.idrepo.ldap.helpers.ADHelper) ADAMHelper(org.forgerock.openam.idrepo.ldap.helpers.ADAMHelper) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) ByteString(org.forgerock.opendj.ldap.ByteString) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) DirectoryHelper(org.forgerock.openam.idrepo.ldap.helpers.DirectoryHelper) SOAPClient(com.sun.identity.shared.jaxrpc.SOAPClient) Map(java.util.Map) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Cache(com.iplanet.am.util.Cache)

Example 3 with ServerEntryNotFoundException

use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.

the class ExternalLdapConfig method getLDAPURLs.

/**
     * The hosts to connect to.
     * @return A set of connection details with serverId/siteId preferences.
     */
public Set<LDAPURL> getLDAPURLs() {
    String serverId = null;
    String siteId = "";
    try {
        serverId = WebtopNaming.getAMServerID();
        siteId = WebtopNaming.getSiteID(serverId);
    } catch (ServerEntryNotFoundException senfe) {
        if (debug.warningEnabled()) {
            debug.warning("ServerEntryNotFoundException, serverId=" + serverId + ", siteId=" + siteId);
        }
    }
    String hosts = this.hosts.get();
    Set<String> urls = new LinkedHashSet<String>();
    urls.addAll(Arrays.asList(hosts.split(",")));
    boolean isSSL = isSSLMode();
    Set<LDAPURL> ldapurls = new LinkedHashSet<LDAPURL>();
    for (LDAPURL url : LDAPUtils.prioritizeServers(urls, serverId, siteId)) {
        ldapurls.add(LDAPURL.valueOf(url.getHost(), url.getPort(), isSSL));
    }
    if (debug.messageEnabled()) {
        debug.message("Priotized server list [" + hosts + "] using server ID [" + serverId + "] and site ID [" + siteId + "]");
    }
    return ldapurls;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) LDAPURL(org.forgerock.openam.ldap.LDAPURL)

Example 4 with ServerEntryNotFoundException

use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.

the class WebtopNamingSiteUtils method getSiteNodeURLs.

/**
     * Determines the Site (if any) that the Session is based in, and then calculates
     * the Servers that make up that Site.
     *
     * @param session Non null Session to use for query.
     *
     * @return The URLs for each node in the Site that the Session belongs to. If the
     * Session comes from a Server that is not part of a Site, then just the URL for
     * that Server will be returned. Never null.
     *
     * @throws IllegalStateException Thrown if WebtopNaming returned an invalid URL.
     */
public Set<URL> getSiteNodeURLs(Session session) {
    Set<URL> urls = new HashSet<URL>();
    for (String node : getSiteNodes(session)) {
        try {
            URL url = new URL(query.getServerFromID(node));
            urls.add(url);
        } catch (MalformedURLException e) {
            String err = "WebtopNaming returned invalid URL";
            debug.error(err, e);
            throw new IllegalStateException(err, e);
        } catch (ServerEntryNotFoundException e) {
            debug.error("Server not found.", e);
            continue;
        }
    }
    return urls;
}
Also used : MalformedURLException(java.net.MalformedURLException) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) URL(java.net.URL) HashSet(java.util.HashSet)

Example 5 with ServerEntryNotFoundException

use of com.iplanet.services.naming.ServerEntryNotFoundException in project OpenAM by OpenRock.

the class AuthClientUtils method setHostUrlCookie.

public static void setHostUrlCookie(HttpServletResponse response) {
    if (isSessionHijackingEnabled) {
        String hostUrlCookieValue = null;
        try {
            String siteID = WebtopNaming.getSiteID(WebtopNaming.getAMServerID());
            hostUrlCookieValue = WebtopNaming.getServerFromID(siteID);
            String uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
            hostUrlCookieValue = hostUrlCookieValue.substring(0, (hostUrlCookieValue.length() - uri.length()));
        } catch (ServerEntryNotFoundException e) {
            utilDebug.message("AuthClientUtils.setHostUrlCookie:", e);
        }
        if (hostUrlCookieValue == null || hostUrlCookieValue.length() == 0) {
            String authServerProtocol = SystemProperties.get(Constants.AM_SERVER_PROTOCOL);
            String authServer = SystemProperties.get(Constants.AM_SERVER_HOST);
            String authServerPort = SystemProperties.get(Constants.AM_SERVER_PORT);
            hostUrlCookieValue = authServerProtocol + "://" + authServer + ":" + authServerPort;
        }
        if (utilDebug.messageEnabled()) {
            utilDebug.message("AuthClientUtils.setHostUrlCookie: " + "hostUrlCookieName = " + hostUrlCookieName + ", hostUrlCookieDomain = " + hostUrlCookieDomain + ", hostUrlCookieValue = " + hostUrlCookieValue);
        }
        // Create Cookie
        try {
            Cookie cookie = createCookie(hostUrlCookieName, hostUrlCookieValue, hostUrlCookieDomain);
            CookieUtils.addCookieToResponse(response, cookie);
        } catch (Exception e) {
            utilDebug.message("AuthClientUtils.setHostUrlCookie:", e);
        }
    }
}
Also used : Cookie(javax.servlet.http.Cookie) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) SMSException(com.sun.identity.sm.SMSException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AuthException(com.sun.identity.authentication.service.AuthException) SessionException(com.iplanet.dpro.session.SessionException)

Aggregations

ServerEntryNotFoundException (com.iplanet.services.naming.ServerEntryNotFoundException)6 MalformedURLException (java.net.MalformedURLException)4 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Cache (com.iplanet.am.util.Cache)1 SessionException (com.iplanet.dpro.session.SessionException)1 SSOException (com.iplanet.sso.SSOException)1 AuthException (com.sun.identity.authentication.service.AuthException)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 PolicyException (com.sun.identity.policy.PolicyException)1 SOAPClient (com.sun.identity.shared.jaxrpc.SOAPClient)1 SMSException (com.sun.identity.sm.SMSException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1