Dear Sandesha2 Committers,
Please accept this patch which adds support for RM Policy enforcement at
client-side. It takes a policy which is set as a parameter in the
MessageContext and populate RMPolicyInfo bean which contains
configuration for the set policy. Then that can be used to configure the
client at runtime enforcing RMPolicy at runtime.
Best,
Sanka
Index: src/org/apache/sandesha2/policy/RMPolicyInfo.java
===================================================================
--- src/org/apache/sandesha2/policy/RMPolicyInfo.java (revision 0)
+++ src/org/apache/sandesha2/policy/RMPolicyInfo.java (revision 0)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sandesha2.policy;
+
+/**
+ * @author Sanka Samaranayake ([EMAIL PROTECTED])
+ * @author Chamikara Jayalath ([EMAIL PROTECTED])
+ */
+public class RMPolicyInfo {
+ private long inactiveTimeoutInterval = -1l;
+ private long acknowledgementInterval = -1l;
+ private long retransmissionInterval = -1l;
+ private boolean exponentialBackoff = false;
+
+
+ public RMPolicyInfo() {
+
+ }
+
+ public long getInactiveTimeoutInterval() {
+ return inactiveTimeoutInterval;
+ }
+
+ public long getAcknowledgementInaterval() {
+ return acknowledgementInterval;
+ }
+
+ public long getRetransmissionInterval() {
+ return retransmissionInterval;
+ }
+
+ public boolean getExponentialBackoff() {
+ return exponentialBackoff;
+ }
+
+ public void setExponentialBackoff(boolean exponentialBackoff) {
+ this.exponentialBackoff = exponentialBackoff;
+ }
+
+ public void setRetransmissionInterval(long retransmissionInterval) {
+ this.retransmissionInterval = retransmissionInterval;
+ }
+
+ public void setInactiveTimeoutInterval(long inactiveTimeoutInterval) {
+ this.inactiveTimeoutInterval = inactiveTimeoutInterval;
+ }
+
+ public void setAcknowledgementInterval(long acknowledgementInterval) {
+ this.acknowledgementInterval = acknowledgementInterval;
+ }
+
+
+}
Index: src/org/apache/sandesha2/policy/RMPolicyUtil.java
===================================================================
--- src/org/apache/sandesha2/policy/RMPolicyUtil.java (revision 0)
+++ src/org/apache/sandesha2/policy/RMPolicyUtil.java (revision 0)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.sandesha2.policy;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.policy.model.AndCompositeAssertion;
+import org.apache.policy.model.PrimitiveAssertion;
+import org.apache.sandesha2.SandeshaException;
+/**
+ * @author Sanka Samaranayake ([EMAIL PROTECTED])
+ * @author Chamikara Jayalath ([EMAIL PROTECTED])
+ */
+public class RMPolicyUtil {
+
+ private static final String WSRM_NS = "http://schemas.xmlsoap.org/ws/2005/02/rm/policy";
+
+ public RMPolicyInfo getRMPolicyInfo(MessageContext msgCtx) throws SandeshaException {
+ Parameter parameter = msgCtx.getParameter("POLICY");
+ AndCompositeAssertion aca = (AndCompositeAssertion) parameter.getValue();
+ RMPolicyInfo info = new RMPolicyInfo();
+ Iterator iterator = aca.getTerms().iterator();
+
+ while (iterator.hasNext()) {
+ PrimitiveAssertion prim = (PrimitiveAssertion) iterator.next();
+ if (isRMAssertion(prim)) {
+ processRMAssertion((OMElement) prim.getValue(), info);
+ }
+ }
+ return info;
+ }
+
+ private void processRMAssertion(OMElement element, RMPolicyInfo info) {
+
+ // processing the wsrm:InactiveTimeout
+ OMElement inac = element.getFirstChildWithName(new QName(WSRM_NS, "InactivityTimeout"));
+ if (inac != null) {
+ OMAttribute attribute = inac.getAttribute(new QName("Milliseconds"));
+ String timeMillies = attribute.getAttributeValue();
+ info.setInactiveTimeoutInterval(Long.parseLong(timeMillies));
+ }
+
+ // processing AcknowledgementInterval
+ OMElement ackIn
+ = element.getFirstChildWithName(new QName(WSRM_NS, "AcknowledgementInterval"));
+ if (ackIn != null) {
+ OMAttribute attribute = ackIn.getAttribute(new QName("Milliseconds"));
+ String timeMillies = attribute.getAttributeValue();
+ info.setAcknowledgementInterval(Long.parseLong(timeMillies));
+ }
+
+ // procession BaseRetransmissionInterval
+ OMElement reI
+ = element.getFirstChildWithName(new QName(WSRM_NS, "BaseRetransmissionInterval"));
+ if (reI != null) {
+ OMAttribute attribute = reI.getAttribute(new QName("Milliseconds"));
+ String timeMillies = attribute.getAttributeValue();
+ info.setRetransmissionInterval(Long.parseLong(timeMillies));
+ }
+
+ // processing ExponentialBackoff
+ OMElement exB
+ = element.getFirstChildWithName(new QName(WSRM_NS, "ExponentialBackoff"));
+ if (exB != null) {
+ info.setExponentialBackoff(true);
+ }
+ }
+
+ private boolean isRMAssertion(PrimitiveAssertion pirmitive) {
+ OMElement element = (OMElement) pirmitive.getValue();
+
+ return element.getNamespace().getName().equals(WSRM_NS)
+ || element.getLocalName().equals("RMAssertion");
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]