Search in sources :

Example 6 with PolicyService

use of com.sun.identity.policy.remote.PolicyService in project OpenAM by OpenRock.

the class ResourceResultCache method removeRemotePolicyListener.

/**
     * Removes a listener registered with policy service to recieve
     * notifications on policy changes
     * @param appToken session token identifying the client
     * @param serviceName service name
     * @param notificationURL end point on the client that listens for
     * notifications
     */
public boolean removeRemotePolicyListener(SSOToken appToken, String serviceName, String notificationURL) {
    boolean status = false;
    URL policyServiceURL = null;
    remotePolicyListeners.remove(notificationURL);
    if (appToken != null) {
        try {
            policyServiceURL = getPolicyServiceURL(appToken);
        } catch (PolicyException pe) {
            debug.error("ResourceResultCache.removeRemotePolicyListener():" + "Can not remove policy listner:", pe);
        }
    }
    if ((appToken != null) && (policyServiceURL != null)) {
        RemoveListenerRequest rmReq = new RemoveListenerRequest();
        rmReq.setServiceName(serviceName);
        rmReq.setNotificationURL(notificationURL);
        PolicyRequest policyReq = new PolicyRequest();
        policyReq.setAppSSOToken(appToken.getTokenID().toString());
        policyReq.setMethodID(PolicyRequest.POLICY_REQUEST_REMOVE_POLICY_LISTENER);
        policyReq.setRemoveListenerRequest(rmReq);
        try {
            PolicyService ps = sendPLLRequest(policyServiceURL, policyReq);
            if (ps != null) {
                if (debug.messageEnabled()) {
                    debug.message("ResourceResultCache." + "removeRemotePolicyListener():" + "result=" + ps.toXMLString());
                }
                PolicyResponse psres = ps.getPolicyResponse();
                if (psres.getMethodID() == PolicyResponse.POLICY_REMOVE_LISTENER_RESPONSE) {
                    status = true;
                }
            } else {
                debug.message("ResourceResultCache." + "removeRemotePolicyListener():" + "no result");
            }
        } catch (Exception e) {
            debug.error("ResourceResultCache.removeRemotePolicyListener():", e);
        }
    }
    return status;
}
Also used : PolicyException(com.sun.identity.policy.PolicyException) PolicyService(com.sun.identity.policy.remote.PolicyService) RemoveListenerRequest(com.sun.identity.policy.remote.RemoveListenerRequest) PolicyRequest(com.sun.identity.policy.remote.PolicyRequest) PolicyResponse(com.sun.identity.policy.remote.PolicyResponse) URL(java.net.URL) JSONException(org.json.JSONException) PolicyException(com.sun.identity.policy.PolicyException) SendRequestException(com.iplanet.services.comm.client.SendRequestException) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AlreadyRegisteredException(com.iplanet.services.comm.client.AlreadyRegisteredException) IOException(java.io.IOException) SessionException(com.iplanet.dpro.session.SessionException)

Aggregations

PolicyService (com.sun.identity.policy.remote.PolicyService)6 SendRequestException (com.iplanet.services.comm.client.SendRequestException)5 PolicyException (com.sun.identity.policy.PolicyException)5 PolicyEvaluationException (com.sun.identity.policy.remote.PolicyEvaluationException)5 PolicyRequest (com.sun.identity.policy.remote.PolicyRequest)5 PolicyResponse (com.sun.identity.policy.remote.PolicyResponse)5 URL (java.net.URL)4 SessionException (com.iplanet.dpro.session.SessionException)3 AlreadyRegisteredException (com.iplanet.services.comm.client.AlreadyRegisteredException)3 URLNotFoundException (com.iplanet.services.naming.URLNotFoundException)3 SSOException (com.iplanet.sso.SSOException)3 AdvicesHandleableByAMResponse (com.sun.identity.policy.remote.AdvicesHandleableByAMResponse)3 IOException (java.io.IOException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 JSONException (org.json.JSONException)3 RequestSet (com.iplanet.services.comm.share.RequestSet)2 Response (com.iplanet.services.comm.share.Response)2 AdvicesHandleableByAMRequest (com.sun.identity.policy.remote.AdvicesHandleableByAMRequest)2 PolicyListenerRequest (com.sun.identity.policy.remote.PolicyListenerRequest)2 RemoveListenerRequest (com.sun.identity.policy.remote.RemoveListenerRequest)2