svn commit: r942814 - in /axis/axis2/java/core/trunk/modules: jaxws-integration/test/org/apache/axis2/jaxws/misc/ jaxws-integration/test/org/apache/axis2/jaxws/misc/a/ jaxws-integration/test/org/apach
Author: scheu Date: Mon May 10 16:28:22 2010 New Revision: 942814 URL: http://svn.apache.org/viewvc?rev=942814&view=rev Log: AXIS2-4708 Contributor:Rich Scheuerle Summary: JAX-WS change to prefer referenced JAXB classes during JAXBContext construction. A validation test is contributed with the code. Added: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean1.java axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean2.java axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/b/ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/b/Bean1.java axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/b/Bean2.java Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java?rev=942814&r1=942813&r2=942814&view=diff == --- axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java Mon May 10 16:28:22 2010 @@ -186,4 +186,30 @@ public class JAXBContextTest extends Abs assertTrue(jaxbContext4 != jaxbContext3); assertTrue(context4.contains("org.test.addnumbers")); } + +public void test03() throws JAXBException { +// Simulate a web services that references a.Bean2 and b.Bean1 +// Note that both these beans are in the same namespace +// but not the same package. +// Also note that there are other colliding classes in the +// packages. +TreeSet context = new TreeSet(); +context.add("org.apache.axis2.jaxws.misc.a"); +context.add("org.apache.axis2.jaxws.misc.b"); +context.add("[org.apache.axis2.jaxws.misc.a.Bean2]"); +context.add("[org.apache.axis2.jaxws.misc.b.Bean1]"); + + +JAXBContext jaxbContext = JAXBUtils.getJAXBContext(context); + +// Ensure that the jaxbContext IS produced and contains +// both a.Bean2 and b.Bean1. +String jaxbContextString = jaxbContext.toString(); + +assertTrue("The JAXBContext should contain a.Bean2: " + jaxbContextString, + jaxbContextString.indexOf("org.apache.axis2.jaxws.misc.a.Bean2") > 0); +assertTrue("The JAXBContext should contain b.Bean1: " + jaxbContextString, + jaxbContextString.indexOf("org.apache.axis2.jaxws.misc.b.Bean1") > 0); + +} } \ No newline at end of file Added: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean1.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean1.java?rev=942814&view=auto == --- axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean1.java (added) +++ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/misc/a/Bean1.java Mon May 10 16:28:22 2010 @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.axis2.jaxws.misc.a; + +import javax.xml.bind.annotation.XmlType; + +...@xmlt
svn commit: r942898 - in /axis/axis2/java/core/trunk/modules: jaxws/test/org/apache/axis2/jaxws/spi/ metadata/src/org/apache/axis2/jaxws/description/ metadata/src/org/apache/axis2/jaxws/description/bu
Author: barrettj Date: Mon May 10 20:51:22 2010 New Revision: 942898 URL: http://svn.apache.org/viewvc?rev=942898&view=rev Log: Add a String property on the sparse composite that will be included as part of the uniqueness of the client-side Service instance. This can be used to attach unique configurations (such as policy set) to different instances of the same WSDL Service injected on the client if each service uses a different service ref name for example. Add associated TDD test also. Added: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataServiceRefNameTests.java Modified: axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Added: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataServiceRefNameTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataServiceRefNameTests.java?rev=942898&view=auto == --- axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataServiceRefNameTests.java (added) +++ axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataServiceRefNameTests.java Mon May 10 20:51:22 2010 @@ -0,0 +1,331 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.axis2.jaxws.spi; + +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.jaxws.description.DescriptionTestUtils2; +import org.apache.axis2.jaxws.description.EndpointDescription; +import org.apache.axis2.jaxws.description.ServiceDescription; +import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite; +import org.apache.axis2.jaxws.description.builder.MDQConstants; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; + +import java.net.URL; + +import junit.framework.TestCase; + +/** + * Validate the behavior related to a ServiceRefName being specified (or not) in the client metadata. Different + * ServiceRefName values should result in different instances of an AxisService. This is so that unique policy sets + * can be attached to AxisSerivces based on a ServiceRefName. If the ServiceRefName is not unique then the AxisService + * should be shared. Also if no ServiceRefName is specified, the AxisService should be shared. + * + * Note that all these tests require that a test client configuration factory which caches ServiceDescriptions be + * installed and restored at the end. + */ +public class ClientMetadataServiceRefNameTests extends TestCase { +static final String namespaceURI = "http://description.jaxws.axis2.apache.org";; +static final String svcLocalPart = "svcLocalPart"; +static final String originalWsdl_portLocalPart = "portLocalPart"; + + +static final String originalWsdl = "ClientMetadata.wsdl"; + +// All tests require a test client configuration factory which caches ServiceDescriptions +protected void setUp() throws Exception { +ClientMetadataTest.installCachingFactory(); +} +protected void tearDown() throws Exception { +ClientMetadataTest.restoreOriginalFactory(); +} + +/** + * Validate that multiple ports created under the same service without additional service metadata + * specified via a setServiceMetatadata(composite) and therefore without a service ref name being specified + * share the same description objects and Axis service. + */ +public void testNoServiceRefNameSameService() { +QName servic
svn commit: r943002 - in /axis/axis2/java/rampart/trunk/modules: rampart-core/src/main/java/org/apache/rampart/ rampart-core/src/main/java/org/apache/rampart/policy/builders/ rampart-core/src/main/jav
Author: prabath Date: Tue May 11 06:28:50 2010 New Revision: 943002 URL: http://svn.apache.org/viewvc?rev=943002&view=rev Log: Fix for https://issues.apache.org/jira/browse/RAMPART-294 - thanks AmilaJ for the patch Added: axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/ServiceNonceCache.java axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/UniqueMessageAttributeCache.java axis/axis2/java/rampart/trunk/modules/rampart-tests/src/test/java/org/apache/rampart/NonceCacheTest.java Modified: axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/RampartEngine.java axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/errors.properties axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/policy/builders/RampartConfigBuilder.java axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/policy/model/RampartConfig.java Modified: axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/RampartEngine.java URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/RampartEngine.java?rev=943002&r1=943001&r2=943002&view=diff == --- axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/RampartEngine.java (original) +++ axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/RampartEngine.java Tue May 11 06:28:50 2010 @@ -18,6 +18,8 @@ package org.apache.rampart; import org.apache.axiom.om.OMElement; import org.apache.axiom.soap.*; +import org.apache.axiom.soap.SOAP11Constants; +import org.apache.axiom.soap.SOAP12Constants; import org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; import org.apache.commons.logging.Log; @@ -30,10 +32,7 @@ import org.apache.rampart.policy.Rampart import org.apache.rampart.util.Axis2Util; import org.apache.rampart.util.RampartUtil; import org.apache.ws.secpolicy.WSSPolicyException; -import org.apache.ws.security.WSConstants; -import org.apache.ws.security.WSSecurityEngine; -import org.apache.ws.security.WSSecurityEngineResult; -import org.apache.ws.security.WSSecurityException; +import org.apache.ws.security.*; import org.apache.ws.security.components.crypto.Crypto; import org.apache.ws.security.saml.SAMLKeyInfo; import org.apache.ws.security.saml.SAMLUtil; @@ -53,7 +52,8 @@ import java.util.Vector; public class RampartEngine { private static Log log = LogFactory.getLog(RampartEngine.class); - private static Log tlog = LogFactory.getLog(RampartConstants.TIME_LOG); + private static Log tlog = LogFactory.getLog(RampartConstants.TIME_LOG); +private static ServiceNonceCache serviceNonceCache = new ServiceNonceCache(); public Vector process(MessageContext msgCtx) throws WSSPolicyException, RampartException, WSSecurityException, AxisFault { @@ -230,9 +230,42 @@ public class RampartEngine { } } else if (WSConstants.UT == actInt.intValue()) { -String username = ((Principal) wser.get(WSSecurityEngineResult.TAG_PRINCIPAL)) -.getName(); + + WSUsernameTokenPrincipal userNameTokenPrincipal = (WSUsernameTokenPrincipal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL); + +String username = userNameTokenPrincipal.getName(); msgCtx.setProperty(RampartMessageData.USERNAME, username); + +if (userNameTokenPrincipal.getNonce() != null) { +// Check whether this is a replay attack. To verify that we need to check whether nonce value +// is a repeating one +int nonceLifeTimeInSeconds = 0; + +if (rpd.getRampartConfig() != null) { + +String stringLifeTime = rpd.getRampartConfig().getNonceLifeTime(); + +try { +nonceLifeTimeInSeconds = Integer.parseInt(stringLifeTime); + +} catch (NumberFormatException e) { +log.error("Invalid value for nonceLifeTime in rampart configuration file.", e); +throw new RampartException( +"invalidNonceLifeTime", e); + +} +} + +String serviceEndpointName = msgCtx.getAxisService().getEndpointName(); + +boolean valueRepeating = serviceNonceCache.isNonceRepeatingForService(serviceEndpointName, username, userNameTokenPrincipal.getNonce()); + +if (valueRepeating){ +throw new RampartExceptio