tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject svn commit: r751297 - in /openejb/trunk/openejb3: assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/ container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/ma...
Date Sat, 07 Mar 2009 16:57:36 GMT
Author: jgallimore
Date: Sat Mar  7 16:57:34 2009
New Revision: 751297

URL: http://svn.apache.org/viewvc?rev=751297&view=rev
Log:
OPENEJB-1004 added basic HTTP auth and Username/Password WS-Security authentication to EJB Webservice endpoints

Added:
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java
    openejb/trunk/openejb3/examples/webservice-security/
    openejb/trunk/openejb3/examples/webservice-security/pom.xml
    openejb/trunk/openejb3/examples/webservice-security/src/
    openejb/trunk/openejb3/examples/webservice-security/src/main/
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
    openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
    openejb/trunk/openejb3/examples/webservice-security/src/main/resources/
    openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/
    openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml
    openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml
    openejb/trunk/openejb3/examples/webservice-security/src/test/
    openejb/trunk/openejb3/examples/webservice-security/src/test/java/
    openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/
    openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/
    openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/
    openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
    openejb/trunk/openejb3/examples/webservice-security/src/test/resources/
    openejb/trunk/openejb3/examples/webservice-security/src/test/resources/groups.properties
    openejb/trunk/openejb3/examples/webservice-security/src/test/resources/users.properties
    openejb/trunk/openejb3/examples/webservice-ws-security/
    openejb/trunk/openejb3/examples/webservice-ws-security/pom.xml
    openejb/trunk/openejb3/examples/webservice-ws-security/src/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml
    openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/META-INF/
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/groups.properties
    openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/users.properties
    openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java
    openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java
Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWsRegistry.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/AuthMethodType.java
    openejb/trunk/openejb3/examples/pom.xml
    openejb/trunk/openejb3/server/openejb-cxf/pom.xml
    openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
    openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java
    openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java
    openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java
    openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWsRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWsRegistry.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWsRegistry.java (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWsRegistry.java Sat Mar  7 16:57:34 2009
@@ -195,6 +195,10 @@
             } else if ("NONE".equals(authMethod)) {
                 context.addValve(new NonLoginAuthenticator());
             }
+
+            OpenEJBValve openejbValve = new OpenEJBValve();
+            context.getPipeline().addValve(openejbValve);
+
         } else {
             throw new IllegalArgumentException("Invalid authMethod: " + authMethod);
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/PortInfo.java Sat Mar  7 16:57:34 2009
@@ -39,4 +39,9 @@
     public String binding;
 
     public String location;
+
+    public String authMethod;
+    public String realmName;
+    public String transportGuarantee;
+    public String securityRealmName;
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/WsBuilder.java Sat Mar  7 16:57:34 2009
@@ -48,6 +48,9 @@
         portData.setWsdlPort(port.wsdlPort);
         portData.setWsdlService(port.wsdlService);
         portData.setLocation(port.location);
+
+        portData.setSecure("WS-SECURITY".equals(port.authMethod));
+
         return portData;
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java Sat Mar  7 16:57:34 2009
@@ -63,6 +63,9 @@
 import org.apache.openejb.jee.WebserviceDescription;
 import org.apache.openejb.jee.PortComponent;
 import org.apache.openejb.jee.ServiceImplBean;
+import org.apache.openejb.jee.oejb2.OpenejbJarType;
+import org.apache.openejb.jee.oejb2.SessionBeanType;
+import org.apache.openejb.jee.oejb2.WebServiceSecurityType;
 
 import javax.xml.bind.JAXBException;
 import java.util.Map;
@@ -138,6 +141,7 @@
                 }
 
                 ejbJarInfo.portInfos.addAll(configureWebservices(ejbModule.getWebservices()));
+                configureWebserviceSecurity(ejbJarInfo, ejbModule);
 
                 ejbJarInfos.put(ejbJarInfo.jarPath, ejbJarInfo);
 
@@ -237,6 +241,42 @@
 
     }
 
+    /*
+     * left package-local for a unit test
+     */
+    void configureWebserviceSecurity(EjbJarInfo ejbJarInfo, EjbModule ejbModule) {
+        Object altDD = ejbModule.getAltDDs().get("openejb-jar.xml");
+        if (altDD == null || (! (altDD instanceof OpenejbJarType))) return;
+
+        OpenejbJarType openejbJarType = (OpenejbJarType) altDD;
+
+        List<PortInfo> infoList = ejbJarInfo.portInfos;
+        for (PortInfo portInfo : infoList) {
+            String link = portInfo.serviceLink;
+
+            List<org.apache.openejb.jee.oejb2.EnterpriseBean> enterpriseBeans = openejbJarType.getEnterpriseBeans();
+            for (org.apache.openejb.jee.oejb2.EnterpriseBean enterpriseBean : enterpriseBeans) {
+                if (link.equals(enterpriseBean.getEjbName()) && enterpriseBean instanceof SessionBeanType) {
+                    SessionBeanType sessionBean = (SessionBeanType) enterpriseBean;
+                    WebServiceSecurityType webServiceSecurityType = sessionBean.getWebServiceSecurity();
+                    portInfo.realmName = webServiceSecurityType.getRealmName();
+                    portInfo.securityRealmName = webServiceSecurityType.getSecurityRealmName();
+                    if (webServiceSecurityType.getTransportGuarantee() != null) {
+                        portInfo.transportGuarantee = webServiceSecurityType.getTransportGuarantee().value();
+                    } else {
+                        portInfo.transportGuarantee = "NONE";
+                    }
+
+                    if (webServiceSecurityType.getAuthMethod() != null) {
+                        portInfo.authMethod = webServiceSecurityType.getAuthMethod().value();
+                    } else {
+                        portInfo.authMethod = "NONE";
+                    }
+                }
+            }
+        }
+    }
+
     private void buildClientModules(AppModule appModule, AppInfo appInfo, JndiEncInfoBuilder jndiEncInfoBuilder) throws OpenEJBException {
         for (ClientModule clientModule : appModule.getClientModules()) {
             ApplicationClient applicationClient = clientModule.getApplicationClient();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java Sat Mar  7 16:57:34 2009
@@ -38,6 +38,7 @@
     private QName wsdlPort;
     private QName wsdlService;
     private String location;
+    private boolean secure;
 
     public String getPortId() {
         return portId;
@@ -118,4 +119,12 @@
     public void setLocation(String location) {
         this.location = location;
     }
+
+    public void setSecure(boolean secure) {
+        this.secure = secure;
+    }
+
+    public boolean isSecure() {
+        return secure;
+    }
 }

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AppInfoBuilderTest.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,153 @@
+/**
+ * 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.openejb.config;
+
+import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.PortInfo;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SessionBean;
+import org.apache.openejb.jee.oejb2.*;
+import org.apache.openejb.jee.oejb3.OpenejbJar;
+
+import java.util.List;
+
+public class AppInfoBuilderTest extends TestCase {
+    public void testShouldAddSecurityDetailsToPortInfo() throws Exception {
+        EjbJar ejbJar = new EjbJar();
+        SessionBean sessionBean = new SessionBean();
+        sessionBean.setEjbName("MySessionBean");
+        sessionBean.setEjbClass("org.superbiz.MySessionBean");
+        sessionBean.setRemote("org.superbiz.MySession");
+        ejbJar.addEnterpriseBean(sessionBean);
+
+        OpenejbJarType openejbJarType = new OpenejbJarType();
+        SessionBeanType openejbSessionBean = new SessionBeanType();
+        openejbSessionBean.setEjbName("MySessionBean");
+
+        WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+        serviceSecurityType.setAuthMethod(AuthMethodType.BASIC);
+        serviceSecurityType.setRealmName("MyRealm");
+        serviceSecurityType.setSecurityRealmName("MySecurityRealm");
+        serviceSecurityType.setTransportGuarantee(TransportGuaranteeType.NONE);
+
+        openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+        openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+        EjbModule ejbModule =  new EjbModule(ejbJar, new OpenejbJar());
+        ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+        EjbJarInfo ejbJarInfo = new EjbJarInfo();
+        PortInfo portInfo = new PortInfo();
+        portInfo.serviceLink = "MySessionBean"; 
+        ejbJarInfo.portInfos.add(portInfo);
+
+        new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+        List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+        assertEquals(1, portInfoList.size());
+        PortInfo info = portInfoList.get(0);
+        assertEquals("MyRealm", info.realmName);
+        assertEquals("MySecurityRealm", info.securityRealmName);
+        assertEquals("BASIC", info.authMethod);
+        assertEquals("NONE", info.transportGuarantee);
+    }
+
+    public void testShouldUseDefaultsIfSettingIsNull() throws Exception {
+        EjbJar ejbJar = new EjbJar();
+        SessionBean sessionBean = new SessionBean();
+        sessionBean.setEjbName("MySessionBean");
+        sessionBean.setEjbClass("org.superbiz.MySessionBean");
+        sessionBean.setRemote("org.superbiz.MySession");
+        ejbJar.addEnterpriseBean(sessionBean);
+
+        OpenejbJarType openejbJarType = new OpenejbJarType();
+        SessionBeanType openejbSessionBean = new SessionBeanType();
+        openejbSessionBean.setEjbName("MySessionBean");
+
+        WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+        serviceSecurityType.setAuthMethod(null);
+        serviceSecurityType.setRealmName(null);
+        serviceSecurityType.setSecurityRealmName(null);
+        serviceSecurityType.setTransportGuarantee(null);
+
+        openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+        openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+        EjbModule ejbModule =  new EjbModule(ejbJar, new OpenejbJar());
+        ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+        EjbJarInfo ejbJarInfo = new EjbJarInfo();
+        PortInfo portInfo = new PortInfo();
+        portInfo.serviceLink = "MySessionBean";
+        ejbJarInfo.portInfos.add(portInfo);
+
+        new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+        List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+        assertEquals(1, portInfoList.size());
+        PortInfo info = portInfoList.get(0);
+        assertEquals(null, info.realmName);
+        assertEquals(null, info.securityRealmName);
+        assertEquals("NONE", info.authMethod);
+        assertEquals("NONE", info.transportGuarantee);
+    }
+
+    public void testShouldIngorePortInfoThatDontMatchTheEjb() throws Exception {
+        EjbJar ejbJar = new EjbJar();
+        SessionBean sessionBean = new SessionBean();
+        sessionBean.setEjbName("MySessionBean");
+        sessionBean.setEjbClass("org.superbiz.MySessionBean");
+        sessionBean.setRemote("org.superbiz.MySession");
+        ejbJar.addEnterpriseBean(sessionBean);
+
+        OpenejbJarType openejbJarType = new OpenejbJarType();
+        SessionBeanType openejbSessionBean = new SessionBeanType();
+        openejbSessionBean.setEjbName("MySessionBean");
+
+        WebServiceSecurityType serviceSecurityType = new WebServiceSecurityType();
+        serviceSecurityType.setAuthMethod(null);
+        serviceSecurityType.setRealmName(null);
+        serviceSecurityType.setSecurityRealmName(null);
+        serviceSecurityType.setTransportGuarantee(null);
+
+        openejbSessionBean.setWebServiceSecurity(serviceSecurityType);
+        openejbJarType.getEnterpriseBeans().add(openejbSessionBean);
+
+        EjbModule ejbModule =  new EjbModule(ejbJar, new OpenejbJar());
+        ejbModule.getAltDDs().put("openejb-jar.xml", openejbJarType);
+
+        EjbJarInfo ejbJarInfo = new EjbJarInfo();
+        PortInfo portInfo = new PortInfo();
+        portInfo.authMethod = "DIGEST";
+        portInfo.realmName = "";
+        portInfo.securityRealmName = "";
+        portInfo.transportGuarantee = "CONFIDENTIAL";
+        portInfo.serviceLink = "DifferentInfo";
+        ejbJarInfo.portInfos.add(portInfo);
+
+        new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
+
+        List<PortInfo> portInfoList = ejbJarInfo.portInfos;
+        assertEquals(1, portInfoList.size());
+        PortInfo info = portInfoList.get(0);
+        assertEquals("", info.realmName);
+        assertEquals("", info.securityRealmName);
+        assertEquals("DIGEST", info.authMethod);
+        assertEquals("CONFIDENTIAL", info.transportGuarantee);
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/AuthMethodType.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/AuthMethodType.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/AuthMethodType.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/oejb2/AuthMethodType.java Sat Mar  7 16:57:34 2009
@@ -45,6 +45,8 @@
     DIGEST("DIGEST"),
     @XmlEnumValue("CLIENT-CERT")
     CLIENT_CERT("CLIENT-CERT"),
+    @XmlEnumValue("WS-SECURITY")
+    WS_SECURITY("WS-SECURITY"),
     NONE("NONE");
     private final String value;
 

Modified: openejb/trunk/openejb3/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/pom.xml?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/pom.xml (original)
+++ openejb/trunk/openejb3/examples/pom.xml Sat Mar  7 16:57:34 2009
@@ -56,6 +56,8 @@
     <module>telephone-stateful</module>
     <module>webservice-attachments</module>
     <module>webapps</module>
+    <module>webservice-security</module>
+    <module>webservice-ws-security</module>
   </modules>
 </project>
 

Added: openejb/trunk/openejb3/examples/webservice-security/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/pom.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/pom.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-security/pom.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>webservice-security</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Web Examples :: EJB WebService with Security</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>5.0-1</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-client</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-clover-plugin</artifactId>
+        <configuration>
+          <jdk>1.5</jdk>
+          <excludes>
+            <exclude>**/package-info.java</exclude>
+          </excludes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>site</id>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>instrument</goal>
+              <goal>aggregate</goal>
+              <goal>save-history</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
+

Added: openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.superbiz.calculator;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value={"Administrator"})    
+@Stateless
+@WebService(
+        portName = "CalculatorPort",
+        serviceName = "CalculatorWsService",
+        targetNamespace = "http://superbiz.org/wsdl",
+        endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote    {
+
+    @RolesAllowed(value={"Administrator"})
+    public int sum(int add1, int add2) {
+        return add1 + add2;
+    }
+
+    @RolesAllowed(value={"Administrator"})
+    public int multiply(int mul1, int mul2) {
+        return mul1 * mul2;
+    }
+
+}
+//END SNIPPET: code
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,12 @@
+package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+    public int sum(int add1, int add2);
+
+    public int multiply(int mul1, int mul2);
+
+}

Added: openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/main/java/org/superbiz/calculator/CalculatorWs.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace="http://superbiz.org/wsdl" )
+public interface CalculatorWs {
+
+	public int sum(int add1, int add2);
+
+	public int multiply(int mul1, int mul2);
+}
+//END SNIPPET: code
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/ejb-jar.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/main/resources/META-INF/openejb-jar.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1,12 @@
+<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2">
+    <enterprise-beans>
+        <session>
+            <ejb-name>CalculatorImpl</ejb-name>
+            <web-service-security>
+                <security-realm-name/>
+                <transport-guarantee>NONE</transport-guarantee>
+                <auth-method>BASIC</auth-method>
+            </web-service-security>
+        </session>
+    </enterprise-beans>
+</openejb-jar>
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/test/java/org/superbiz/calculator/CalculatorTest.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,63 @@
+/**
+ * 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.superbiz.calculator;
+
+import junit.framework.TestCase;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.xml.ws.Service;
+import javax.xml.ws.BindingProvider;
+import javax.xml.namespace.QName;
+import java.net.URL;
+import java.net.PasswordAuthentication;
+import java.net.Authenticator;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+    //START SNIPPET: setup
+    private InitialContext initialContext;
+
+    protected void setUp() throws Exception {
+        Properties properties = new Properties();
+        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
+        properties.setProperty("openejb.embedded.remotable", "true");
+
+        initialContext = new InitialContext(properties);
+    }
+    //END SNIPPET: setup
+
+    /**
+     * Create a webservice client using wsdl url
+     *
+     * @throws Exception
+     */
+    //START SNIPPET: webservice
+    public void testCalculatorViaWsInterface() throws Exception {
+        Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl"), null);
+        assertNotNull(calcService);
+
+        CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+        ((BindingProvider) calc).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jane");
+        ((BindingProvider) calc).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "waterfall");
+        assertEquals(10, calc.sum(4, 6));
+        assertEquals(12, calc.multiply(3, 4));
+    }
+    //END SNIPPET: webservice
+
+}
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-security/src/test/resources/groups.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/test/resources/groups.properties?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/test/resources/groups.properties (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/test/resources/groups.properties Sat Mar  7 16:57:34 2009
@@ -0,0 +1 @@
+Administrator=jane,joe

Added: openejb/trunk/openejb3/examples/webservice-security/src/test/resources/users.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-security/src/test/resources/users.properties?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-security/src/test/resources/users.properties (added)
+++ openejb/trunk/openejb3/examples/webservice-security/src/test/resources/users.properties Sat Mar  7 16:57:34 2009
@@ -0,0 +1,2 @@
+joe=cool
+jane=waterfall
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/pom.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/pom.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/pom.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<!-- $Rev: 684173 $ $Date: 2008-08-08 20:13:24 -0700 (Fri, 08 Aug 2008) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>webservice-ws-security</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Web Examples :: EJB WebService with WS-Security</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>5.0-1</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-client</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-clover-plugin</artifactId>
+        <configuration>
+          <jdk>1.5</jdk>
+          <excludes>
+            <exclude>**/package-info.java</exclude>
+          </excludes>
+        </configuration>
+        <executions>
+          <execution>
+            <id>site</id>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>instrument</goal>
+              <goal>aggregate</goal>
+              <goal>save-history</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
+

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorImpl.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.superbiz.calculator;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.RolesAllowed;
+
+/**
+ * This is an EJB 3 style pojo stateless session bean
+ * Every stateless session bean implementation must be annotated
+ * using the annotation @Stateless
+ * This EJB has a single interface: CalculatorWs a webservice interface.
+ */
+//START SNIPPET: code
+@DeclareRoles(value={"Administrator"})    
+@Stateless
+@WebService(
+        portName = "CalculatorPort",
+        serviceName = "CalculatorWsService",
+        targetNamespace = "http://superbiz.org/wsdl",
+        endpointInterface = "org.superbiz.calculator.CalculatorWs")
+public class CalculatorImpl implements CalculatorWs, CalculatorRemote    {
+
+    @RolesAllowed(value={"Administrator"})
+    public int sum(int add1, int add2) {
+        return add1 + add2;
+    }
+
+    @RolesAllowed(value={"Administrator"})
+    public int multiply(int mul1, int mul2) {
+        return mul1 * mul2;
+    }
+
+}
+//END SNIPPET: code
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorRemote.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,12 @@
+package org.superbiz.calculator;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface CalculatorRemote {
+
+    public int sum(int add1, int add2);
+
+    public int multiply(int mul1, int mul2);
+
+}

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/java/org/superbiz/calculator/CalculatorWs.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.superbiz.calculator;
+
+import javax.jws.WebService;
+
+//END SNIPPET: code
+
+/**
+ * This is an EJB 3 webservice interface
+ * A webservice interface must be annotated with the @Local
+ * annotation.
+ */
+//START SNIPPET: code
+@WebService(targetNamespace="http://superbiz.org/wsdl" )
+public interface CalculatorWs {
+
+	public int sum(int add1, int add2);
+
+	public int multiply(int mul1, int mul2);
+}
+//END SNIPPET: code
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/ejb-jar.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1 @@
+<ejb-jar/>
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/main/resources/META-INF/openejb-jar.xml Sat Mar  7 16:57:34 2009
@@ -0,0 +1,12 @@
+<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2">
+    <enterprise-beans>
+        <session>
+            <ejb-name>CalculatorImpl</ejb-name>
+            <web-service-security>
+                <security-realm-name/>
+                <transport-guarantee>NONE</transport-guarantee>
+                <auth-method>WS-SECURITY</auth-method>
+            </web-service-security>
+        </session>
+    </enterprise-beans>
+</openejb-jar>
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/test/java/org/superbiz/calculator/CalculatorTest.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,92 @@
+/**
+ * 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.superbiz.calculator;
+
+import junit.framework.TestCase;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.ws.security.handler.WSHandlerConstants;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.ws.Service;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class CalculatorTest extends TestCase {
+
+    //START SNIPPET: setup
+    private InitialContext initialContext;
+
+    protected void setUp() throws Exception {
+        Properties properties = new Properties();
+        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
+        properties.setProperty("openejb.embedded.remotable", "true");
+
+        initialContext = new InitialContext(properties);
+    }
+    //END SNIPPET: setup
+
+    /**
+     * Create a webservice client using wsdl url
+     *
+     * @throws Exception
+     */
+    //START SNIPPET: webservice
+    public void testCalculatorViaWsInterface() throws Exception {
+        Service calcService = Service.create(new URL("http://127.0.0.1:4204/CalculatorImpl?wsdl"), null);
+        assertNotNull(calcService);
+
+        CalculatorWs calc = calcService.getPort(CalculatorWs.class);
+
+        Client client = ClientProxy.getClient(calc);
+        Endpoint endpoint = client.getEndpoint();
+        endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
+
+        Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+        outProps.put(WSHandlerConstants.USER, "jane");
+        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+        outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
+
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+                pc.setPassword("waterfall");
+            }
+        });
+
+        WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
+        endpoint.getOutInterceptors().add(wssOut);
+
+        assertEquals(10, calc.sum(4,6));
+	    assertEquals(12, calc.multiply(3,4));
+    }
+    //END SNIPPET: webservice
+
+}
\ No newline at end of file

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/groups.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/groups.properties?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/groups.properties (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/groups.properties Sat Mar  7 16:57:34 2009
@@ -0,0 +1 @@
+Administrator=jane,joe

Added: openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/users.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/users.properties?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/users.properties (added)
+++ openejb/trunk/openejb3/examples/webservice-ws-security/src/test/resources/users.properties Sat Mar  7 16:57:34 2009
@@ -0,0 +1,2 @@
+joe=cool
+jane=waterfall
\ No newline at end of file

Modified: openejb/trunk/openejb3/server/openejb-cxf/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/pom.xml?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/pom.xml Sat Mar  7 16:57:34 2009
@@ -209,10 +209,6 @@
           <artifactId>velocity</artifactId>
         </exclusion>
         <exclusion>
-          <groupId>wss4j</groupId>
-          <artifactId>wss4j</artifactId>
-        </exclusion>
-        <exclusion>
           <groupId>xalan</groupId>
           <artifactId>xalan</artifactId>
         </exclusion>
@@ -221,10 +217,6 @@
           <artifactId>xml-apis</artifactId>
         </exclusion>
         <exclusion>
-          <groupId>xml-security</groupId>
-          <artifactId>xmlsec</artifactId>
-        </exclusion>
-        <exclusion>
           <groupId>xmlbeans</groupId>
           <artifactId>xbean</artifactId>
         </exclusion>

Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java Sat Mar  7 16:57:34 2009
@@ -19,6 +19,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.DestinationFactoryManager;
@@ -26,12 +27,18 @@
 import org.apache.openejb.server.httpd.HttpRequest;
 import org.apache.openejb.server.httpd.HttpResponse;
 import org.apache.openejb.server.httpd.HttpListener;
+import org.apache.openejb.server.httpd.HttpRequestImpl;
 import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+import org.apache.openejb.util.Base64;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.loader.SystemInstance;
 
+import javax.security.auth.login.LoginException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.security.Principal;
 
 public abstract class CxfWsContainer implements HttpListener {
     protected final Bus bus;

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ServerPasswordHandler.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.openejb.server.cxf;
+
+import org.apache.ws.security.WSPasswordCallback;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.SecurityService;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginException;
+import java.io.IOException;
+
+public class ServerPasswordHandler implements CallbackHandler {
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+        SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+        Object token = null;
+        try {
+            securityService.disassociate();
+
+            token = securityService.login(pc.getIdentifer(), pc.getPassword());
+            securityService.associate(token);
+        } catch (LoginException e) {
+            throw new SecurityException("wrong password");
+        } finally {
+//            if (token != null) {
+//                securityService.disassociate();
+//            }
+        }
+    }
+}

Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java Sat Mar  7 16:57:34 2009
@@ -18,6 +18,7 @@
 package org.apache.openejb.server.cxf.ejb;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
 import org.apache.cxf.binding.soap.SoapBinding;
 import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
@@ -32,9 +33,14 @@
 import org.apache.openejb.server.cxf.CxfEndpoint;
 import org.apache.openejb.server.cxf.CxfServiceConfiguration;
 import org.apache.openejb.server.cxf.JaxWsImplementorInfoImpl;
+import org.apache.openejb.server.cxf.ServerPasswordHandler;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.WSConstants;
 
 import javax.xml.ws.WebServiceException;
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * A web service endpoint which invokes an EJB container.
@@ -86,6 +92,18 @@
         if (endpoint.getBinding() instanceof SoapBinding && !this.implInfo.isWebServiceProvider()) {
             endpoint.getService().getInInterceptors().add(new SAAJInInterceptor());
         }
+
+        // Install WSS4J interceptor
+        if (port.isSecure()) {
+            Map<String, Object> inProps = new HashMap<String, Object>();
+            inProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
+            inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
+            inProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ServerPasswordHandler.class.getName());
+
+            WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
+            endpoint.getInInterceptors().add(wssIn);
+        }
+
     }
 
     private static void removeHandlerInterceptors(List<Interceptor> interceptors) {

Modified: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java (original)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java Sat Mar  7 16:57:34 2009
@@ -35,4 +35,9 @@
         EjbEndpoint ep = new EjbEndpoint(bus, port, deploymentInfo);
         return ep;
     }
+
+    public void start() {
+        super.start();
+        this.destination.setPassSecurityContext(true);
+    }
 }

Added: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java?rev=751297&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java (added)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/BasicAuthHttpListenerWrapper.java Sat Mar  7 16:57:34 2009
@@ -0,0 +1,80 @@
+/**
+ * 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.openejb.server.webservices;
+
+import org.apache.openejb.server.httpd.HttpListener;
+import org.apache.openejb.server.httpd.HttpRequest;
+import org.apache.openejb.server.httpd.HttpResponse;
+import org.apache.openejb.util.Base64;
+import org.apache.openejb.spi.SecurityService;
+import org.apache.openejb.loader.SystemInstance;
+
+import javax.security.auth.login.LoginException;
+
+public class BasicAuthHttpListenerWrapper implements HttpListener {
+    private HttpListener httpListener;
+    private String realmName;
+
+    public BasicAuthHttpListenerWrapper(HttpListener httpListener, String realmName) {
+        this.httpListener = httpListener;
+        this.realmName = realmName;
+    }
+
+    public void onMessage(HttpRequest request, HttpResponse response) throws Exception {
+        Object token = null;
+
+        String auth = request.getHeader("Authorization");
+        if (auth != null && auth.length() > 0) {
+            if (auth.toUpperCase().startsWith("BASIC ")) {
+                auth = auth.substring(6);
+                String decoded = new String(Base64.decodeBase64(auth.getBytes()));
+                String[] parts = decoded.split(":");
+                if (parts != null && parts.length == 2) {
+                    String username = parts[0];
+                    String password = parts[1];
+
+                    try {
+                        final SecurityService securityService = getSecurityService();
+                        token = securityService.login(realmName, username, password);
+                        if (token != null) {
+                            securityService.associate(token);
+                        }
+                    } catch (LoginException e) {
+                        // login failed, return 401
+                    }
+                }
+            }
+        }
+
+        if (token != null || HttpRequest.Method.GET == request.getMethod()) {
+            httpListener.onMessage(request, response);
+        } else {
+            // login failed,  return 401
+        }
+
+        if (token != null) {
+           getSecurityService().disassociate();
+        }
+    }
+
+    private SecurityService getSecurityService() {
+        final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
+        return securityService;
+    }
+
+}

Modified: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java (original)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/OpenEJBHttpWsRegistry.java Sat Mar  7 16:57:34 2009
@@ -78,6 +78,10 @@
         if (path == null) throw new NullPointerException("contextRoot is null");
         if (httpListener == null) throw new NullPointerException("httpListener is null");
 
+        if ("BASIC".equals(authMethod)) {
+            httpListener = new BasicAuthHttpListenerWrapper(httpListener, realmName);
+        }
+
         // assure context root with a leading slash
         if (!path.startsWith("/")) path = "/" + path;
 

Modified: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java?rev=751297&r1=751296&r2=751297&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java (original)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/WsService.java Sat Mar  7 16:57:34 2009
@@ -242,8 +242,17 @@
 
                             ClassLoader classLoader = deploymentInfo.getClassLoader();
                             if (wsRegistry != null) {
-                                // add servlet to web container
-                                List<String> addresses = wsRegistry.addWsContainer(location, container, virtualHost, realmName, transportGuarantee, authMethod, classLoader);
+                                String auth = authMethod;
+                                String realm = realmName;
+                                String transport = transportGuarantee;
+
+                                if ("BASIC".equals(portInfo.authMethod) || "DIGEST".equals(portInfo.authMethod) || "CLIENT-CERT".equals(portInfo.authMethod)) {
+                                    auth = portInfo.authMethod;
+                                    realm = portInfo.realmName;
+                                    transport = portInfo.transportGuarantee;
+                                }
+
+                                List<String> addresses = wsRegistry.addWsContainer(location, container, virtualHost, realm, transport, auth, classLoader);
 
                                 // one of the registered addresses to be the connonical address
                                 String address = selectSingleAddress(addresses);



Mime
View raw message