You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2007/04/23 11:55:16 UTC
svn commit: r531400 [5/18] - in /webservices/sandesha/trunk/java/modules:
client/ core/ core/src/ core/src/main/ core/src/main/java/
core/src/main/java/org/ core/src/main/java/org/apache/
core/src/main/java/org/apache/sandesha2/ core/src/main/java/org/...
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/RMPolicyExtension.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/RMPolicyExtension.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/RMPolicyExtension.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/RMPolicyExtension.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 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.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.modules.PolicyExtension;
+import org.apache.neethi.Policy;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class RMPolicyExtension implements PolicyExtension {
+
+ public void addMethodsToStub(Document document, Element element, QName opName, Policy policy) {
+
+ Element methods = document.createElement("reliableMessagingMethods");
+
+ Element startSequence = document.createElement("createSequence");
+ methods.appendChild(startSequence);
+
+ Element setLastMessage = document.createElement("setLastMessage");
+ methods.appendChild(setLastMessage);
+
+ Element endSequence = document.createElement("endSequence");
+ methods.appendChild(endSequence);
+
+ element.appendChild(methods);
+ }
+
+ public void addMethodsToStub(Document document, Element element, QName methodName, List assertions) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/SandeshaPolicyBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,602 @@
+/*
+ * Copyright 1999-2004 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.ArrayList;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Constants;
+import org.apache.neethi.PolicyComponent;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+
+/**
+ * Used to hold peoperties loaded from sandesha2.properties file or
+ * Sandesha2Constants.
+ */
+
+public class SandeshaPolicyBean implements Assertion {
+
+ private SandeshaPolicyBean parent = null;
+
+ // String storageManagerClass = null;
+ boolean inOrder = true;
+ private boolean inOrderSet = false;
+
+ ArrayList msgTypesToDrop = null;
+
+ private String inMemoryStorageManagerClass = null;
+
+ private String permanentStorageManagerClass = null;
+
+ private String securityManagerClass = null;
+
+ private long inactiveTimeoutValue;
+ private boolean inactiveTimeoutValueSet = false;
+
+ private String inactivityTimeoutMeasure;
+
+ private long inactivityTimeoutInterval = -1;
+ private boolean inactivityTimeoutIntervalSet = false;
+
+ private long sequenceRemovalTimeoutValue;
+ private String sequenceRemovalTimeoutMeasure;
+
+ private long sequenceRemovalTimeoutInterval = -1;
+ private boolean sequenceRemovalTimeoutIntervalSet = false;
+
+ private long acknowledgementInterval;
+ private boolean acknowledgementIntervalSet = false;
+
+ private long retransmissionInterval;
+ private boolean retransmissionIntervalSet = false;
+
+ private boolean exponentialBackoff;
+ private boolean exponentialBackoffSet = false;
+
+ private int maximumRetransmissionCount;
+ private boolean maximumRetransmissionCountSet = false;
+
+ private boolean enableMakeConnection;
+ private boolean enableMakeConnectionSet = false;
+
+ private boolean enableRMAnonURI;
+ private boolean enableRMAnonURISet = false;
+
+ private boolean useMessageSerialization;
+ private boolean useMessageSerializationSet = false;
+
+ private boolean enforceRM;
+ private boolean enforceRMSet = false;
+
+ public void setInactiveTimeoutInterval(long value, String measure) {
+ long timeOut = -1;
+
+ if (measure == null) {
+ this.inactivityTimeoutInterval = value;
+ } else if ("seconds".equals(measure)) {
+ timeOut = value * 1000;
+ } else if ("minutes".equals(measure)) {
+ timeOut = value * 60 * 1000;
+ } else if ("hours".equals(measure)) {
+ timeOut = value * 60 * 60 * 1000;
+ } else if ("days".equals(measure)) {
+ timeOut = value * 24 * 60 * 60 * 1000;
+ }
+
+ this.inactivityTimeoutInterval = timeOut;
+
+ }
+
+ public void setSequenceRemovalTimeoutInterval(long value, String measure) {
+ long timeOut = 0;
+
+ if (measure == null) {
+ this.sequenceRemovalTimeoutInterval = value;
+ } else if ("seconds".equals(measure)) {
+ timeOut = value * 1000;
+ } else if ("minutes".equals(measure)) {
+ timeOut = value * 60 * 1000;
+ } else if ("hours".equals(measure)) {
+ timeOut = value * 60 * 60 * 1000;
+ } else if ("days".equals(measure)) {
+ timeOut = value * 24 * 60 * 60 * 1000;
+ }
+
+ this.sequenceRemovalTimeoutInterval = timeOut;
+
+ }
+
+ public void setAcknowledgementInterval(long acknowledgementInterval) {
+ this.acknowledgementInterval = acknowledgementInterval;
+ setAcknowledgementIntervalSet(true);
+ }
+
+ public String getInMemoryStorageManagerClass() {
+ return inMemoryStorageManagerClass;
+ }
+
+ public void setInMemoryStorageManagerClass(
+ String inMemoryStorageManagerClass) {
+ this.inMemoryStorageManagerClass = inMemoryStorageManagerClass;
+ }
+
+ public String getPermanentStorageManagerClass() {
+ return permanentStorageManagerClass;
+ }
+
+ public void setPermanentStorageManagerClass(
+ String permanentStorageManagerClass) {
+ this.permanentStorageManagerClass = permanentStorageManagerClass;
+ }
+
+ public boolean isInOrder() {
+ return inOrder;
+ }
+
+ public void setInOrder(boolean inOrder) {
+ this.inOrder = inOrder;
+ setInOrderSet(true);
+ }
+
+ public ArrayList getMsgTypesToDrop() {
+ return msgTypesToDrop;
+ }
+
+ public void setMsgTypesToDrop(ArrayList msgTypesToDrop) {
+ this.msgTypesToDrop = msgTypesToDrop;
+ }
+
+ public void addMsgTypeToDrop(Integer typeNo) {
+
+ if (typeNo != null) {
+ if (msgTypesToDrop == null)
+ msgTypesToDrop = new ArrayList();
+
+ msgTypesToDrop.add(typeNo);
+ }
+ }
+
+ public int getMaximumRetransmissionCount() throws SandeshaException {
+
+ if (isMaximumRetransmissionCountSet()) {
+ return maximumRetransmissionCount;
+ } else if (parent!=null) {
+ return parent.getMaximumRetransmissionCount();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_MAX_RETRANS_COUNT);
+ throw new SandeshaException (message);
+ }
+
+ }
+
+ public void setMaximumRetransmissionCount(int maximumRetransmissionCount) {
+ this.maximumRetransmissionCount = maximumRetransmissionCount;
+ setMaximumRetransmissionCountSet(true);
+ }
+
+ public String getSecurityManagerClass() {
+ return securityManagerClass;
+ }
+
+ public void setSecurityManagerClass(String className) {
+ this.securityManagerClass = className;
+ }
+
+ public QName getName() {
+ return Sandesha2Constants.Assertions.Q_ELEM__RMBEAN;
+ }
+
+ public boolean isOptional() {
+ return false;
+ }
+
+ public PolicyComponent normalize() {
+ return this;
+ }
+
+ public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+ try {
+ String localName = Sandesha2Constants.Assertions.Q_ELEM_RMASSERTION
+ .getLocalPart();
+ String namespaceURI = Sandesha2Constants.Assertions.Q_ELEM_RMASSERTION
+ .getNamespaceURI();
+
+ String prefix = writer.getPrefix(namespaceURI);
+ if (prefix == null) {
+ prefix = Sandesha2Constants.Assertions.Q_ELEM_RMASSERTION
+ .getPrefix();
+ writer.setPrefix(prefix, namespaceURI);
+ }
+
+ // <wsrm:RMAssertion>
+ writer.writeStartElement(prefix, localName, namespaceURI);
+ // xmlns:wsrm=".."
+ writer.writeNamespace(prefix, namespaceURI);
+
+ String policyLocalName = Sandesha2Constants.Assertions.Q_ELEM_POLICY
+ .getLocalPart();
+ String policyNamespaceURI = Sandesha2Constants.Assertions.Q_ELEM_POLICY
+ .getNamespaceURI();
+ String wspPrefix = writer.getPrefix(policyNamespaceURI);
+
+ if (wspPrefix == null) {
+ wspPrefix = Sandesha2Constants.Assertions.Q_ELEM_POLICY.getPrefix();
+ writer.writeNamespace(wspPrefix, policyNamespaceURI);
+ }
+
+ // <wsp:Policy>
+ writer.writeStartElement(wspPrefix, policyLocalName, policyNamespaceURI);
+
+ // <wsrm:AcknowledgementInterval />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_ACK_INTERVAL.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Long.toString(getAcknowledgementInterval()));
+ writer.writeEndElement();
+
+ // <wsrm:RetransmissionInterval />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_RETRANS_INTERVAL.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Long.toString(getRetransmissionInterval()));
+ writer.writeEndElement();
+
+ // <wsrm:MaximumRetransmissionCount />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_MAX_RETRANS_COUNT.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Long.toString(getMaximumRetransmissionCount()));
+ writer.writeEndElement();
+
+ // <wsrm:ExponentialBackoff />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_EXP_BACKOFF.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isExponentialBackoff()));
+ writer.writeEndElement();
+
+ // <wsrm:InactivityTimeout />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_INACTIVITY_TIMEOUT.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Long.toString(getInactivityTimeoutInterval()));
+ writer.writeEndElement();
+
+ // <wsrm:InactivityTimeoutMeasure />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_INACTIVITY_TIMEOUT_MEASURES.getLocalPart(), namespaceURI);
+ writer.writeCharacters(inactivityTimeoutMeasure);
+ writer.writeEndElement();
+
+ // <wsrm:SequenceRemovalTimeout />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_SEQUENCE_REMOVAL_TIMEOUT.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Long.toString(getSequenceRemovalTimeoutInterval()));
+ writer.writeEndElement();
+
+ // <wsrm:SequenceRemovalTimeoutMeasure />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_SEQUENCE_REMOVAL_TIMEOUT_MEASURES.getLocalPart(), namespaceURI);
+ writer.writeCharacters(sequenceRemovalTimeoutMeasure);
+ writer.writeEndElement();
+
+ // <wsrm:InvokeInOrder />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_INVOKE_INORDER.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isInOrder()));
+ writer.writeEndElement();
+
+ // <wsrm:MessageTypesToDrop />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_MSG_TYPES_TO_DROP.getLocalPart(), namespaceURI);
+ writer.writeCharacters("none"); // FIXME
+ writer.writeEndElement();
+
+ // <wsrm:StorageManagers>
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_STORAGE_MGR.getLocalPart(), namespaceURI);
+
+ // <wsrm:InMemoryStorageManager />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_INMEMORY_STORAGE_MGR.getLocalPart(), namespaceURI);
+ writer.writeCharacters(getInMemoryStorageManagerClass());
+ writer.writeEndElement();
+
+ // <wsrm:PermanentStorageManager />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_PERMANENT_STORAGE_MGR.getLocalPart(), namespaceURI);
+ writer.writeCharacters(getPermanentStorageManagerClass());
+ writer.writeEndElement();
+
+ // </wsrm:StorageManager>
+ writer.writeEndElement();
+
+ // <wsrm:SecurityManager />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_SEC_MGR.getLocalPart(), namespaceURI);
+ writer.writeCharacters(getSecurityManagerClass());
+ writer.writeEndElement();
+
+ // <wsrm:MakeConnection>
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_MAKE_CONNECTION.getLocalPart(), namespaceURI);
+
+ // <wsrm:Enabled />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_ENABLED.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isEnableMakeConnection()));
+ writer.writeEndElement();
+
+ // <wsrm:UseRMAnonURI />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_USE_RM_ANON_URI.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isEnableRMAnonURI()));
+ writer.writeEndElement();
+
+ // </wsrm:MakeConnection>
+ writer.writeEndElement();
+
+ // <wsrm:UseMessageSerialization />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_USE_SERIALIZATION.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isUseMessageSerialization()));
+ writer.writeEndElement();
+
+ // <wsrm:EnforceRM />
+ writer.writeStartElement(prefix, Sandesha2Constants.Assertions.Q_ELEM_ENFORCE_RM.getLocalPart(), namespaceURI);
+ writer.writeCharacters(Boolean.toString(isEnforceRM()));
+ writer.writeEndElement();
+
+ // </wsp:Policy>
+ writer.writeEndElement();
+
+ // </wsrm:RMAssertion>
+ writer.writeEndElement();
+ } catch (SandeshaException e) {
+ throw new XMLStreamException (e);
+ }
+
+ }
+
+ public short getType() {
+ return Constants.TYPE_ASSERTION;
+ }
+
+ public boolean isExponentialBackoff() throws SandeshaException {
+ if (isExponentialBackoffSet()) {
+ return exponentialBackoff;
+ } else if (parent!=null) {
+ return parent.isExponentialBackoff ();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_EXP_BACKOFF);
+ throw new SandeshaException (message);
+ }
+ }
+
+ public void setExponentialBackoff(boolean exponentialBackoff) {
+ this.exponentialBackoff = exponentialBackoff;
+ setExponentialBackoffSet(true);
+ }
+
+ public long getRetransmissionInterval() throws SandeshaException {
+ if (isRetransmissionIntervalSet()) {
+ return retransmissionInterval;
+ } else if (parent!=null) {
+ return parent.getRetransmissionInterval();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_RETRANS_INTERVAL);
+ throw new SandeshaException (message);
+ }
+ }
+
+ public void setRetransmissionInterval(long retransmissionInterval) {
+ this.retransmissionInterval = retransmissionInterval;
+ setRetransmissionIntervalSet(true);
+ }
+
+ public long getAcknowledgementInterval() throws SandeshaException {
+ if (isAcknowledgementIntervalSet()) {
+ return acknowledgementInterval;
+ } else if (parent!=null) {
+ return parent.getAcknowledgementInterval();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_ACK_INTERVAL);
+ throw new SandeshaException (message);
+ }
+ }
+
+ public long getInactivityTimeoutInterval() {
+ if (inactivityTimeoutInterval < 0)
+ setInactiveTimeoutInterval(inactiveTimeoutValue,
+ inactivityTimeoutMeasure);
+
+ return inactivityTimeoutInterval;
+ }
+
+ public long getSequenceRemovalTimeoutInterval() {
+ if (sequenceRemovalTimeoutInterval < 0)
+ setSequenceRemovalTimeoutInterval(sequenceRemovalTimeoutValue,
+ sequenceRemovalTimeoutMeasure);
+
+ return sequenceRemovalTimeoutInterval;
+ }
+
+ public void setInactiveTimeoutValue(long inactiveTimeoutValue) {
+ this.inactiveTimeoutValue = inactiveTimeoutValue;
+ setInactiveTimeoutValueSet(true);
+ }
+
+ public void setInactivityTimeoutMeasure(String inactivityTimeoutMeasure) {
+ this.inactivityTimeoutMeasure = inactivityTimeoutMeasure;
+ }
+
+ public void setSequenceRemovalTimeoutValue(long sequenceRemovalTimeoutValue) {
+ this.sequenceRemovalTimeoutValue = sequenceRemovalTimeoutValue;
+ setSequenceRemovalTimeoutValueSet(true);
+ }
+
+ public void setSequenceRemovalTimeoutMeasure(String sequenceRemovalTimeoutMeasure) {
+ this.sequenceRemovalTimeoutMeasure = sequenceRemovalTimeoutMeasure;
+ }
+
+ public boolean isEnableMakeConnection() {
+ return enableMakeConnection;
+ }
+
+ public void setEnableMakeConnection(boolean enableMakeConnection) {
+ this.enableMakeConnection = enableMakeConnection;
+ setEnableMakeConnectionSet(true);
+ }
+
+ public boolean isEnableRMAnonURI() {
+ return enableRMAnonURI;
+ }
+
+ public void setEnableRMAnonURI(boolean enableRMAnonURI) {
+ this.enableRMAnonURI = enableRMAnonURI;
+ setEnableRMAnonURISet(true);
+ }
+
+ public boolean isUseMessageSerialization() throws SandeshaException {
+ if (isUseMessageSerializationSet ()) {
+ return useMessageSerialization;
+ } else if (parent!=null) {
+ return parent.isUseMessageSerialization();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_USE_SERIALIZATION);
+ throw new SandeshaException (message);
+ }
+ }
+
+ public void setUseMessageSerialization(boolean useMessageSerialization) {
+ this.useMessageSerialization = useMessageSerialization;
+ setUseMessageSerializationSet(true);
+ }
+
+ public boolean equal(PolicyComponent policyComponent) {
+ // TODO
+ return false;
+ }
+
+ public boolean isEnforceRM() throws SandeshaException {
+ if (isEnforceRMSet ()) {
+ return enforceRM;
+ } else if (parent!=null) {
+ return parent.isEnforceRM();
+ } else {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.policyHasNotBeenSet, Sandesha2Constants.Assertions.ELEM_ENFORCE_RM);
+ throw new SandeshaException (message);
+ }
+ }
+
+ public void setEnforceRM(boolean enforceRM) {
+ this.enforceRM = enforceRM;
+ setEnforceRMSet(true);
+ }
+
+ protected boolean isAcknowledgementIntervalSet() {
+ return acknowledgementIntervalSet;
+ }
+
+ protected void setAcknowledgementIntervalSet(boolean acknowledgementIntervalSet) {
+ this.acknowledgementIntervalSet = acknowledgementIntervalSet;
+ }
+
+ protected boolean isEnableMakeConnectionSet() {
+ return enableMakeConnectionSet;
+ }
+
+ protected void setEnableMakeConnectionSet(boolean enableMakeConnectionSet) {
+ this.enableMakeConnectionSet = enableMakeConnectionSet;
+ }
+
+ protected boolean isEnableRMAnonURISet() {
+ return enableRMAnonURISet;
+ }
+
+ protected void setEnableRMAnonURISet(boolean enableRMAnonURISet) {
+ this.enableRMAnonURISet = enableRMAnonURISet;
+ }
+
+ protected boolean isEnforceRMSet() {
+ return enforceRMSet;
+ }
+
+ protected void setEnforceRMSet(boolean enforceRMSet) {
+ this.enforceRMSet = enforceRMSet;
+ }
+
+ protected boolean isExponentialBackoffSet() {
+ return exponentialBackoffSet;
+ }
+
+ protected void setExponentialBackoffSet(boolean exponentialBackoffSet) {
+ this.exponentialBackoffSet = exponentialBackoffSet;
+ }
+
+ protected boolean isInactiveTimeoutValueSet() {
+ return inactiveTimeoutValueSet;
+ }
+
+ protected void setInactiveTimeoutValueSet(boolean inactiveTimeoutValueSet) {
+ this.inactiveTimeoutValueSet = inactiveTimeoutValueSet;
+ }
+
+ protected void setSequenceRemovalTimeoutValueSet(boolean sequenceRemovalTimeoutIntervalSet) {
+ this.sequenceRemovalTimeoutIntervalSet = sequenceRemovalTimeoutIntervalSet;
+ }
+
+ protected boolean isSequenceRemovalTimeoutValueSet() {
+ return sequenceRemovalTimeoutIntervalSet;
+ }
+
+ protected boolean isInactivityTimeoutIntervalSet() {
+ return inactivityTimeoutIntervalSet;
+ }
+
+ protected void setInactivityTimeoutIntervalSet(
+ boolean inactivityTimeoutIntervalSet) {
+ this.inactivityTimeoutIntervalSet = inactivityTimeoutIntervalSet;
+ }
+
+ protected boolean isInOrderSet() {
+ return inOrderSet;
+ }
+
+ protected void setInOrderSet(boolean inOrderSet) {
+ this.inOrderSet = inOrderSet;
+ }
+
+ protected boolean isMaximumRetransmissionCountSet() {
+ return maximumRetransmissionCountSet;
+ }
+
+ protected void setMaximumRetransmissionCountSet(
+ boolean maximumRetransmissionCountSet) {
+ this.maximumRetransmissionCountSet = maximumRetransmissionCountSet;
+ }
+
+ protected boolean isRetransmissionIntervalSet() {
+ return retransmissionIntervalSet;
+ }
+
+ protected void setRetransmissionIntervalSet(boolean retransmissionIntervalSet) {
+ this.retransmissionIntervalSet = retransmissionIntervalSet;
+ }
+
+ protected boolean isUseMessageSerializationSet() {
+ return useMessageSerializationSet;
+ }
+
+ protected void setUseMessageSerializationSet(boolean useMessageSerializationSet) {
+ this.useMessageSerializationSet = useMessageSerializationSet;
+ }
+
+ public SandeshaPolicyBean getParent() {
+ return parent;
+ }
+
+ public void setParent(SandeshaPolicyBean parent) {
+ this.parent = parent;
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/policy/builders/RMAssertionBuilder.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2001-2004 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.builders;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.Constants;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.AssertionBuilderFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.neethi.builders.xml.XmlPrimtiveAssertion;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+
+public class RMAssertionBuilder implements AssertionBuilder {
+
+ public Assertion build(OMElement element, AssertionBuilderFactory factory)
+ throws IllegalArgumentException {
+
+ SandeshaPolicyBean propertyBean = new SandeshaPolicyBean();
+ Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
+
+ processElements(policy.getPolicyComponents(), propertyBean);
+ return propertyBean;
+ }
+
+ public QName[] getKnownElements() {
+ return new QName[] { new QName(
+ Sandesha2Constants.Assertions.URI_RM_POLICY_NS, "RMAssertion") };
+ }
+
+ private void processElements(List policyComponents,
+ SandeshaPolicyBean propertyBean) {
+
+ XmlPrimtiveAssertion xmlPrimtiveAssertion;
+
+ for (Iterator iterator = policyComponents.iterator(); iterator
+ .hasNext();) {
+ xmlPrimtiveAssertion = (XmlPrimtiveAssertion) iterator.next();
+ OMElement element = xmlPrimtiveAssertion.getValue();
+ String name = element.getLocalName();
+
+ if (Sandesha2Constants.Assertions.ELEM_ACK_INTERVAL.equals(name)) {
+ propertyBean.setAcknowledgementInterval(Long.parseLong(element
+ .getText().trim()));
+
+ } else if (Sandesha2Constants.Assertions.ELEM_EXP_BACKOFF
+ .equals(name)) {
+ propertyBean.setExponentialBackoff(Boolean.valueOf(
+ element.getText().trim()).booleanValue());
+
+ } else if (Sandesha2Constants.Assertions.ELEM_INACTIVITY_TIMEOUT
+ .equals(name)) {
+
+ propertyBean.setInactiveTimeoutValue (Long.parseLong(element
+ .getText().trim()));
+
+ } else if (Sandesha2Constants.Assertions.ELEM_INACTIVITY_TIMEOUT_MEASURES
+ .equals(name)) {
+ //using the previously set Inactivity Timeout
+ propertyBean.setInactivityTimeoutMeasure (element.getText().trim());
+
+ } else if (Sandesha2Constants.Assertions.ELEM_DELETION_TIMEOUT
+ .equals(name)) {
+
+ propertyBean.setSequenceRemovalTimeoutValue (Long.parseLong(element
+ .getText().trim()));
+
+ } else if (Sandesha2Constants.Assertions.ELEM_DELETION_TIMEOUT_MEASURES
+ .equals(name)) {
+ //using the previously set Inavtivity Timeout
+ propertyBean.setSequenceRemovalTimeoutMeasure (element.getText().trim());
+
+ } else if (Sandesha2Constants.Assertions.ELEM_INVOKE_INORDER
+ .equals(name)) {
+ String value = element.getText().trim();
+ boolean inOrder = false;
+
+ if (value!=null && Constants.VALUE_TRUE.equals(value))
+ inOrder = true;
+
+ propertyBean.setInOrder(inOrder);
+
+ } else if (Sandesha2Constants.Assertions.ELEM_MAX_RETRANS_COUNT
+ .equals(name)) {
+ propertyBean.setMaximumRetransmissionCount (Integer.parseInt(element.getText().trim()));
+ } else if (Sandesha2Constants.Assertions.ELEM_MSG_TYPES_TO_DROP
+ .equals(name)) {
+ ArrayList types = new ArrayList ();
+ String str = element.getText().trim();
+ String[] items = str.split(Sandesha2Constants.LIST_SEPERATOR);
+ if (items!=null) {
+ int size = items.length;
+ for (int i=0;i<size;i++) {
+ String itemStr = items[i];
+ if (!itemStr.equals("") && !itemStr.equals(Sandesha2Constants.VALUE_NONE) )
+ types.add(new Integer (itemStr));
+ }
+ }
+ propertyBean.setMsgTypesToDrop (types);
+ } else if (Sandesha2Constants.Assertions.ELEM_RETRANS_INTERVAL
+ .equals(name)) {
+ propertyBean.setRetransmissionInterval (Long.parseLong (element.getText().trim()));
+ } else if (Sandesha2Constants.Assertions.ELEM_SEC_MGR
+ .equals(name)) {
+ propertyBean.setSecurityManagerClass (element.getText().trim());
+ } else if (Sandesha2Constants.Assertions.ELEM_STORAGE_MGR
+ .equals(name)) {
+
+ if (element!=null) {
+ //finding out storage managers.
+
+ OMElement inmemoryStorageManagerElem = element.getFirstChildWithName(Sandesha2Constants.Assertions.Q_ELEM_INMEMORY_STORAGE_MGR);
+ if (inmemoryStorageManagerElem!=null) {
+ String inMemoryStorageMgr = inmemoryStorageManagerElem.getText().trim();
+ propertyBean.setInMemoryStorageManagerClass(inMemoryStorageMgr);
+ }
+
+ OMElement permanentStorageManagerElem = element.getFirstChildWithName(Sandesha2Constants.Assertions.Q_ELEM_PERMANENT_STORAGE_MGR);
+ if (permanentStorageManagerElem!=null) {
+ String permanentStorageMgr = permanentStorageManagerElem.getText().trim();
+ propertyBean.setPermanentStorageManagerClass(permanentStorageMgr);
+ }
+
+ }
+ } else if(Sandesha2Constants.Assertions.ELEM_MAKE_CONNECTION.equals(name)) {
+ if (element!=null) {
+ // Read the nested assertions
+
+ OMElement enabledElem = element.getFirstChildWithName(Sandesha2Constants.Assertions.Q_ELEM_ENABLED);
+ if (enabledElem!=null) {
+ String data = enabledElem.getText().trim();
+ propertyBean.setEnableMakeConnection(Boolean.valueOf(data).booleanValue());
+ }
+
+ OMElement useRMAnonElem = element.getFirstChildWithName(Sandesha2Constants.Assertions.Q_ELEM_USE_RM_ANON_URI);
+ if (useRMAnonElem!=null) {
+ String data = useRMAnonElem.getText().trim();
+ propertyBean.setEnableRMAnonURI(Boolean.valueOf(data).booleanValue());
+ }
+ }
+ } else if (Sandesha2Constants.Assertions.ELEM_USE_SERIALIZATION.equals(name)) {
+ String value = element.getText().trim();
+ propertyBean.setUseMessageSerialization(Boolean.valueOf(value).booleanValue());
+ } else if (Sandesha2Constants.Assertions.ELEM_ENFORCE_RM.equals(name)) {
+ String value = element.getText().trim();
+ propertyBean.setEnforceRM (Boolean.valueOf(value).booleanValue());
+ }
+ }
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/polling/PollingManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/polling/PollingManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/polling/PollingManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/polling/PollingManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,275 @@
+/*
+ * Copyright 1999-2004 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.polling;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.storage.beans.RMSequenceBean;
+import org.apache.sandesha2.storage.beans.SenderBean;
+import org.apache.sandesha2.util.AcknowledgementManager;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.RMMsgCreator;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.workers.SandeshaThread;
+import org.apache.sandesha2.workers.SequenceEntry;
+
+/**
+ * This class is responsible for sending MakeConnection requests. This is a seperate thread that
+ * keeps running. Will do MakeConnection based on the request queue or randomly.
+ */
+public class PollingManager extends SandeshaThread {
+ private static final Log log = LogFactory.getLog(PollingManager.class);
+
+ // Variables used to help round-robin across the sequences that we can poll for
+ private int nextIndex = 0;
+
+ /**
+ * By adding an entry to this, the PollingManager will be asked to do a polling request on this sequence.
+ */
+ private LinkedList scheduledPollingRequests = new LinkedList();
+
+ private static final int POLLING_MANAGER_WAIT_TIME = 3000;
+
+ public PollingManager() {
+ super(POLLING_MANAGER_WAIT_TIME);
+ }
+
+ protected boolean internalRun() {
+ if(log.isDebugEnabled()) log.debug("Enter: PollingManager::internalRun");
+ Transaction t = null;
+ try {
+ // If we have request scheduled, handle them first, and then pick
+ // pick a sequence using a round-robin approach. Scheduled polls
+ // bypass the normal polling checks, to make sure that they happen
+ boolean forcePoll = false;
+ SequenceEntry entry = null;
+ synchronized (this) {
+ if(!scheduledPollingRequests.isEmpty()) {
+ entry = (SequenceEntry) scheduledPollingRequests.removeFirst();
+ forcePoll = true;
+ }
+ }
+ if(entry == null) {
+ ArrayList allSequencesList = getSequences();
+ int size = allSequencesList.size();
+ if(log.isDebugEnabled()) log.debug("Choosing one from " + size + " sequences");
+ if(nextIndex >= size) {
+ nextIndex = 0;
+ // We just looped over the set of sequences, so sleep before we try
+ // polling them again.
+ if (log.isDebugEnabled()) log.debug("Exit: PollingManager::internalRun, looped over all sequences, sleeping");
+ return true;
+ }
+
+ entry = (SequenceEntry) allSequencesList.get(nextIndex++);
+ }
+ if(log.isDebugEnabled()) log.debug("Chose sequence " + entry.getSequenceId());
+
+ t = storageManager.getTransaction();
+ if(entry.isRmSource()) {
+ pollRMSSide(entry, forcePoll);
+ } else {
+ pollRMDSide(entry, forcePoll);
+ }
+ if(t != null) t.commit();
+ t = null;
+
+ } catch (Exception e) {
+ if(log.isDebugEnabled()) log.debug("Exception", e);
+ if(t != null) {
+ try {
+ t.rollback();
+ } catch(Exception e2) {
+ if(log.isDebugEnabled()) log.debug("Exception during rollback", e);
+ }
+ }
+ }
+
+ if(log.isDebugEnabled()) log.debug("Exit: PollingManager::internalRun, not sleeping");
+ return false;
+ }
+
+ private void pollRMSSide(SequenceEntry entry, boolean force) throws AxisFault {
+ if(log.isDebugEnabled()) log.debug("Enter: PollingManager::pollRMSSide, force: " + force);
+
+ RMSBeanMgr rmsBeanManager = storageManager.getRMSBeanMgr();
+ RMSBean findRMS = new RMSBean();
+ findRMS.setInternalSequenceID(entry.getSequenceId());
+ findRMS.setPollingMode(true);
+ findRMS.setTerminated(false);
+ RMSBean beanToPoll = rmsBeanManager.findUnique(findRMS);
+
+ if(beanToPoll == null) {
+ // This sequence must have been terminated, or deleted
+ stopThreadForSequence(entry.getSequenceId(), true);
+ } else {
+ if (log.isDebugEnabled())
+ log.debug("Polling rms " + beanToPoll);
+ // The sequence is there, but we still only poll if we are expecting reply messages,
+ // or if we don't have clean ack state.
+ boolean cleanAcks = false;
+ if (beanToPoll.getNextMessageNumber() > -1)
+ cleanAcks = AcknowledgementManager.verifySequenceCompletion(beanToPoll.getClientCompletedMessages(), beanToPoll.getNextMessageNumber());
+ long repliesExpected = beanToPoll.getExpectedReplies();
+ if((force || !cleanAcks || repliesExpected > 0) && beanToPoll.getReferenceMessageStoreKey() != null)
+ pollForSequence(beanToPoll.getAnonymousUUID(), beanToPoll.getInternalSequenceID(), beanToPoll.getReferenceMessageStoreKey(), beanToPoll, entry);
+ }
+
+ if(log.isDebugEnabled()) log.debug("Exit: PollingManager::pollRMSSide");
+ }
+
+ private void pollRMDSide(SequenceEntry entry, boolean force) throws AxisFault {
+ if(log.isDebugEnabled()) log.debug("Enter: PollingManager::pollRMDSide, force: " + force);
+ RMDBeanMgr nextMsgMgr = storageManager.getRMDBeanMgr();
+ RMDBean findBean = new RMDBean();
+ findBean.setPollingMode(true);
+ findBean.setTerminated(false);
+ findBean.setSequenceID(entry.getSequenceId());
+ RMDBean nextMsgBean = nextMsgMgr.findUnique(findBean);
+
+ if(nextMsgBean == null) {
+ // This sequence must have been terminated, or deleted
+ stopThreadForSequence(entry.getSequenceId(), false);
+ } else {
+ // The sequence is still there, but if we have a running related sequence
+ // that is not expecting replies then there is no need to poll.
+ boolean doPoll = true;
+ String outboundSequence = nextMsgBean.getOutboundInternalSequence();
+ if(outboundSequence != null) {
+ RMSBean findRMS = new RMSBean();
+ findRMS.setInternalSequenceID(outboundSequence);
+ findRMS.setTerminated(false);
+ RMSBeanMgr mgr = storageManager.getRMSBeanMgr();
+ RMSBean outbound = mgr.findUnique(findRMS);
+ if(outbound != null && outbound.getExpectedReplies() == 0) {
+ doPoll = false;
+ }
+ }
+ if(force || doPoll)
+ pollForSequence(null, null, nextMsgBean.getReferenceMessageKey(), nextMsgBean, entry);
+ }
+
+ if(log.isDebugEnabled()) log.debug("Exit: PollingManager::pollRMDSide");
+ }
+
+ private void pollForSequence(String anonUUID, // Only set for RMS polling
+ String internalSeqId, // Only set for RMS polling
+ String referenceMsgKey,
+ RMSequenceBean rmBean,
+ SequenceEntry entry)
+ throws SandeshaException, SandeshaStorageException, AxisFault
+ {
+ if(log.isDebugEnabled()) log.debug("Enter: PollingManager::pollForSequence, rmBean: " + rmBean);
+
+ //create a MakeConnection message
+ String replyTo = rmBean.getReplyToEPR();
+ String wireSeqId = null;
+ String wireAddress = null;
+ if(anonUUID != null) {
+ // If we are polling on a RM anon URI then we don't want to include the sequence id
+ // in the MakeConnection message.
+ wireAddress = anonUUID;
+ } else if(SandeshaUtil.isWSRMAnonymous(replyTo)) {
+ // If we are polling on a RM anon URI then we don't want to include the sequence id
+ // in the MakeConnection message.
+ wireAddress = replyTo;
+ } else {
+ wireSeqId = rmBean.getSequenceID();
+ }
+
+ MessageContext referenceMessage = storageManager.retrieveMessageContext(referenceMsgKey,context);
+ if(referenceMessage!=null){
+ RMMsgContext referenceRMMessage = MsgInitializer.initializeMessage(referenceMessage);
+ RMMsgContext makeConnectionRMMessage = RMMsgCreator.createMakeConnectionMessage(referenceRMMessage,
+ rmBean, wireSeqId, wireAddress, storageManager);
+
+
+ //we must set serverSide to false. Having serverSide as true (I.e. when polling for RMD) will cause the SenderWorker to ignore
+ //the sync response message.
+ makeConnectionRMMessage.getMessageContext().setServerSide(false);
+
+ // Store properties so that we know which sequence we are polling for. This can be used
+ // to match reply sequences up to requests, as well as to help process messagePending
+ // headers.
+ OperationContext ctx = makeConnectionRMMessage.getMessageContext().getOperationContext();
+ ctx.setProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY, entry);
+
+ makeConnectionRMMessage.setProperty(MessageContext.TRANSPORT_IN,null);
+ //storing the MakeConnection message.
+ String makeConnectionMsgStoreKey = SandeshaUtil.getUUID();
+
+ //add an entry for the MakeConnection message to the sender (with ,send=true, resend=false)
+ SenderBean makeConnectionSenderBean = new SenderBean ();
+ makeConnectionSenderBean.setInternalSequenceID(internalSeqId);
+ makeConnectionSenderBean.setMessageContextRefKey(makeConnectionMsgStoreKey);
+ makeConnectionSenderBean.setMessageID(makeConnectionRMMessage.getMessageId());
+ makeConnectionSenderBean.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);
+ makeConnectionSenderBean.setReSend(false);
+ makeConnectionSenderBean.setSend(true);
+ makeConnectionSenderBean.setSequenceID(rmBean.getSequenceID());
+ EndpointReference to = makeConnectionRMMessage.getTo();
+ if (to!=null)
+ makeConnectionSenderBean.setToAddress(to.getAddress());
+
+ SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
+
+ //this message should not be sent until it is qualified. I.e. till it is sent through the Sandesha2TransportSender.
+ makeConnectionRMMessage.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
+
+ SandeshaUtil.executeAndStore(makeConnectionRMMessage, makeConnectionMsgStoreKey);
+
+ senderBeanMgr.insert(makeConnectionSenderBean);
+ }
+
+ if(log.isDebugEnabled()) log.debug("Exit: PollingManager::pollForSequence");
+ }
+
+ /**
+ * Asking the polling manager to do a polling request on the sequence identified by the
+ * given InternalSequenceId.
+ *
+ * @param sequenceId
+ */
+ public synchronized void schedulePollingRequest(String sequenceId, boolean rmSource) {
+ if(log.isDebugEnabled()) log.debug("Enter: PollingManager::shedulePollingRequest, " + sequenceId);
+
+ SequenceEntry entry = new SequenceEntry(sequenceId, rmSource);
+ scheduledPollingRequests.add(entry);
+ this.wakeThread();
+
+ if(log.isDebugEnabled()) log.debug("Exit: PollingManager::shedulePollingRequest");
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.security;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * SecurityManager interface. This manages the link between the RM layer and Security,
+ * so that the CreateSequence message can be secured using a SecurityTokenReference.
+ * Once the sequence is secured using the STR, each inbound messgae must be checked to
+ * ensure the sender has demonstrated proof-of-possession of the referenced token.
+ *
+ * See the WS-RM 1.0 spec for details.
+ */
+public abstract class SecurityManager {
+
+ public SecurityManager(ConfigurationContext context) {
+
+ }
+
+ /**
+ * Initialize the security manager. This may perfom setup such as checking the set
+ * of sequences that have been persisted over restart, and bootstrapping their
+ * security state.
+ */
+ public abstract void initSecurity(AxisModule moduleDesc);
+
+ /**
+ * Get a security token to secure an outbound create sequence message. This token
+ * will be the one referenced with the body of the CreateSequence. This method may
+ * return null, in which case the CreateSequence message will not contain the
+ * SecurityTokenReference.
+ */
+ public abstract SecurityToken getSecurityToken(MessageContext message)
+ throws SandeshaException;
+
+ /**
+ * Get a security token, from a SecurityTokenReference within an inbound message.
+ * This method should not return null, so if the Token cannot be found the implementation
+ * should throw an exception.
+ */
+ public abstract SecurityToken getSecurityToken(OMElement theSTR, MessageContext message)
+ throws SandeshaException;
+
+ /**
+ * Create a SecurityTokenReference, suitable for inclusion in the given message.
+ * The imelementation may choose to insert security headers into the SOAP envelope at
+ * this point, or it may choose to simple place some state into the message context
+ * and defer the real work until the security handlers execute.
+ */
+ public abstract OMElement createSecurityTokenReference(SecurityToken token, MessageContext message)
+ throws SandeshaException;
+
+ /**
+ * Check that the given element of the message demonstrated proof of possession of
+ * the given token. This allows Sandesha to implement the checking required by the
+ * RM spec. Proof is normally demonstrated by signing or encrypting the the given
+ * part using the token.
+ * If the elements is not secured with the given token the SecurityManager must
+ * throw an exception.
+ */
+ public abstract void checkProofOfPossession(SecurityToken token, OMElement messagePart, MessageContext message)
+ throws SandeshaException;
+
+ /**
+ * Write the data from this token in to a String. This is here to simplify storing
+ * token data into the storage layer - rather than rely on Java serialization we
+ * use this method, and the matching SecurityManager method to rebuild the token
+ * object.
+ */
+ public abstract String getTokenRecoveryData(SecurityToken token)
+ throws SandeshaException;
+
+ /**
+ * Reconstruct a token from a String. This method should not return null - if the
+ * security manager is unable to recover the token from the correlation data then
+ * it should throw an exception.
+ */
+ public abstract SecurityToken recoverSecurityToken(String tokenData)
+ throws SandeshaException;
+
+ /**
+ * Ensure that the given token will be associated with an outbound message.
+ * This gives the SecurityManager implementation an opportunity to decorate
+ * the message context with properties that will then be used by the security
+ * handlers.
+ */
+ public abstract void applySecurityToken(SecurityToken token, MessageContext outboundMessage)
+ throws SandeshaException;
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityToken.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityToken.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/SecurityToken.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.security;
+
+/**
+ * SecurityToken interface. This is an opaque handle onto the state that the security
+ * layer needs to manage on behalf of RM. Each secure RM sequence will have an
+ * associated security token.
+ *
+ */
+public interface SecurityToken {
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/dummy/DummySecurityManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/dummy/DummySecurityManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/dummy/DummySecurityManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/dummy/DummySecurityManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.security.dummy;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.security.SecurityManager;
+import org.apache.sandesha2.security.SecurityToken;
+
+/**
+ * A null implementation of a security manager. This manager cannot create tokens, so the
+ * messages sent using this manager will not be secured.
+ */
+public class DummySecurityManager extends SecurityManager {
+
+ public DummySecurityManager(ConfigurationContext context) {
+ super(context);
+ }
+
+ public void initSecurity(AxisModule moduleDesc) {
+ }
+
+ public void checkProofOfPossession(SecurityToken token, OMElement messagePart, MessageContext message)
+ throws SandeshaException
+ {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.secureDummyNoProof);
+ throw new SandeshaException(msg);
+ }
+
+ public SecurityToken getSecurityToken(MessageContext message) {
+ // Returning null will tell the rest of sandesha to continue without attempting to secure the sequence.
+ return null;
+ }
+
+ public String getTokenRecoveryData(SecurityToken token)
+ throws SandeshaException
+ {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.secureDummyNoToken);
+ throw new SandeshaException(msg);
+ }
+
+ public SecurityToken recoverSecurityToken(String tokenData)
+ throws SandeshaException
+ {
+ String msg = SandeshaMessageHelper.getMessage("secureDummyNoToken");
+ throw new SandeshaException(msg);
+ }
+
+
+ public SecurityToken getSecurityToken(OMElement theSTR, MessageContext message)
+ throws SandeshaException
+ {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.secureDummyNoSTR);
+ throw new SandeshaException(msg);
+ }
+
+ public OMElement createSecurityTokenReference(SecurityToken token, MessageContext message) throws SandeshaException {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.secureDummyNoSTR);
+ throw new SandeshaException(msg);
+ }
+
+ public void applySecurityToken(SecurityToken token, MessageContext outboundMessage) throws SandeshaException {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.secureDummyNoSTR);
+ throw new SandeshaException(msg);
+ }
+
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartBasedSecurityManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartBasedSecurityManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartBasedSecurityManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartBasedSecurityManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,361 @@
+/*
+ * 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.security.rampart;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.Constants;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Policy;
+import org.apache.rahas.RahasConstants;
+import org.apache.rahas.SimpleTokenStore;
+import org.apache.rahas.Token;
+import org.apache.rahas.TokenStorage;
+import org.apache.rahas.TrustException;
+import org.apache.rahas.TrustUtil;
+import org.apache.rahas.client.STSClient;
+import org.apache.rampart.RampartException;
+import org.apache.rampart.RampartMessageData;
+import org.apache.rampart.policy.RampartPolicyBuilder;
+import org.apache.rampart.policy.RampartPolicyData;
+import org.apache.rampart.util.RampartUtil;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.security.SecurityManager;
+import org.apache.sandesha2.security.SecurityToken;
+import org.apache.ws.secpolicy.WSSPolicyException;
+import org.apache.ws.secpolicy.model.SecureConversationToken;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSDerivedKeyTokenPrincipal;
+import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.conversation.ConversationConstants;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
+import org.apache.ws.security.message.token.Reference;
+import org.apache.ws.security.message.token.SecurityTokenReference;
+
+import javax.xml.namespace.QName;
+
+import java.security.Principal;
+import java.util.List;
+import java.util.Vector;
+
+
+public class RampartBasedSecurityManager extends SecurityManager {
+
+ private static final Log log = LogFactory.getLog(RampartBasedSecurityManager.class);
+
+ TokenStorage storage = null;
+
+ /**
+ * @param context
+ */
+ public RampartBasedSecurityManager(ConfigurationContext context) {
+ super(context);
+
+ this.storage = (TokenStorage) context
+ .getProperty(TokenStorage.TOKEN_STORAGE_KEY);
+ if (this.storage == null) {
+ this.storage = new SimpleTokenStore();
+ context.setProperty(TokenStorage.TOKEN_STORAGE_KEY, this.storage);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#checkProofOfPossession(org.apache.sandesha2.security.SecurityToken, org.apache.axiom.om.OMElement, org.apache.axis2.context.MessageContext)
+ */
+ public void checkProofOfPossession(SecurityToken token,
+ OMElement messagePart, MessageContext message)
+ throws SandeshaException {
+
+ Vector results = null;
+ if ((results = (Vector) message
+ .getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
+ String msg = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.noSecurityResults);
+ throw new SandeshaException(msg);
+ } else {
+ boolean verified = false;
+ for (int i = 0; i < results.size() && !verified; i++) {
+ WSHandlerResult rResult = (WSHandlerResult) results.get(i);
+ Vector wsSecEngineResults = rResult.getResults();
+
+ for (int j = 0; j < wsSecEngineResults.size() && !verified; j++) {
+ WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults
+ .get(j);
+ if (wser.getAction() == WSConstants.SIGN
+ && wser.getPrincipal() != null) {
+
+ // first verify the base token
+ Principal principal = wser.getPrincipal();
+ if (principal instanceof WSDerivedKeyTokenPrincipal) {
+ //Get the id of the SCT that was used to create the DKT
+ String baseTokenId = ((WSDerivedKeyTokenPrincipal) principal)
+ .getBasetokenId();
+ //Get the token that matches the id
+ SecurityToken recoveredToken = this
+ .recoverSecurityToken(baseTokenId);
+ if (recoveredToken != null) {
+ Token rahasToken = ((RampartSecurityToken) recoveredToken)
+ .getToken();
+ //check whether the SCT used in the message is
+ //similar to the one given into the method
+ String recoverdTokenId = rahasToken.getId();
+ String attRefId = null;
+ String unattrefId = null;
+ if (rahasToken.getAttachedReference() != null) {
+ attRefId = this.getUriFromSTR(rahasToken
+ .getAttachedReference());
+ }
+ if (rahasToken.getUnattachedReference() != null) {
+ unattrefId = this.getUriFromSTR(rahasToken
+ .getUnattachedReference());
+ }
+
+ String id = ((RampartSecurityToken) token)
+ .getToken().getId();
+ if (recoverdTokenId.equals(id)
+ || attRefId.equals(id)
+ || unattrefId.equals(id)) {
+ //Token matched with a token that signed the message part
+ //Now check signature parts
+ OMAttribute idattr = messagePart
+ .getAttribute(new QName(
+ WSConstants.WSU_NS, "Id"));
+ verified = wser.getSignedElements()
+ .contains(
+ idattr.getAttributeValue());
+ if (verified) {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (!verified) {
+ String msg = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.proofOfPossessionNotVerified);
+ throw new SandeshaException(msg);
+ }
+ }
+
+ }
+
+ private String getUriFromSTR(OMElement str) {
+ OMElement refElem = str.getFirstChildWithName(Reference.TOKEN);
+ return refElem.getAttributeValue(new QName("URI")).substring(1);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#createSecurityTokenReference(org.apache.sandesha2.security.SecurityToken, org.apache.axis2.context.MessageContext)
+ */
+ public OMElement createSecurityTokenReference(SecurityToken token,
+ MessageContext message) throws SandeshaException {
+
+ OMFactory fac = message.getEnvelope().getOMFactory();
+
+ RampartSecurityToken rampartToken = (RampartSecurityToken) token;
+ OMElement element = rampartToken.getToken().getAttachedReference();
+ if (element == null) {
+ element = rampartToken.getToken().getUnattachedReference();
+ }
+
+ if (element == null) {
+ //Now use the token id and construct the ref element
+ element = fac.createOMElement(
+ SecurityTokenReference.SECURITY_TOKEN_REFERENCE,
+ WSConstants.WSSE_LN, WSConstants.WSSE_PREFIX);
+ OMElement refElem = fac.createOMElement(Reference.TOKEN, element);
+ refElem.addAttribute("ValueType",
+ "http://schemas.xmlsoap.org/ws/2005/02/sc/sct", null);
+ refElem.addAttribute("URI", rampartToken.getToken().getId(), null);
+ }
+
+ return this.convertOMElement(fac, element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#getSecurityToken(org.apache.axis2.context.MessageContext)
+ */
+ public SecurityToken getSecurityToken(MessageContext message)
+ throws SandeshaException {
+ String contextIdentifierKey = RampartUtil
+ .getContextIdentifierKey(message);
+ String identifier = (String) RampartUtil.getContextMap(message).get(
+ contextIdentifierKey);
+
+ if (identifier == null && !message.isServerSide()) {
+ try {
+ OMElement rstTmpl = RampartUtil.createRSTTempalteForSCT(
+ ConversationConstants.VERSION_05_02,
+ RahasConstants.VERSION_05_02);
+
+ String action = TrustUtil.getActionValue(
+ RahasConstants.VERSION_05_02,
+ RahasConstants.RST_ACTION_SCT);
+
+ Policy servicePolicy = (Policy) message
+ .getProperty(RampartMessageData.KEY_RAMPART_POLICY);
+ if (servicePolicy == null) {
+ //Missing service policy means no security requirement
+ return null;
+ }
+ List it = (List) servicePolicy.getAlternatives().next();
+ RampartPolicyData rpd = RampartPolicyBuilder.build(it);
+
+ SecureConversationToken secConvTok = null;
+
+ org.apache.ws.secpolicy.model.Token encrtok = rpd
+ .getEncryptionToken();
+ secConvTok = (encrtok != null && encrtok instanceof SecureConversationToken) ? (SecureConversationToken) encrtok
+ : null;
+
+ if (secConvTok == null) {
+ org.apache.ws.secpolicy.model.Token sigtok = rpd
+ .getSignatureToken();
+ secConvTok = (sigtok != null && sigtok instanceof SecureConversationToken) ? (SecureConversationToken) sigtok
+ : null;
+ }
+
+ if (secConvTok != null) {
+
+ Policy issuerPolicy = secConvTok.getBootstrapPolicy();
+ issuerPolicy.addAssertion(rpd.getRampartConfig());
+
+ STSClient client = new STSClient(message
+ .getConfigurationContext());
+ Options op = new Options();
+ op.setProperty(SandeshaClientConstants.UNRELIABLE_MESSAGE,
+ Constants.VALUE_TRUE);
+ client.setOptions(op);
+ client.setAction(action);
+ client.setRstTemplate(rstTmpl);
+ client.setCryptoInfo(RampartUtil.getEncryptionCrypto(rpd
+ .getRampartConfig(), message.getAxisService()
+ .getClassLoader()), RampartUtil.getPasswordCB(
+ message, rpd));
+ String address = message.getTo().getAddress();
+ Token tok = client.requestSecurityToken(servicePolicy,
+ address, issuerPolicy, null);
+
+ tok.setState(Token.ISSUED);
+ this.storage.add(tok);
+
+ contextIdentifierKey = RampartUtil
+ .getContextIdentifierKey(message);
+ RampartUtil.getContextMap(message).put(
+ contextIdentifierKey, tok.getId());
+ identifier = tok.getId();
+
+ } else {
+ String msg = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.noSecConvTokenInPolicy);
+ log.debug(msg);
+ return null;
+ }
+
+ } catch (RampartException e) {
+ throw new SandeshaException(e.getMessage(), e);
+ } catch (TrustException e) {
+ throw new SandeshaException(e.getMessage(), e);
+ } catch (WSSPolicyException e) {
+ throw new SandeshaException(e.getMessage(), e);
+ }
+ }
+
+ return this.recoverSecurityToken(identifier);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#getSecurityToken(org.apache.axiom.om.OMElement, org.apache.axis2.context.MessageContext)
+ */
+ public SecurityToken getSecurityToken(OMElement theSTR,
+ MessageContext message) throws SandeshaException {
+
+ OMElement refElem = theSTR.getFirstChildWithName(Reference.TOKEN);
+ String id = refElem.getAttributeValue(new QName("URI"));
+ String tokenId = id;
+ if (!id.startsWith("urn:") && id.startsWith("#")) {
+ tokenId = tokenId.substring(1);
+ }
+ return this.recoverSecurityToken(tokenId);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#getTokenRecoveryData(org.apache.sandesha2.security.SecurityToken)
+ */
+ public String getTokenRecoveryData(SecurityToken token)
+ throws SandeshaException {
+ String id = ((RampartSecurityToken) token).getToken().getId();
+ if (!id.startsWith("urn:") && id.startsWith("#")) {
+ id = id.substring(1);
+ }
+ return id;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#initSecurity(org.apache.axis2.description.AxisModule)
+ */
+ public void initSecurity(AxisModule moduleDesc) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sandesha2.security.SecurityManager#recoverSecurityToken(java.lang.String)
+ */
+ public SecurityToken recoverSecurityToken(String tokenData)
+ throws SandeshaException {
+ try {
+ Token token = this.storage.getToken(tokenData);
+ if (token != null) {
+ return new RampartSecurityToken(token);
+ } else {
+ String msg = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.errorRetrievingSecurityToken);
+ throw new SandeshaException(msg);
+ }
+ } catch (TrustException e) {
+ String msg = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.errorRetrievingSecurityToken);
+ throw new SandeshaException(msg);
+ }
+ }
+
+ private OMElement convertOMElement(OMFactory fac, OMElement elem) {
+ return new StAXOMBuilder(fac, elem.getXMLStreamReader())
+ .getDocumentElement();
+ }
+
+ public void applySecurityToken(SecurityToken token,
+ MessageContext outboundMessage) throws SandeshaException {
+ // TODO If there are any properties that should be put onto the outbound message
+ // to ensure that the correct token is used to secure it, then they should be
+ // added now.
+ }
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartSecurityToken.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartSecurityToken.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartSecurityToken.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/security/rampart/RampartSecurityToken.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.security.rampart;
+
+import org.apache.rahas.Token;
+import org.apache.sandesha2.security.SecurityToken;
+
+
+public class RampartSecurityToken implements SecurityToken {
+
+ private Token token = null;
+
+ RampartSecurityToken(Token token) {
+ this.token = token;
+ }
+
+ public Token getToken() {
+ return token;
+ }
+
+ public void setToken(Token token) {
+ this.token = token;
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/SandeshaStorageException.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/SandeshaStorageException.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/SandeshaStorageException.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/SandeshaStorageException.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999-2004 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.storage;
+
+import org.apache.sandesha2.SandeshaException;
+
+/**
+ * To easily track exceptions happening in the storage area.
+ */
+
+public class SandeshaStorageException extends SandeshaException {
+
+ private static final long serialVersionUID = -8620608387173070005L;
+
+ public SandeshaStorageException (String message) {
+ super (message);
+ }
+
+ public SandeshaStorageException (Exception e) {
+ super (e);
+ }
+
+ public SandeshaStorageException (String m,Exception e) {
+ super (m,e);
+ }
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/StorageManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/StorageManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/StorageManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/StorageManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.storage;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.sandesha2.polling.PollingManager;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.workers.SandeshaThread;
+
+/**
+ * Storage managers should extend this.
+ *
+ */
+
+public abstract class StorageManager {
+
+ private ConfigurationContext context;
+
+ public StorageManager(ConfigurationContext context) {
+ this.context = context;
+ }
+
+ public ConfigurationContext getContext() {
+ return context;
+ }
+
+ public void setContext(ConfigurationContext context) {
+ if (context != null)
+ this.context = context;
+ }
+
+ public void shutdown(){
+ //shutdown the running threads
+ getSender().stopRunning();
+
+ SandeshaThread thread = getInvoker();
+ if(thread != null) thread.stopRunning();
+
+ thread = getPollingManager();
+ if(thread != null) thread.stopRunning();
+
+ //removing the reference to the configuration context
+ context=null;
+ }
+
+ public abstract void initStorage (AxisModule moduleDesc) throws SandeshaStorageException;
+
+ public abstract Transaction getTransaction();
+
+ public abstract SandeshaThread getSender();
+
+ /**
+ * Get the invoker that hands inbound messages over to the application. This
+ * may be null, in which case the inbound messages will be dispatched directly
+ * to the application without switching them over to the invoker.
+ * @return null if messages should be delivered directly to the application,
+ * otherwise return a SandeshaThread.
+ */
+ public abstract SandeshaThread getInvoker();
+
+ /**
+ * Get the thread that generates polling requests to send to remote endpoints.
+ * This may be null, in which case the storage manager does not support polling.
+ * @return null if polling is diabled, otherwise return a PollingManager.
+ */
+ public abstract PollingManager getPollingManager();
+
+ public abstract RMSBeanMgr getRMSBeanMgr();
+
+ public abstract RMDBeanMgr getRMDBeanMgr();
+
+ public abstract SenderBeanMgr getSenderBeanMgr();
+
+ public abstract InvokerBeanMgr getInvokerBeanMgr();
+
+ public abstract void storeMessageContext (String storageKey,MessageContext msgContext) throws SandeshaStorageException;
+
+ public abstract void updateMessageContext (String storageKey,MessageContext msgContext) throws SandeshaStorageException;
+
+ public abstract MessageContext retrieveMessageContext (String storageKey, ConfigurationContext configContext) throws SandeshaStorageException;
+
+ public abstract void removeMessageContext (String storageKey) throws SandeshaStorageException;
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/Transaction.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/Transaction.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/Transaction.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/Transaction.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2004 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.storage;
+
+/**
+ * Transaction implementations should extend this.
+ */
+
+public interface Transaction {
+
+ public void commit ();
+
+ public void rollback ();
+
+ //indicates that the transaction has been started, but has not been committed or rolledbacked yet.
+ public boolean isActive ();
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/InvokerBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/InvokerBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/InvokerBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/InvokerBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-2004 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.storage.beanmanagers;
+
+import java.util.List;
+
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beans.InvokerBean;
+
+/**
+ * Used to manage invoker beans.
+ */
+
+public interface InvokerBeanMgr extends RMBeanManager {
+
+ public boolean insert(InvokerBean bean) throws SandeshaStorageException;
+
+ public boolean delete(String key) throws SandeshaStorageException;
+
+ public InvokerBean retrieve(String key) throws SandeshaStorageException;
+
+ public List find(InvokerBean bean) throws SandeshaStorageException;
+
+ public InvokerBean findUnique (InvokerBean bean) throws SandeshaException;
+
+ public boolean update(InvokerBean bean) throws SandeshaStorageException;
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMBeanManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMBeanManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMBeanManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMBeanManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,26 @@
+/*
+ * Copyright 1999-2004 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.storage.beanmanagers;
+
+/**
+ * A marker interface to mart Bean Managers.
+ */
+
+public interface RMBeanManager {
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMDBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMDBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMDBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMDBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-2004 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.storage.beanmanagers;
+
+import java.util.List;
+
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beans.RMDBean;
+
+/**
+ * Used to manage NextMsg beans.
+ */
+
+public interface RMDBeanMgr extends RMBeanManager {
+
+ public boolean delete(String sequenceId) throws SandeshaStorageException;
+
+ public RMDBean retrieve(String sequenceId) throws SandeshaStorageException;
+
+ public boolean insert(RMDBean bean) throws SandeshaStorageException;
+
+ public List find(RMDBean bean) throws SandeshaStorageException;
+
+ public boolean update(RMDBean bean) throws SandeshaStorageException;
+
+ public RMDBean findUnique (RMDBean bean) throws SandeshaException;
+
+}
Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMSBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMSBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMSBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/RMSBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1999-2004 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.storage.beanmanagers;
+
+import java.util.List;
+
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beans.RMSBean;
+
+/**
+ * This is used to manage CreateSequence beans.
+ */
+
+
+public interface RMSBeanMgr extends RMBeanManager {
+
+ public boolean insert(RMSBean bean) throws SandeshaStorageException;
+
+ public boolean delete(String msgId) throws SandeshaStorageException;
+
+ public RMSBean retrieve(String msgId) throws SandeshaStorageException;
+
+ public boolean update(RMSBean bean) throws SandeshaStorageException;
+
+ public List find(RMSBean bean) throws SandeshaStorageException;
+
+ public RMSBean findUnique (RMSBean bean) throws SandeshaException;
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org