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;
}
Aggregations