Search in sources :

Example 1 with RemoveListenerRequest

use of com.sun.identity.policy.remote.RemoveListenerRequest 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

SessionException (com.iplanet.dpro.session.SessionException)1 AlreadyRegisteredException (com.iplanet.services.comm.client.AlreadyRegisteredException)1 SendRequestException (com.iplanet.services.comm.client.SendRequestException)1 URLNotFoundException (com.iplanet.services.naming.URLNotFoundException)1 SSOException (com.iplanet.sso.SSOException)1 PolicyException (com.sun.identity.policy.PolicyException)1 PolicyEvaluationException (com.sun.identity.policy.remote.PolicyEvaluationException)1 PolicyRequest (com.sun.identity.policy.remote.PolicyRequest)1 PolicyResponse (com.sun.identity.policy.remote.PolicyResponse)1 PolicyService (com.sun.identity.policy.remote.PolicyService)1 RemoveListenerRequest (com.sun.identity.policy.remote.RemoveListenerRequest)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 JSONException (org.json.JSONException)1