Author: muthulee
Date: Mon Feb  5 03:14:46 2007
New Revision: 503634

URL: http://svn.apache.org/viewvc?view=rev&rev=503634
Log:
The resources needed to perfom wsdl2java 

Added:
    webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/ping.wsdl
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/PingPortSkeleton.java
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/InteropScenarioClient.java
    
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/PWCallback.java

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/ping.wsdl
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/ping.wsdl?view=auto&rev=503634
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/ping.wsdl
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/ping.wsdl
 Mon Feb  5 03:14:46 2007
@@ -0,0 +1,99 @@
+<definitions 
xmlns:s1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+             xmlns:http="http://schemas.xmlsoap.org/wsdl/http/";
+             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
+             xmlns:s="http://www.w3.org/2001/XMLSchema";
+             xmlns:tns="http://xmlsoap.org/Ping";
+             xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
+             xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/";
+             xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/";
+             targetNamespace="http://xmlsoap.org/Ping";
+             xmlns="http://schemas.xmlsoap.org/wsdl/";>
+    <types>
+        <s:schema elementFormDefault="qualified" 
targetNamespace="http://xmlsoap.org/Ping";>
+            <s:import 
namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
+            <s:element name="Ping" nillable="true" type="tns:ping"/>
+            <s:complexType name="ping">
+                <s:sequence>
+                    <s:element minOccurs="0" maxOccurs="1" name="ticket" 
type="tns:ticketType"/>
+                    <s:element minOccurs="1" maxOccurs="1" name="text" 
nillable="true" type="s:string"/>
+                </s:sequence>
+            </s:complexType>
+            <s:complexType name="ticketType">
+                <s:simpleContent>
+                    <s:extension base="s:string">
+                        <s:attribute ref="s1:Id"/>
+                    </s:extension>
+                </s:simpleContent>
+            </s:complexType>
+            <s:element name="PingResponse" nillable="true" 
type="tns:pingResponse"/>
+            <s:complexType name="pingResponse">
+                <s:sequence>
+                    <s:element minOccurs="1" maxOccurs="1" name="text" 
nillable="true" type="s:string"/>
+                </s:sequence>
+            </s:complexType>
+        </s:schema>
+        <s:schema elementFormDefault="qualified" 
targetNamespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";>
+            <s:attribute name="Id" type="s:string"/>
+        </s:schema>
+    </types>
+    <message name="PingRequest">
+        <part name="ping" element="tns:Ping"/>
+    </message>
+    <message name="PingResponse">
+        <part name="pingResponse" element="tns:PingResponse"/>
+    </message>
+    <portType name="PingPort">
+        <operation name="Ping">
+            <input message="tns:PingRequest"/>
+            <output message="tns:PingResponse"/>
+        </operation>
+    </portType>
+    <binding name="PingBinding" type="tns:PingPort">
+        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <operation name="Ping">
+            <soap:operation soapAction="urn:Ping" style="document"/>
+            <input>
+                <soap:body use="literal"/>
+            </input>
+            <output>
+                <soap:body use="literal"/>
+            </output>
+        </operation>
+    </binding>
+    <service name="PingPort">
+        <port name="Ping1" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping1"/>
+        </port>
+        <port name="Ping2" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping2"/>
+        </port>
+        <port name="Ping2a" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping2a"/>
+        </port>
+        <port name="Ping3" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping3"/>
+        </port>
+        <port name="Ping4" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping4"/>
+        </port>
+        <port name="Ping5" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping5"/>
+        </port>
+        <port name="Ping6" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping6"/>
+        </port>
+        <port name="Ping7" binding="tns:PingBinding">
+            <soap:address location="http://localhost:9080/pingservice/Ping7"/>
+        </port>
+        <port name="STPing1" binding="tns:PingBinding">
+            <soap:address 
location="http://localhost:9080/pingservice/STPing1"/>
+        </port>
+        <port name="STPing3" binding="tns:PingBinding">
+            <soap:address 
location="http://localhost:9080/pingservice/STPing3"/>
+        </port>
+        <port name="STPing4" binding="tns:PingBinding">
+            <soap:address 
location="http://localhost:9080/pingservice/STPing4"/>
+        </port>
+        
+    </service>
+</definitions>

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/PingPortSkeleton.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/PingPortSkeleton.java?view=auto&rev=503634
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/PingPortSkeleton.java
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/oasis/ping/PingPortSkeleton.java
 Mon Feb  5 03:14:46 2007
@@ -0,0 +1,74 @@
+/*
+* 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.axis2.oasis.ping;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
+import org.xmlsoap.ping.PingDocument;
+import org.xmlsoap.ping.PingResponse;
+import org.xmlsoap.ping.PingResponseDocument;
+
+import java.util.Vector;
+
+/**
+ * Auto generated java skeleton for the service by the Axis code generator
+ */
+public class PingPortSkeleton{
+    /**
+     * Auto generated method signature
+     *
+     * @param param0
+     */
+    public PingResponseDocument Ping
+            (PingDocument param0) {
+        Vector results = null;
+        MessageContext msgCtx = MessageContext.getCurrentMessageContext();
+        if ((results =
+                (Vector) msgCtx.getProperty(WSHandlerConstants.RECV_RESULTS))
+                == null) {
+            System.out.println("No security results!!");
+            throw new RuntimeException("No security results!!");
+        } else {
+            System.out.println("Number of results: " + results.size());
+            for (int i = 0; i < results.size(); i++) {
+                WSHandlerResult rResult =
+                        (WSHandlerResult) results.get(i);
+                Vector wsSecEngineResults = rResult.getResults();
+    
+                for (int j = 0; j < wsSecEngineResults.size(); j++) {
+                    WSSecurityEngineResult wser =
+                            (WSSecurityEngineResult) wsSecEngineResults.get(j);
+                    if (wser.getAction() != WSConstants.ENCR && 
wser.getPrincipal() != null) {
+                        System.out.println(wser.getPrincipal().getName());
+                    }
+                }
+            }
+            PingResponseDocument response = 
PingResponseDocument.Factory.newInstance();
+            PingResponse pingRes = response.addNewPingResponse();
+            pingRes.setText("Response: " + param0.getPing().getText());
+            return response;
+        }
+    }
+
+}
+    
\ No newline at end of file

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/InteropScenarioClient.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/InteropScenarioClient.java?view=auto&rev=503634
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/InteropScenarioClient.java
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/InteropScenarioClient.java
 Mon Feb  5 03:14:46 2007
@@ -0,0 +1,179 @@
+/*
+ * 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.axis2.security;
+
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.oasis.ping.PingPortStub;
+import org.apache.rampart.handler.WSSHandlerConstants;
+import org.apache.rampart.handler.config.InflowConfiguration;
+import org.apache.rampart.handler.config.OutflowConfiguration;
+import org.xmlsoap.ping.Ping;
+import org.xmlsoap.ping.PingDocument;
+import org.xmlsoap.ping.PingResponse;
+import org.xmlsoap.ping.PingResponseDocument;
+import org.xmlsoap.ping.TicketType;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * Client for the interop service This MUST be used with the codegen'ed classes
+ */
+public class InteropScenarioClient {
+
+    String soapNsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+    public InteropScenarioClient(boolean useSOAP12InStaticConfigTest) {
+        if (useSOAP12InStaticConfigTest) {
+            soapNsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+        }
+    }
+
+    public void invokeWithStaticConfig(String clientRepo, String url)
+            throws Exception {
+        TicketType ticket = TicketType.Factory.newInstance();
+        ticket.setId("My ticket Id");
+
+        Ping ping = Ping.Factory.newInstance();
+        ping.setText("Testing axis2-wss4j module");
+        ping.setTicket(ticket);
+
+        PingDocument pingDoc = PingDocument.Factory.newInstance();
+        pingDoc.setPing(ping);
+
+        ConfigurationContext configCtx = ConfigurationContextFactory
+                        .createConfigurationContextFromFileSystem(clientRepo,
+                                clientRepo + "/conf/axis2.xml");
+        PingPortStub stub = new PingPortStub(configCtx, url);
+
+        // Enable MTOM to those scenarios where they are configured using:
+        // <optimizeParts>xpathExpression</optimizeParts>
+        stub._getServiceClient().getOptions().setProperty(
+                Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        stub._getServiceClient().getOptions().setSoapVersionURI(soapNsURI);
+        stub._getServiceClient().engageModule(
+                new javax.xml.namespace.QName("rampart"));
+
+        PingResponseDocument pingResDoc = stub.Ping(pingDoc);
+
+        PingResponse pingRes = pingResDoc.getPingResponse();
+
+        System.out.println(pingRes.getText());
+    }
+
+    public void invokeWithGivenConfig(String clientRepo, String url,
+            OutflowConfiguration outflowConfig, InflowConfiguration 
inflowConfig)
+            throws Exception {
+        TicketType ticket = TicketType.Factory.newInstance();
+        ticket.setId("My ticket Id");
+
+        Ping ping = Ping.Factory.newInstance();
+        ping.setText("Testing axis2-wss4j module");
+        ping.setTicket(ticket);
+
+        PingDocument pingDoc = PingDocument.Factory.newInstance();
+        pingDoc.setPing(ping);
+
+        PingPortStub stub = new PingPortStub(ConfigurationContextFactory
+                .createConfigurationContextFromFileSystem(clientRepo,
+                        clientRepo + "/conf/axis2.xml"), url);
+
+        // Enable MTOM to those scenarios where they are configured using:
+        // <optimizeParts>xpathExpression</optimizeParts>
+        stub._getServiceClient().getOptions().setProperty(
+                Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        // Engage the security module
+        stub._getServiceClient().engageModule(
+                new javax.xml.namespace.QName("rampart"));
+
+        if (outflowConfig != null) {
+            stub._getServiceClient().getOptions().setProperty(
+                    WSSHandlerConstants.OUTFLOW_SECURITY,
+                    outflowConfig.getProperty());
+        }
+        if (inflowConfig != null) {
+            stub._getServiceClient().getOptions().setProperty(
+                    WSSHandlerConstants.INFLOW_SECURITY,
+                    inflowConfig.getProperty());
+        }
+        PingResponseDocument pingResDoc = stub.Ping(pingDoc);
+
+        PingResponse pingRes = pingResDoc.getPingResponse();
+
+        System.out.println(pingRes.getText());
+        stub = null;
+    }
+
+    public void invokeWithGivenConfigWithProRefs(String clientRepo, String url,
+            OutflowConfiguration outflowConfig, InflowConfiguration 
inflowConfig,
+            Hashtable propRefs)
+            throws Exception {
+        TicketType ticket = TicketType.Factory.newInstance();
+        ticket.setId("My ticket Id");
+
+        Ping ping = Ping.Factory.newInstance();
+        ping.setText("Testing axis2-wss4j module");
+        ping.setTicket(ticket);
+
+        PingDocument pingDoc = PingDocument.Factory.newInstance();
+        pingDoc.setPing(ping);
+
+        PingPortStub stub = new PingPortStub(ConfigurationContextFactory
+                .createConfigurationContextFromFileSystem(clientRepo,
+                        clientRepo + "/conf/axis2.xml"), url);
+
+        // Enable MTOM to those scenarios where they are configured using:
+        // <optimizeParts>xpathExpression</optimizeParts>
+        stub._getServiceClient().getOptions().setProperty(
+                Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        // Engage the security module
+        stub._getServiceClient().engageModule(
+                new javax.xml.namespace.QName("rampart"));
+
+        if (outflowConfig != null) {
+            stub._getServiceClient().getOptions().setProperty(
+                    WSSHandlerConstants.OUTFLOW_SECURITY,
+                    outflowConfig.getProperty());
+        }
+        if (inflowConfig != null) {
+            stub._getServiceClient().getOptions().setProperty(
+                    WSSHandlerConstants.INFLOW_SECURITY,
+                    inflowConfig.getProperty());
+        }
+        
+        if(propRefs != null) {
+            Enumeration keysEnum = propRefs.keys();
+            while (keysEnum.hasMoreElements()) {
+                String refKey = (String) keysEnum.nextElement();
+                
+                stub._getServiceClient().getOptions().setProperty(refKey,
+                       propRefs.get(refKey));
+            }
+        }
+        
+        PingResponseDocument pingResDoc = stub.Ping(pingDoc);
+
+        PingResponse pingRes = pingResDoc.getPingResponse();
+
+        System.out.println(pingRes.getText());
+        stub = null;
+    }
+}

Added: 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/PWCallback.java
URL: 
http://svn.apache.org/viewvc/webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/PWCallback.java?view=auto&rev=503634
==============================================================================
--- 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/PWCallback.java
 (added)
+++ 
webservices/rampart/trunk/java/modules/rampart-integration/resources/ping/src/org/apache/axis2/security/PWCallback.java
 Mon Feb  5 03:14:46 2007
@@ -0,0 +1,185 @@
+/*
+ * 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.axis2.security;
+
+
+import org.apache.ws.security.WSPasswordCallback;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import java.io.IOException;
+
+
+
+/**
+
+ * Class PWCallback
+
+ */
+
+public class PWCallback implements CallbackHandler {
+
+
+
+    /** Field key */
+
+    private static final byte[] key = {
+
+        (byte) 0x31, (byte) 0xfd, (byte) 0xcb, (byte) 0xda, (byte) 0xfb,
+
+        (byte) 0xcd, (byte) 0x6b, (byte) 0xa8, (byte) 0xe6, (byte) 0x19,
+
+        (byte) 0xa7, (byte) 0xbf, (byte) 0x51, (byte) 0xf7, (byte) 0xc7,
+
+        (byte) 0x3e, (byte) 0x80, (byte) 0xae, (byte) 0x98, (byte) 0x51,
+
+        (byte) 0xc8, (byte) 0x51, (byte) 0x34, (byte) 0x04,
+
+    };
+
+
+
+    /*
+
+     * (non-Javadoc)
+
+     * @see 
javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
+
+     */
+
+
+
+    /**
+
+     * Method handle
+
+     * 
+
+     * @param callbacks 
+
+     * @throws java.io.IOException                  
+
+     * @throws javax.security.auth.callback.UnsupportedCallbackException 
+
+     */
+
+    public void handle(Callback[] callbacks)
+
+            throws IOException, UnsupportedCallbackException {
+
+
+
+        for (int i = 0; i < callbacks.length; i++) {
+
+            if (callbacks[i] instanceof WSPasswordCallback) {
+
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+
+
+
+                /*
+
+                 * This usage type is used only in case we received a
+
+                 * username token with a password of type PasswordText or
+
+                 * an unknown password type.
+
+                 * 
+
+                 * This case the WSPasswordCallback object contains the
+
+                 * identifier (aka username), the password we received, and
+
+                 * the password type string to identify the type.
+
+                 * 
+
+                 * Here we perform only a very simple check.
+
+                 */
+
+                if (pc.getUsage() == 
WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
+
+                       if(pc.getIdentifer().equals("Ron") && 
pc.getPassword().equals("noR")) {
+
+                        return;
+
+                       }
+
+                    if (pc.getPassword().equals("sirhC")) {
+
+                        return;
+
+                    }                  
+
+                    throw new UnsupportedCallbackException(callbacks[i],
+
+                    "check failed");
+
+                }
+
+                /*
+
+                 * here call a function/method to lookup the password for
+
+                 * the given identifier (e.g. a user name or keystore alias)
+
+                 * e.g.: 
pc.setPassword(passStore.getPassword(pc.getIdentfifier))
+
+                 * for Testing we supply a fixed name here.
+
+                 */
+
+                if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
+
+                    pc.setKey(key);
+
+                } else if(pc.getIdentifer().equals("alice")) {
+
+                    pc.setPassword("password");
+
+                } else if(pc.getIdentifer().equals("bob")) {
+
+                    pc.setPassword("password");
+
+                } else if(pc.getIdentifer().equals("Ron")) {
+
+                    pc.setPassword("noR");
+
+                } else {
+
+                    pc.setPassword("sirhC");
+
+                }
+
+            } else {
+
+                throw new UnsupportedCallbackException(callbacks[i],
+
+                        "Unrecognized Callback");
+
+            }
+
+        }
+
+    }
+
+}
+
+


Reply via email to