Search in sources :

Example 1 with PolicyNotification

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

the class PolicyNotificationHandler method processPLLNotifications.

/**
     * Processes PLL notifications
     * @param notifications PLL notification to be processed
     */
void processPLLNotifications(Vector notifications) {
    for (int i = 0; i < notifications.size(); i++) {
        Notification notification = (Notification) notifications.elementAt(i);
        if (debug.messageEnabled()) {
            debug.message("PolicyNotificationHandler." + "processPLLNotifications():" + "got notification: " + notification.getContent());
        }
        try {
            PolicyService ps = PolicyService.parseXML(notification.getContent());
            PolicyNotification pn = ps.getPolicyNotification();
            if (pn != null) {
                processPolicyNotification(pn);
            }
        } catch (PolicyException pe) {
            debug.error("PolicyNotificationHandler." + "processPLLNotifications():" + "invalid notifcation format", pe);
        }
    }
}
Also used : PolicyNotification(com.sun.identity.policy.remote.PolicyNotification) PolicyException(com.sun.identity.policy.PolicyException) PolicyService(com.sun.identity.policy.remote.PolicyService) Notification(com.iplanet.services.comm.share.Notification) PolicyNotification(com.sun.identity.policy.remote.PolicyNotification)

Example 2 with PolicyNotification

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

the class ResultsCacheUtil method extractPolicyNotification.

/**
     * Returns the notification XML node
     *
     * @param xml XML node
     *
     * @return XML Notification node
     *
     * @throws PolicyEvaluationException 
     *
     */
private static PolicyNotification extractPolicyNotification(String xml) throws PolicyEvaluationException {
    PolicyNotification policyNotification = null;
    try {
        String notificationDataBlock = getNotificationDataBlock(xml);
        if (notificationDataBlock != null) {
            Document doc = XMLUtils.getXMLDocument(new ByteArrayInputStream(notificationDataBlock.getBytes()));
            Node rootNode = XMLUtils.getRootNode(doc, NODE_POLICY_SERVICE);
            if (rootNode != null) {
                Node notificationNode = XMLUtils.getChildNode(rootNode, NODE_POLICY_NOTIFICATION);
                if (notificationNode != null) {
                    policyNotification = PolicyNotification.parseXML(notificationNode);
                } else {
                    debug.error("ResultsCacheUtil." + "extractPolicyNotification():" + "cannot find notification node");
                    throw new PolicyEvaluationException(ResBundleUtils.rbName, "invalid_root_element", null, null);
                }
            } else {
                debug.error("ResultsCacheUtil." + "extractPolicyNotification():");
            }
        } else {
            //null notification data block
            debug.error("ResultsCacheUtil:" + "extractPolicyNotification():" + "notification data block is null");
        }
    } catch (Exception xe) {
        debug.error("ResultsCacheUtil.extractPolicyNotification():", xe);
        throw new PolicyEvaluationException(ResBundleUtils.rbName, "xml_parsing_error", null, xe);
    }
    return policyNotification;
}
Also used : PolicyNotification(com.sun.identity.policy.remote.PolicyNotification) ByteArrayInputStream(java.io.ByteArrayInputStream) Node(org.w3c.dom.Node) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) Document(org.w3c.dom.Document) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException)

Aggregations

PolicyNotification (com.sun.identity.policy.remote.PolicyNotification)2 Notification (com.iplanet.services.comm.share.Notification)1 PolicyException (com.sun.identity.policy.PolicyException)1 PolicyEvaluationException (com.sun.identity.policy.remote.PolicyEvaluationException)1 PolicyService (com.sun.identity.policy.remote.PolicyService)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1