Search in sources :

Example 31 with Session

use of com.iplanet.dpro.session.Session in project OpenAM by OpenRock.

the class ResourceResultCache method getPolicyServiceURL.

/**
    * Returns policy service URL based on session token
    * @param token session token of user
    * @return policy service URL based on session token
    * @throws PolicyException if can not get policy service URL
    */
static URL getPolicyServiceURL(SSOToken token) throws PolicyException {
    URL policyServiceURL = null;
    try {
        String ssoTokenID = token.getTokenID().toString();
        SessionID sid = new SessionID(ssoTokenID);
        Session session = sessionCache.getSession(sid);
        URL sessionServiceURL = session.getSessionServiceURL();
        String protocol = sessionServiceURL.getProtocol();
        String host = sessionServiceURL.getHost();
        int port = sessionServiceURL.getPort();
        String uri = sessionServiceURL.getPath();
        String portString = null;
        if (port == -1) {
            portString = "";
        } else {
            portString = Integer.toString(port);
        }
        policyServiceURL = WebtopNaming.getServiceURL(POLICY_SERVICE_ID_FOR_NAMING, protocol, host, portString, uri);
    } catch (SessionException se) {
        debug.error("ResourceResultCache.getPolicyServiceURL():" + "Can not find policy service URL", se);
        throw new PolicyEvaluationException(ResBundleUtils.rbName, "policy_service_url_not_found", null, se);
    } catch (URLNotFoundException ue) {
        debug.error("ResourceResultCache.getPolicyServiceURL():" + "Can not find policy service URL", ue);
        throw new PolicyEvaluationException(ResBundleUtils.rbName, "policy_service_url_not_found", null, ue);
    }
    return policyServiceURL;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException) SessionID(com.iplanet.dpro.session.SessionID) URL(java.net.URL) Session(com.iplanet.dpro.session.Session)

Aggregations

Session (com.iplanet.dpro.session.Session)31 SessionException (com.iplanet.dpro.session.SessionException)22 SessionID (com.iplanet.dpro.session.SessionID)13 SSOException (com.iplanet.sso.SSOException)7 Test (org.testng.annotations.Test)7 Map (java.util.Map)5 InternalSession (com.iplanet.dpro.session.service.InternalSession)4 BeforeTest (org.testng.annotations.BeforeTest)4 SSOToken (com.iplanet.sso.SSOToken)3 SearchResults (com.sun.identity.common.SearchResults)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 HashMap (java.util.HashMap)3 StatelessSession (org.forgerock.openam.sso.providers.stateless.StatelessSession)3 URL (java.net.URL)2 Iterator (java.util.Iterator)2 SessionEvent (com.iplanet.dpro.session.SessionEvent)1 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)1 SessionService (com.iplanet.dpro.session.service.SessionService)1 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)1 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)1