Class WebtopNaming


  • public class WebtopNaming
    extends Object
    The WebtopNaming class is used to get URLs for various services such as session, profile, logging etc. The lookup is based on the service name and the host name. The Naming Service shall contain URLs for all services on all servers. For instance, two machines might host session services. The Naming Service profile may look like the following:
          host1.session.URL="http://host1:8080/SessionServlet"
          host2.session.URL="https://host2:9090/SessionServlet"
     
    • Field Detail

      • NAMING_SERVICE

        public static final String NAMING_SERVICE
        The unique identifier for the Naming Service.
        See Also:
        Constant Field Values
      • NODE_SEPARATOR

        public static final String NODE_SEPARATOR
        The delimiter used to separate server IDs in the service attribute.
        See Also:
        Constant Field Values
      • debug

        protected static Debug debug
        The debug instance.
    • Constructor Detail

      • WebtopNaming

        public WebtopNaming()
    • Method Detail

      • initialize

        public static void initialize()
      • isServerMode

        public static boolean isServerMode()
        Determines whether WebtopNaming code runs in the core server mode or in the client SDK run-time mode.
        Returns:
        true running in the core server mode, false otherwise
      • isServer

        public static boolean isServer​(String serverID)
        Tells whether the provided ID belongs to a server or not.
        Parameters:
        serverID - The ID that needs to be checked.
        Returns:
        true if the ID corresponds to a server.
      • isSite

        public static boolean isSite​(String siteID)
        Tells whether the provided ID belongs to a site or not.
        Parameters:
        siteID - The ID that needs to be checked.
        Returns:
        true if the ID corresponds to a site.
      • isSecondarySite

        public static boolean isSecondarySite​(String secondarySiteID)
        Tells whether the provided ID belongs to a secondary site or not.
        Parameters:
        secondarySiteID - The ID that needs to be checked.
        Returns:
        true if the ID corresponds to a secondary site.
      • isSiteEnabled

        public static boolean isSiteEnabled​(String protocol,
                                            String host,
                                            String port,
                                            String uri)
                                     throws Exception
        Determines whether Site is enabled for the given server instance.
        Parameters:
        protocol - protocol of the server instance
        host - host of the server instance
        port - port of the server instance
        uri - uri of the server instance
        Returns:
        true if Site is enabled, false otherwise
        Throws:
        Exception - if server entry is not found or there is any other run-time error
      • isSiteEnabled

        public static boolean isSiteEnabled​(String serverid)
                                     throws Exception
        Determines whether Site is enabled for the given server ID.
        Parameters:
        serverid - server ID
        Returns:
        true if Site is enabled, false otherwise
        Throws:
        Exception - if the given server ID is null
      • getServiceURL

        public static URL getServiceURL​(String service,
                                        String protocol,
                                        String host,
                                        String port,
                                        String uri)
                                 throws URLNotFoundException
        Returns the URL of the specified service on the specified host.
        Parameters:
        service - the name of the service.
        protocol - the service protocol
        host - the service host name
        port - the service listening port
        uri - the deployment uri
        Returns:
        the URL of the specified service on the specified host.
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • getServiceURL

        public static URL getServiceURL​(String service,
                                        URL url,
                                        boolean validate)
                                 throws URLNotFoundException
        Returns the URL of the specified service on the specified host.
        Parameters:
        service - the name of the service.
        url - the deployment URI.
        validate - a boolean value indicate whether or not to validate the protocol, host and port of the server
        Returns:
        the URL of the specified service on the specified host.
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • getServiceURL

        public static URL getServiceURL​(String service,
                                        String protocol,
                                        String host,
                                        String port,
                                        boolean validate)
                                 throws URLNotFoundException
        Returns the URL of the specified service on the specified host.
        Parameters:
        service - the name of the service.
        protocol - the service protocol.
        host - the service host name.
        port - the ervice listening port.
        validate - a boolean value indicate whether or not to validate the protocol, host and port of the server
        Returns:
        the URL of the specified service on the specified host.
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • mapSiteToServer

        public static String mapSiteToServer​(SessionID sid)
                                      throws URLNotFoundException
        Return the mapped server URL if there is a site. Otherwise, return the server URL from the session.
        Parameters:
        sid - the session
        Returns:
        the site URL
        Throws:
        URLNotFoundException
      • getServiceURL

        public static URL getServiceURL​(String service,
                                        String protocol,
                                        String host,
                                        String port,
                                        String uri,
                                        boolean validate)
                                 throws URLNotFoundException
        Returns the URL of the specified service on the specified host.
        Parameters:
        service - name of the service.
        protocol - service protocol.
        host - service host name.
        port - service listening port.
        uri - the deployment uri.
        validate - a boolean value indicate whether or not to validate the protocol, host and port of the server.
        Returns:
        the URL of the specified service on the specified host.
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • getServiceAllURLs

        public static Vector getServiceAllURLs​(String service)
                                        throws URLNotFoundException
        Returns all the URLs of the specified service based on the servers in platform server list.
        Parameters:
        service - the name of the service.
        Returns:
        the URL of the specified service on the specified host.
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • getBaseURLs

        public static List<String> getBaseURLs()
                                        throws URLNotFoundException
        The idea behind this function is to returns the base URLs of the OpenAM instances, without any of the extras that getServiceAllURLs provides - i.e. we don't want a specific service, we just want the base URL.
        Returns:
        the URLs of the OpenAM instances we can contact.
        Throws:
        URLNotFoundException - if the Naming Service cannot find a URL for a specified service
      • getPlatformServerList

        public static Set<String> getPlatformServerList()
                                                 throws Exception
        Returns the platform server list. Note: Calling this method would dont cause performance impact, as it involves xml request over the wire.
        Returns:
        platform server list
        Throws:
        Exception - if an error occurs when updating the naming table
      • getPlatformServerList

        public static Set<String> getPlatformServerList​(boolean update)
                                                 throws Exception
        Returns the platform server list.
        Parameters:
        update - a boolean flag indicating whether a refresh of the naming profile is needed.
        Returns:
        platform server list
        Throws:
        Exception - if an error occurs when updating the nameing table
      • getLocalServer

        public static String getLocalServer()
        Returns local server name from naming table.
        Returns:
        server name opensso is deployed.
      • getServerID

        public static String getServerID​(String protocol,
                                         String host,
                                         String port,
                                         String uri)
                                  throws ServerEntryNotFoundException
        Returns the server ID that is there in the platform server list for a corresponding server.
        Parameters:
        protocol - procotol of the server instance
        host - host of the server instance
        port - port of the server instance
        uri - uri of the server instance
        Returns:
        Server ID
        Throws:
        ServerEntryNotFoundException - if the Naming Service can not find that server entry
      • getServerID

        public static String getServerID​(String protocol,
                                         String host,
                                         String port,
                                         String uri,
                                         boolean updatetbl)
                                  throws ServerEntryNotFoundException
        Returns the server ID that is there in the platform server list for a corresponding server.
        Parameters:
        protocol - procotol of the server instance
        host - host of the server instance
        port - port of the server instance
        uri - uri of the server instance
        updatetbl - a boolean flag indicating whether a refresh of the naming profile is needed.
        Returns:
        Server ID
        Throws:
        ServerEntryNotFoundException - if the Naming Service can not find that server entry
      • getAllServerIDs

        public static Collection<String> getAllServerIDs()
                                                  throws Exception
        Returns all server IDs.
        Returns:
        all server IDs.
        Throws:
        Exception - if an error occurs when updating the nameing table
      • getLBCookieValue

        public static String getLBCookieValue​(String serverid)
        Returns the lbCookieValue corresponding to the server ID.
        Parameters:
        serverid - the server id
        Returns:
        the LB cookie value corresponding to server ID
      • getSiteID

        public static String getSiteID​(String protocol,
                                       String host,
                                       String port,
                                       String uri)
                                throws ServerEntryNotFoundException
        Returns the unique identifier of the site which the given server instance belongs to.
        Parameters:
        protocol - procotol of the server instance
        host - host of the server instance
        port - port of the server instance
        uri - uri of the server instance
        Returns:
        Site ID
        Throws:
        ServerEntryNotFoundException - if the Naming Service can not find that server entry
      • getSiteID

        public static String getSiteID​(String serverid)
        Returns the unique identifier of the site which the given server instance belongs to.
        Parameters:
        serverid - server ID
        Returns:
        Site ID or null if the Server ID is not known.
      • getSiteIdByName

        public static String getSiteIdByName​(String siteName)
      • getSiteNameById

        public static String getSiteNameById​(String siteId)
      • getSecondarySites

        public static String getSecondarySites​(String protocol,
                                               String host,
                                               String port,
                                               String uri)
                                        throws ServerEntryNotFoundException
        Returns the String representation of the separator delimited secondary site list.
        Parameters:
        protocol - procotol of the server instance
        host - host of the server instance
        port - port of the server instance
        uri - uri of the server instance
        Returns:
        the secondary site list
        Throws:
        ServerEntryNotFoundException - if the Naming Service can not find that server entry
      • getSecondarySites

        public static String getSecondarySites​(String serverid)
        Returns the String representation of the separator delimited secondary site list.
        Parameters:
        serverid - server ID
        Returns:
        the secondary site list
      • getSiteNodes

        public static Set<String> getSiteNodes​(String serverid)
                                        throws Exception
        Returns all the node ID for the site.
        Parameters:
        serverid - one of server IDs within the site, it can also be the loab balancer's ID
        Returns:
        HashSet has all the node is for the site.
        Throws:
        Exception - if an error occurs when updating the nameing table
      • getServiceClass

        public static String getServiceClass​(String service)
                                      throws ClassNotFoundException
        Returns the class of the specified service.
        Parameters:
        service - the name of the service.
        Returns:
        The class name of the specified service.
        Throws:
        ClassNotFoundException - if no definition for the class with the specified name could be found.
      • getNotificationURL

        public static URL getNotificationURL()
                                      throws URLNotFoundException
        Returns the URL of the notification service on the local host.
        Returns:
        the notification URL
        Throws:
        URLNotFoundException - if the Naming Service can not find a URL for a specified service
      • updateNamingTable

        public static void updateNamingTable()
                                      throws Exception
        Triggers the update of the NamingTable by examining the contents of NamingService for the naming information. Assembles this int a table of Servers and Sites that make up the platform.
        Throws:
        Exception - If there was an error processing naming information.
      • getNamingServiceURL

        public static String[] getNamingServiceURL()
                                            throws Exception
        Returns a list of the naming service urls.
        Returns:
        a String array of naming service urls.
        Throws:
        Exception - if there is no configured url or there is an error when trying to get the urls
      • removeFailedSite

        public static void removeFailedSite​(String server)
        Removes a server from the available site list.
        Parameters:
        server - the String to parse as a URL of the server to be removed from the site list
      • removeFailedSite

        public static void removeFailedSite​(URL url)
        Removes a server from the available site list.
        Parameters:
        url - url of the server to be removed from the site list
      • getURI

        public static String getURI​(URL url)
        Returns the uri of the specified URL.
        Parameters:
        url - the URL that includes uri.
        Returns:
        a uri of the specified URL.
      • configMonitoring

        public static int configMonitoring()
        Provides the Monitoring Agent site and server related information.
        Returns:
        0 (zero) if all information collected and provided successfully; -1 if server protocol, hostname, port or URI is null; -2 if not serverMode, or Monitoring Agent already running -3 if unable to get the ServerID
      • getSessionIDCorrector

        public static SessionIDCorrector getSessionIDCorrector()
        When server/site configuration changes, Sessions issued against the previous configuration will be out of date and refer to an invalid configuration. SessionIDCorrector can compensate for these changes.
        Returns:
        Null if WebtopNaming has not been configured, otherwise the instance of SessionIDCorrector associated with the WebtopNaming configuration.