Author: thomas.diesler(a)jboss.com
Date: 2007-05-15 01:10:13 -0400 (Tue, 15 May 2007)
New Revision: 3094
Added:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/WebAppGeneratorDeployer.java
Removed:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointPublisher.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/IOUtils.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptor.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptorFactory.java
Modified:
branches/tdiesler/trunk/jbossws/.classpath
branches/tdiesler/trunk/jbossws/ant-import-tests/build-testsuite.xml
branches/tdiesler/trunk/jbossws/ant-import/build-deploy.xml
branches/tdiesler/trunk/jbossws/build.xml
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointGeneratorEJB.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/ReceiveUsernameOperation.java
Log:
restructure
Modified: branches/tdiesler/trunk/jbossws/.classpath
===================================================================
--- branches/tdiesler/trunk/jbossws/.classpath 2007-05-14 21:45:21 UTC (rev 3093)
+++ branches/tdiesler/trunk/jbossws/.classpath 2007-05-15 05:10:13 UTC (rev 3094)
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="org/jboss/test/ws/jaxrpc/samples/jmstransport/"
kind="src" path="src/test/java"/>
<classpathentry kind="src"
path="output-tests/wsconsume/java"/>
- <classpathentry
excluding="org/jboss/test/ws/benchmark/|org/jboss/test/ws/interop/|org/jboss/test/ws/jaxrpc/samples/jmstransport/OrganizationJMSEndpoint.java"
kind="src" path="src/test/java"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib"
path="thirdparty/ejb3.deployer/jboss-annotations-ejb3.jar"/>
+ <classpathentry combineaccessrules="false" kind="src"
path="/spi"/>
<classpathentry kind="lib" path="thirdparty/activation.jar"/>
<classpathentry kind="lib" path="thirdparty/getopt.jar"/>
<classpathentry kind="lib" path="thirdparty/javassist.jar"/>
@@ -27,12 +27,11 @@
<classpathentry kind="lib" path="thirdparty/xalan.jar"/>
<classpathentry kind="lib" path="thirdparty/xercesImpl.jar"/>
<classpathentry kind="lib" path="thirdparty/xmlsec.jar"/>
- <classpathentry kind="lib" path="thirdparty/qdox.jar"/>
<classpathentry kind="lib" path="thirdparty/ant.jar"/>
+ <classpathentry kind="lib" path="thirdparty/qdox.jar"/>
+ <classpathentry kind="lib" path="thirdparty/xmlunit1.0.jar"/>
+ <classpathentry kind="lib" path="/spi/thirdparty/junit.jar"/>
<classpathentry kind="lib" path="thirdparty/policy.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
- <classpathentry kind="lib" path="thirdparty/xmlunit1.0.jar"/>
- <classpathentry combineaccessrules="false" kind="src"
path="/jbossws-spi"/>
- <classpathentry kind="lib"
path="/jbossws-spi/thirdparty/junit.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified: branches/tdiesler/trunk/jbossws/ant-import/build-deploy.xml
===================================================================
--- branches/tdiesler/trunk/jbossws/ant-import/build-deploy.xml 2007-05-14 21:45:21 UTC
(rev 3093)
+++ branches/tdiesler/trunk/jbossws/ant-import/build-deploy.xml 2007-05-15 05:10:13 UTC
(rev 3094)
@@ -15,17 +15,12 @@
<!-- Deploy jbossws to jboss50 -->
<target name="deploy-jboss50" depends="prepare"
description="Deploy jbossws">
- <ant antfile="${jbws.jboss50.dir}/build.xml" target="deploy"
inheritall="false"/>
+ <ant antfile="${int.jbws50.dir}/build.xml" target="deploy"
inheritall="false"/>
</target>
<!-- Deploy jbossws to jboss42 -->
<target name="deploy-jboss42" depends="prepare"
description="Deploy jbossws">
- <ant antfile="${jbws.jboss42.dir}/build.xml" target="deploy"
inheritall="false"/>
+ <ant antfile="${int.jbws42.dir}/build.xml" target="deploy"
inheritall="false"/>
</target>
- <!-- Deploy jbossws to jboss40 -->
- <target name="deploy-jboss40" depends="prepare"
description="Deploy jbossws">
- <ant antfile="${jbws.jboss40.dir}/build.xml" target="deploy"
inheritall="false"/>
- </target>
-
</project>
Modified: branches/tdiesler/trunk/jbossws/ant-import-tests/build-testsuite.xml
===================================================================
--- branches/tdiesler/trunk/jbossws/ant-import-tests/build-testsuite.xml 2007-05-14
21:45:21 UTC (rev 3093)
+++ branches/tdiesler/trunk/jbossws/ant-import-tests/build-testsuite.xml 2007-05-15
05:10:13 UTC (rev 3094)
@@ -11,6 +11,7 @@
<project>
<property name="tests.dir" value="${core.dir}/src/test"/>
+ <property name="tests.output.dir"
value="${core.dir}/output-tests"/>
<import file="${build.dir}/ant-import/build-testsuite.xml"/>
@@ -24,7 +25,7 @@
<!--
Init the various classpaths
-->
- <target name="tests-init"
depends="tests-prepare,thirdparty-classpath">
+ <target name="tests-init" depends="jars,tests-prepare">
<path id="jbossws.classpath">
<pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
Modified: branches/tdiesler/trunk/jbossws/build.xml
===================================================================
--- branches/tdiesler/trunk/jbossws/build.xml 2007-05-14 21:45:21 UTC (rev 3093)
+++ branches/tdiesler/trunk/jbossws/build.xml 2007-05-15 05:10:13 UTC (rev 3094)
@@ -219,8 +219,8 @@
</target>
<target name="clobber" depends="clean" description="Cleans
up all generated files.">
- <delete dir="${basedir}/output-tests"/>
- <delete dir="${basedir}/thirdparty"/>
+ <delete dir="${core.dir}/output-tests"/>
+ <delete dir="${core.dir}/thirdparty"/>
</target>
<target name="main" description="Executes the default target
(most)." depends="most"/>
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointPublisher.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointPublisher.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointPublisher.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -1,265 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core.deployment;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.Servlet;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.utils.DOMWriter;
-import org.jboss.ws.core.utils.IOUtils;
-import org.jboss.ws.core.utils.JavaUtils;
-import org.jboss.ws.integration.Endpoint;
-import org.jboss.ws.integration.deployment.UnifiedDeploymentInfo;
-import org.jboss.ws.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-/**
- * The publisher for web service endpoints
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 12-May-2006
- */
-public class ServiceEndpointPublisher
-{
- // logging support
- private static Logger log = Logger.getLogger(ServiceEndpointPublisher.class);
-
- // The configured service endpoint servlet
- private String servletClass;
-
- // The results of the URL rewriting
- public class RewriteResults
- {
- // The URL to the rewrittn web.xml
- public URL webXML;
- // Maps the servlet name to the target bean
- public Map<String, String> sepTargetMap = new HashMap<String,
String>();
- }
-
- public String getServletClass()
- {
- return servletClass;
- }
-
- public void setServletClass(String servletClass)
- {
- this.servletClass = servletClass;
- }
-
- public RewriteResults rewriteWebXml(UnifiedDeploymentInfo udi)
- {
- URL warURL = udi.webappURL;
- File warFile = new File(warURL.getFile());
- if (warFile.isDirectory() == false)
- throw new WSException("Expected a war directory: " + warURL);
-
- File webXML = new File(warURL.getFile() + "/WEB-INF/web.xml");
- if (webXML.isFile() == false)
- throw new WSException("Cannot find web.xml: " + webXML);
-
- try
- {
- // After redeployment there might be a stale copy of the original
web.xml.org,
we delete it
- File orgWebXML = new File(webXML.getCanonicalPath() + ".org");
- orgWebXML.delete();
-
- // Rename the web.xml
- if (webXML.renameTo(orgWebXML) == false)
- throw new WSException("Cannot rename web.xml: " + orgWebXML);
-
- FileInputStream stream = new FileInputStream(orgWebXML);
- return rewriteWebXml(stream, webXML, udi.classLoader);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception e)
- {
- throw new WSException(e);
- }
- }
-
- public RewriteResults rewriteWebXml(InputStream source, File dest, ClassLoader loader)
throws Exception
- {
- if (dest == null)
- {
- dest = File.createTempFile("jbossws-alt-web", "xml",
IOUtils.createTempDirectory());
- dest.deleteOnExit();
- }
-
- Element root = DOMUtils.parse(source);
- RewriteResults results = modifyServletConfig(root, loader);
- results.webXML = dest.toURL();
-
- FileOutputStream fos = new FileOutputStream(dest);
- new DOMWriter(fos).setPrettyprint(true).print(root);
- fos.flush();
- fos.close();
-
- return results;
- }
-
- private RewriteResults modifyServletConfig(Element root, ClassLoader loader) throws
ClassNotFoundException
- {
- RewriteResults results = new RewriteResults();
- Iterator itServlets = DOMUtils.getChildElements(root, "servlet");
- while (itServlets.hasNext())
- {
- Element servletElement = (Element)itServlets.next();
- String linkName =
DOMUtils.getTextContent(DOMUtils.getFirstChildElement(servletElement,
"servlet-name"));
-
- // find the servlet-class
- Element classElement = DOMUtils.getFirstChildElement(servletElement,
"servlet-class");
-
- // JSP
- if (classElement == null)
- continue;
-
- String orgServletClassName = DOMUtils.getTextContent(classElement).trim();
-
- // Get the servlet class
- Class orgServletClass = null;
- if (loader != null)
- {
- try
- {
- orgServletClass = loader.loadClass(orgServletClassName);
- }
- catch (ClassNotFoundException ex)
- {
- log.warn("Cannot load servlet class: " + orgServletClassName);
- }
- }
-
- String targetBeanName = null;
-
- // Nothing to do if we have an <init-param>
- if (isAlreadyModified(servletElement))
- {
- Iterator itParams = DOMUtils.getChildElements(servletElement,
"init-param");
- while (itParams.hasNext())
- {
- Element elParam = (Element)itParams.next();
- Element elParamName = DOMUtils.getFirstChildElement(elParam,
"param-name");
- Element elParamValue = DOMUtils.getFirstChildElement(elParam,
"param-value");
- if
(Endpoint.SEPID_DOMAIN_ENDPOINT.equals(DOMUtils.getTextContent(elParamName)))
- {
- targetBeanName = DOMUtils.getTextContent(elParamValue);
- }
- }
- }
- else
- {
- // Check if it is a real servlet that we can ignore
- if (orgServletClass != null &&
JavaUtils.isAssignableFrom(Servlet.class, orgServletClass))
- {
- log.info("Ignore servlet: " + orgServletClassName);
- continue;
- }
- else if (orgServletClassName.endsWith("Servlet"))
- {
- log.info("Ignore <servlet-class> that ends with
'Servlet': " + orgServletClassName);
- continue;
- }
-
- // build a list of detached elements that come after <servlet-class>
- boolean startDetach = false;
- List<Element> detachedElements = new ArrayList<Element>();
- Iterator itDetached = DOMUtils.getChildElements(servletElement);
- while (itDetached.hasNext())
- {
- Element el = (Element)itDetached.next();
- if (startDetach == true)
- {
- detachedElements.add(el);
- servletElement.removeChild(el);
- }
- if (el.equals(classElement))
- {
- servletElement.removeChild(el);
- startDetach = true;
- }
- }
-
- // replace the class name
- classElement = (Element)DOMUtils.createElement("servlet-class");
- classElement.appendChild(DOMUtils.createTextNode(servletClass));
- classElement =
(Element)servletElement.getOwnerDocument().importNode(classElement, true);
- servletElement.appendChild(classElement);
-
- // add additional init params
- if (orgServletClassName.equals(servletClass) == false)
- {
- Element paramElement = DOMUtils.createElement("init-param");
-
paramElement.appendChild(DOMUtils.createElement("param-name")).appendChild(DOMUtils.createTextNode(Endpoint.SEPID_DOMAIN_ENDPOINT));
-
paramElement.appendChild(DOMUtils.createElement("param-value")).appendChild(DOMUtils.createTextNode(orgServletClassName));
- paramElement =
(Element)servletElement.getOwnerDocument().importNode(paramElement, true);
- servletElement.appendChild(paramElement);
- targetBeanName = orgServletClassName;
- }
-
- // reattach the elements
- itDetached = detachedElements.iterator();
- while (itDetached.hasNext())
- {
- Element el = (Element)itDetached.next();
- servletElement.appendChild(el);
- }
- }
-
- if (targetBeanName == null)
- throw new IllegalStateException("Cannot obtain service endpoint bean
for: " + linkName);
-
- // remember the target bean name
- results.sepTargetMap.put(linkName, targetBeanName.trim());
- }
-
- return results;
- }
-
- // Return true if the web.xml is already modified
- private boolean isAlreadyModified(Element servletElement)
- {
- Iterator itParams = DOMUtils.getChildElements(servletElement,
"init-param");
- while (itParams.hasNext())
- {
- Element elParam = (Element)itParams.next();
- Element elParamName = DOMUtils.getFirstChildElement(elParam,
"param-name");
- if
(Endpoint.SEPID_DOMAIN_ENDPOINT.equals(DOMUtils.getTextContent(elParamName)))
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
Added:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/WebAppGeneratorDeployer.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/WebAppGeneratorDeployer.java
(rev 0)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/WebAppGeneratorDeployer.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.deployment;
+
+//$Id$
+
+import org.jboss.ws.core.server.ServiceEndpointGeneratorEJB;
+import org.jboss.ws.integration.deployment.AbstractDeployer;
+import org.jboss.ws.integration.deployment.Deployment;
+import org.jboss.ws.integration.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.metadata.umdm.UnifiedMetaData;
+
+/**
+ * A deployer that generates a webapp for an EJB endpoint
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class WebAppGeneratorDeployer extends AbstractDeployer
+{
+ private ServiceEndpointGeneratorEJB serviceEndpointGenerator;
+
+ @Override
+ public void create(Deployment dep)
+ {
+ UnifiedDeploymentInfo udi =
dep.getContext().getAttachment(UnifiedDeploymentInfo.class);
+ if (udi == null)
+ throw new IllegalStateException("Cannot obtain unified deployement
info");
+
+ UnifiedMetaData umd = dep.getContext().getAttachment(UnifiedMetaData.class);
+ if (umd == null)
+ throw new IllegalStateException("Cannot obtain unified meta data");
+
+ udi.webappURL = serviceEndpointGenerator.generatWebDeployment(umd, udi);
+ }
+}
\ No newline at end of file
Property changes on:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/WebAppGeneratorDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointGeneratorEJB.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointGeneratorEJB.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointGeneratorEJB.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -34,6 +34,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.utils.DOMWriter;
+import org.jboss.ws.integration.deployment.SecurityRolesHandler;
import org.jboss.ws.integration.deployment.UnifiedDeploymentInfo;
import org.jboss.ws.integration.management.ServerConfig;
import org.jboss.ws.integration.management.ServerConfigFactory;
@@ -50,11 +51,13 @@
* @author Thomas.Diesler(a)jboss.org
* @since 12-May-2006
*/
-public abstract class ServiceEndpointGeneratorEJB
+public class ServiceEndpointGeneratorEJB
{
// logging support
protected Logger log = Logger.getLogger(ServiceEndpointGeneratorEJB.class);
+ private SecurityRolesHandler securityRolesHandler;
+
public URL generatWebDeployment(UnifiedMetaData wsMetaData, UnifiedDeploymentInfo
udi)
{
// Collect the list of ServerEndpointMetaData
@@ -117,7 +120,7 @@
Element servlet =
(Element)webApp.appendChild(DOMUtils.createElement("servlet"));
Element servletName =
(Element)servlet.appendChild(DOMUtils.createElement("servlet-name"));
servletName.appendChild(DOMUtils.createTextNode(ejbName));
-
+
Element servletClass =
(Element)servlet.appendChild(DOMUtils.createElement("servlet-class"));
String implName = sepMetaData.getServiceEndpointImplName();
String seiName = sepMetaData.getServiceEndpointInterfaceName();
@@ -147,7 +150,7 @@
}
if (urlPatters.contains(urlPattern))
- throw new IllegalArgumentException("Cannot use the same url-pattern with
different endpoints, " + "check your <port-component-uri> in
jboss.xml");
+ throw new IllegalArgumentException("Cannot use the same url-pattern with
different endpoints, check your <port-component-uri> in jboss.xml");
urlPatternElement.appendChild(DOMUtils.createTextNode(urlPattern));
urlPatters.add(urlPattern);
@@ -220,7 +223,7 @@
Element realm =
(Element)loginConfig.appendChild(DOMUtils.createElement("realm-name"));
realm.appendChild(DOMUtils.createTextNode("EJBServiceEndpointServlet
Realm"));
- addEJBSecurityRoles(webApp, udi);
+ securityRolesHandler.addSecurityRoles(webApp, udi);
}
return webApp;
@@ -300,8 +303,4 @@
return jbossWeb;
}
-
- /** Add the roles from ejb-jar.xml to the security roles
- */
- protected abstract void addEJBSecurityRoles(Element webApp, UnifiedDeploymentInfo
udi);
}
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/IOUtils.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/IOUtils.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/IOUtils.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core.utils;
-
-// $Id$
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-
-import javax.activation.DataHandler;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.WSException;
-import org.jboss.ws.integration.management.ServerConfig;
-import org.jboss.ws.integration.management.ServerConfigFactory;
-
-/**
- * IO utilites
- *
- * @author Thomas.Diesler(a)jboss.org
- */
-public final class IOUtils
-{
- private static Logger log = Logger.getLogger(IOUtils.class);
-
- // Hide the constructor
- private IOUtils()
- {
- }
-
- public static Writer getCharsetFileWriter(File file, String charset) throws
IOException
- {
- return new OutputStreamWriter(new FileOutputStream(file), charset);
- }
-
- /** Copy the input stream to the output stream
- */
- public static void copyStream(OutputStream outs, InputStream ins) throws IOException
- {
- byte[] bytes = new byte[1024];
- int r = ins.read(bytes);
- while (r > 0)
- {
- outs.write(bytes, 0, r);
- r = ins.read(bytes);
- }
- }
-
- /** Copy the reader to the output stream
- */
- public static void copyReader(OutputStream outs, Reader reader) throws IOException
- {
- OutputStreamWriter writer = new OutputStreamWriter(outs);
- char[] bytes = new char[1024];
- int r = reader.read(bytes);
- while (r > 0)
- {
- writer.write(bytes, 0, r);
- r = reader.read(bytes);
- }
- }
-
- public static byte[] convertToBytes(DataHandler dh)
- {
- try
- {
- ByteArrayOutputStream buffOS= new ByteArrayOutputStream();
- dh.writeTo(buffOS);
- return buffOS.toByteArray();
- }
- catch (IOException e)
- {
- throw new WSException("Unable to convert DataHandler to byte[]: " +
e.getMessage());
- }
- }
-
- /**
- * Transform a Reader to an InputStream
- * Background is that DocumentBuilder.parse() cannot take the Reader directly
- */
- public static InputStream transformReader(Reader reader) throws IOException
- {
- int capacity = 1024;
- char[] charBuffer = new char[capacity];
- StringBuffer strBuffer = new StringBuffer(capacity);
-
- int len = reader.read(charBuffer, 0, capacity);
- while (len > 0)
- {
- strBuffer.append(charBuffer, 0, len);
- len = reader.read(charBuffer, 0, capacity);
- }
- return new ByteArrayInputStream(strBuffer.toString().getBytes());
- }
-
- public static File createTempDirectory() throws IOException
- {
- File tmpdir = null;
-
- try
- {
- ServerConfigFactory factory = ServerConfigFactory.getInstance();
- ServerConfig config = factory.getServerConfig();
-
- tmpdir = new File(config.getServerTempDir().getCanonicalPath() +
"/jbossws");
- tmpdir.mkdirs();
- }
- catch (Throwable t)
- {
- // Use the Java temp directory if there is no server config (the client)
- }
-
- return tmpdir;
- }
-}
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/ReceiveUsernameOperation.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/ReceiveUsernameOperation.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/ReceiveUsernameOperation.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -28,6 +28,7 @@
import org.jboss.ws.extensions.security.element.SecurityHeader;
import org.jboss.ws.extensions.security.element.Token;
import org.jboss.ws.extensions.security.element.UsernameToken;
+import org.jboss.ws.integration.invocation.SecurityAssociationAdaptor;
import org.w3c.dom.Document;
public class ReceiveUsernameOperation implements TokenOperation
@@ -44,12 +45,12 @@
public void process(Document message, Token token) throws WSSecurityException
{
UsernameToken user = (UsernameToken)token;
- String propName = SecurityAssociationAdaptorFactory.class.getName();
- SecurityAssociationAdaptorFactory factory =
(SecurityAssociationAdaptorFactory)FactoryLoader.loadFactory(propName, null);
- if (factory == null)
+ String propName = SecurityAssociationAdaptor.class.getName();
+
+ SecurityAssociationAdaptor securityAdaptor =
(SecurityAssociationAdaptor)FactoryLoader.loadFactory(propName, null);
+ if (securityAdaptor == null)
throw new WSSecurityException("Cannot load: " + propName);
- SecurityAssociationAdaptor securityAdaptor =
factory.getSecurityAssociationAdaptor();
securityAdaptor.setPrincipal(new SimplePrincipal(user.getUsername()));
securityAdaptor.setCredential(user.getPassword());
}
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptor.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptor.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptor.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -1,38 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.ws.extensions.security;
-
-// $Id$
-
-import java.security.Principal;
-
-/**
- * A container idependent security adaptor
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 10-May-2005
- */
-public interface SecurityAssociationAdaptor
-{
- void setPrincipal(Principal pricipal);
- void setCredential(Object credential);
-}
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptorFactory.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptorFactory.java 2007-05-14
21:45:21 UTC (rev 3093)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/extensions/security/SecurityAssociationAdaptorFactory.java 2007-05-15
05:10:13 UTC (rev 3094)
@@ -1,36 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.ws.extensions.security;
-
-// $Id$
-
-
-/**
- * A container idependent security adaptor factory
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 10-May-2005
- */
-public interface SecurityAssociationAdaptorFactory
-{
- SecurityAssociationAdaptor getSecurityAssociationAdaptor();
-}