You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2015/07/14 02:25:33 UTC
[6/6] tomee git commit: Re-use the connection for the datasource and
transaction rather than fetch another one only to throw it away later.
Slightly experimental change to prevent the db pool locking up.
Re-use the connection for the datasource and transaction rather than fetch another one only to throw it away later. Slightly experimental change to prevent the db pool locking up.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/bd7dbd0f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/bd7dbd0f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/bd7dbd0f
Branch: refs/heads/tomee-1.7.x
Commit: bd7dbd0f31964df0c3ea421bc2f4aba2f51f8a2e
Parents: fbb34e3
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Tue Jul 14 01:24:18 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Tue Jul 14 01:24:18 2015 +0100
----------------------------------------------------------------------
.../jdbc/managed/local/ManagedConnection.java | 16 +-
.../jdbc/managed/local/ManagedDataSource.java | 28 +-
.../resource/jdbc/ManagedDataSourceTest.java | 4 +-
.../MultiThreadedManagedDataSourceTest.java | 4 +-
.../resource/jdbc/UTManagedDataSourceTest.java | 4 +-
.../maven/plugin/AbstractSynchronizable.java | 142 +-
.../test/resources/schema/ComplexAllElement.xsd | 42 +-
.../test/resources/schema/ComplexAllType.xsd | 42 +-
.../resources/schema/ComplexSequenceElement.xsd | 42 +-
.../resources/schema/ComplexSequenceType.xsd | 42 +-
.../test/resources/schema/JaxRpcSpecExample.xsd | 42 +-
.../src/test/resources/schema/SimpleElement.xsd | 42 +-
.../src/test/resources/schema/SimpleType.xsd | 42 +-
.../resources/schema/SoapArrayByAttribute.xsd | 42 +-
.../resources/schema/SoapArrayByRestriction.xsd | 42 +-
.../apache/openejb/client/ClientSecurity.java | 408 ++---
.../client/DirectConnectionStrategy.java | 66 +-
.../openejb/client/MulticastPulseClient.java | 1556 +++++++++---------
.../apache/openejb/client/ProtocolMetaData.java | 224 +--
.../openejb/server/cxf/rs/AutoJAXRSInvoker.java | 140 +-
.../server/cxf/rs/OpenEJBEJBInvoker.java | 230 +--
.../openejb/server/cxf/rs/PojoInvoker.java | 124 +-
.../rs/DynamicSubclassEjbDeploymentTest.java | 260 +--
.../cxf/rs/EJBAccessExceptionMapperTest.java | 220 +--
.../server/cxf/rs/EjbDeploymentTest.java | 246 +--
.../cxf/rs/PathParamAtClassLevelTest.java | 148 +-
.../server/cxf/WSSPassThroughInterceptor.java | 132 +-
.../server/cxf/ejb/EjbMessageContext.java | 124 +-
.../server/cxf/CxfJaxWsProviderTest.java | 274 +--
.../server/cxf/fault/AuthenticatorService.java | 60 +-
.../cxf/fault/AuthenticatorServiceBean.java | 84 +-
.../AuthenticatorServiceBeanNoHandler.java | 82 +-
.../server/cxf/fault/DummyInterceptor.java | 96 +-
.../cxf/fault/WrongPasswordException.java | 82 +-
.../fault/WrongPasswordRuntimeException.java | 84 +-
.../src/test/resources/META-INF/ejb-jar.xml | 36 +-
.../apache/openejb/server/cxf/fault/handler.xml | 52 +-
.../org/apache/openejb/daemon/NTService.java | 228 +--
.../openejb/server/ejbd/RequestHandler.java | 90 +-
.../server/discovery/MulticastPulseAgent.java | 1520 ++++++++---------
.../multipulse | 6 +-
.../discovery/MulticastPulseAgentTest.java | 1026 ++++++------
.../openejb/server/rest/EJBRestServiceInfo.java | 66 +-
.../server/rest/InternalApplication.java | 90 +-
.../main/resources/META-INF/openejb-server.xml | 72 +-
.../META-INF/org.apache.openejb.cli/stop.help | 28 +-
src/main/style/checkstyle.xml | 330 ++--
.../apache/openejb/tck/util/ServerLocal.java | 100 +-
.../apache-tomee/src/main/resources/service.bat | 452 ++---
.../main/resources/service.install.as.admin.bat | 64 +-
.../main/resources/service.remove.as.admin.bat | 64 +-
tomee/apache-tomee/src/main/resources/tomee.bat | 170 +-
.../org/apache/tomee/catalina/Contexts.java | 296 ++--
.../catalina/ProvisioningWebappLoader.java | 238 +--
.../tomee/catalina/TomcatDeploymentLoader.java | 86 +-
55 files changed, 5122 insertions(+), 5108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
index 25e1727..5a8c4c7 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
@@ -35,13 +35,10 @@ import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
public class ManagedConnection implements InvocationHandler {
private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB_RESOURCE_JDBC, ManagedConnection.class);
- private static final Map<Integer, Map<Transaction, Connection>> CONNECTION_BY_TX_BY_DS = new ConcurrentHashMap<Integer, Map<Transaction, Connection>>();
-
private final TransactionManager transactionManager;
private final LocalXAResource xaResource;
protected Connection delegate;
@@ -55,7 +52,7 @@ public class ManagedConnection implements InvocationHandler {
transactionManager = txMgr;
closed = false;
xaResource = new LocalXAResource(delegate);
- connectionByTx = CONNECTION_BY_TX_BY_DS.get(ds.hashCode());
+ connectionByTx = ManagedConnectionsByTransactionByDatasource.get(ds);
}
public XAResource getXAResource() throws SQLException {
@@ -195,17 +192,6 @@ public class ManagedConnection implements InvocationHandler {
}
}
- public static void pushDataSource(final CommonDataSource ds) {
- CONNECTION_BY_TX_BY_DS.put(ds.hashCode(), new ConcurrentHashMap<Transaction, Connection>());
- }
-
- public static void cleanDataSource(final CommonDataSource ds) {
- final Map<Transaction, Connection> map = CONNECTION_BY_TX_BY_DS.remove(ds.hashCode());
- if (map != null) {
- map.clear();
- }
- }
-
private static class ClosingSynchronization implements Synchronization {
private final Connection connection;
private final Map<Transaction, Connection> mapToCleanup;
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
index 0c074f9..f57b9d8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedDataSource.java
@@ -21,7 +21,10 @@ import org.apache.openejb.util.reflection.Reflections;
import javax.sql.CommonDataSource;
import javax.sql.DataSource;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+
import java.io.PrintWriter;
import java.lang.reflect.Proxy;
import java.sql.Connection;
@@ -40,7 +43,7 @@ public class ManagedDataSource implements DataSource {
delegate = ds;
hashCode = hc;
transactionManager = txMgr;
- ManagedConnection.pushDataSource(this);
+ ManagedConnectionsByTransactionByDatasource.pushDataSource(this);
}
public ManagedDataSource(final DataSource ds, final TransactionManager txMgr) {
@@ -49,7 +52,26 @@ public class ManagedDataSource implements DataSource {
@Override
public Connection getConnection() throws SQLException {
- return managed(delegate.getConnection());
+
+ Transaction transaction = null;
+
+ try {
+ transaction = transactionManager.getTransaction();
+ } catch (final SystemException e) {
+ // ignore
+ }
+
+ Connection connection = null;
+
+ if (transaction != null) {
+ connection = ManagedConnectionsByTransactionByDatasource.get(this, transaction);
+ }
+
+ if (connection == null) {
+ connection = delegate.getConnection();
+ }
+
+ return managed(connection);
}
@Override
@@ -101,7 +123,7 @@ public class ManagedDataSource implements DataSource {
}
public void clean() {
- ManagedConnection.cleanDataSource(this);
+ ManagedConnectionsByTransactionByDatasource.cleanDataSource(this);
}
@Override
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
index e959693..6279f6c 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/ManagedDataSourceTest.java
@@ -20,6 +20,7 @@ import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.SingletonBean;
import org.apache.openejb.junit.ApplicationComposer;
import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
+import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
import org.apache.openejb.testing.Configuration;
import org.apache.openejb.testing.Module;
import org.junit.After;
@@ -36,6 +37,7 @@ import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.sql.DataSource;
import javax.transaction.Transaction;
+
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -200,7 +202,7 @@ public class ManagedDataSourceTest {
@After
public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
- final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+ final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
map.setAccessible(true);
final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
assertEquals(1, instance.size());
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
index 15288fe..f538783 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/MultiThreadedManagedDataSourceTest.java
@@ -20,6 +20,7 @@ import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.SingletonBean;
import org.apache.openejb.junit.ApplicationComposer;
import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
+import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
import org.apache.openejb.testing.Configuration;
import org.apache.openejb.testing.Module;
import org.junit.After;
@@ -34,6 +35,7 @@ import javax.ejb.LocalBean;
import javax.ejb.Singleton;
import javax.sql.DataSource;
import javax.transaction.Transaction;
+
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -194,7 +196,7 @@ public class MultiThreadedManagedDataSourceTest {
@After
public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
- final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+ final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
map.setAccessible(true);
final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
assertEquals(1, instance.size());
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
index 146a5b3..821a761 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/UTManagedDataSourceTest.java
@@ -20,6 +20,7 @@ import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.SingletonBean;
import org.apache.openejb.junit.ApplicationComposer;
import org.apache.openejb.resource.jdbc.managed.local.ManagedConnection;
+import org.apache.openejb.resource.jdbc.managed.local.ManagedConnectionsByTransactionByDatasource;
import org.apache.openejb.testing.Configuration;
import org.apache.openejb.testing.Module;
import org.junit.After;
@@ -36,6 +37,7 @@ import javax.ejb.TransactionManagementType;
import javax.sql.DataSource;
import javax.transaction.Transaction;
import javax.transaction.UserTransaction;
+
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -211,7 +213,7 @@ public class UTManagedDataSourceTest {
@After
public void checkTxMapIsEmpty() throws Exception { // avoid memory leak
- final Field map = ManagedConnection.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
+ final Field map = ManagedConnectionsByTransactionByDatasource.class.getDeclaredField("CONNECTION_BY_TX_BY_DS");
map.setAccessible(true);
final Map<DataSource, Map<Transaction, Connection>> instance = (Map<DataSource, Map<Transaction, Connection>>) map.get(null);
assertEquals(1, instance.size());
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
----------------------------------------------------------------------
diff --git a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
index 488e372..1244882 100644
--- a/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
+++ b/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractSynchronizable.java
@@ -1,71 +1,71 @@
-/**
- *
- * 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.maven.plugin;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractSynchronizable {
- protected int updateInterval;
- protected List<String> extensions;
- protected List<String> updateOnlyExtensions;
- protected String regex;
- protected Map<File, File> updates;
-
- public abstract Map<File, File> updates();
-
- public int getUpdateInterval() {
- return updateInterval;
- }
-
- public void setUpdateInterval(final int updateInterval) {
- this.updateInterval = updateInterval;
- }
-
- public List<String> getExtensions() {
- if (extensions == null) {
- extensions = new ArrayList<String>();
- }
- return extensions;
- }
-
- public void setExtensions(final List<String> extensions) {
- this.extensions = extensions;
- }
-
- public String getRegex() {
- return regex;
- }
-
- public void setRegex(final String regex) {
- this.regex = regex;
- }
-
- public List<String> getUpdateOnlyExtenions() {
- if (updateOnlyExtensions == null) {
- updateOnlyExtensions = new ArrayList<String>();
- }
- return updateOnlyExtensions;
- }
-
- public void setUpdateOnlyExtensions(final List<String> updateOnlyExtensions) {
- this.updateOnlyExtensions = updateOnlyExtensions;
- }
-}
+/**
+ *
+ * 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.maven.plugin;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractSynchronizable {
+ protected int updateInterval;
+ protected List<String> extensions;
+ protected List<String> updateOnlyExtensions;
+ protected String regex;
+ protected Map<File, File> updates;
+
+ public abstract Map<File, File> updates();
+
+ public int getUpdateInterval() {
+ return updateInterval;
+ }
+
+ public void setUpdateInterval(final int updateInterval) {
+ this.updateInterval = updateInterval;
+ }
+
+ public List<String> getExtensions() {
+ if (extensions == null) {
+ extensions = new ArrayList<String>();
+ }
+ return extensions;
+ }
+
+ public void setExtensions(final List<String> extensions) {
+ this.extensions = extensions;
+ }
+
+ public String getRegex() {
+ return regex;
+ }
+
+ public void setRegex(final String regex) {
+ this.regex = regex;
+ }
+
+ public List<String> getUpdateOnlyExtenions() {
+ if (updateOnlyExtensions == null) {
+ updateOnlyExtensions = new ArrayList<String>();
+ }
+ return updateOnlyExtensions;
+ }
+
+ public void setUpdateOnlyExtensions(final List<String> updateOnlyExtensions) {
+ this.updateOnlyExtensions = updateOnlyExtensions;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd b/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
index df9ef21..4821609 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd b/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
index f9dd8b4..9409581 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd b/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
index 36299e3..f59ab72 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd b/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
index 34dbf99..0484e30 100644
--- a/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd b/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
index a1bba13..65eb581 100644
--- a/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
+++ b/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd b/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
index 9d4bd82..3f483e3 100644
--- a/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SimpleType.xsd b/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
index 83339ae..894c3b4 100644
--- a/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd b/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
index 5696c61..1f63eed 100644
--- a/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<xsd:schema
targetNamespace="X"
xmlns:tns="X"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
----------------------------------------------------------------------
diff --git a/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd b/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
index 9b61fcc..ab4c67b 100644
--- a/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
+++ b/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
@@ -1,24 +1,24 @@
-<?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$ $Date$ -->
-
+<?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$ $Date$ -->
+
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="X"
xmlns:tns="X"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
index 1990958..99cacd1 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientSecurity.java
@@ -1,204 +1,204 @@
-/**
- *
- * 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.client;
-
-import javax.security.auth.login.FailedLoginException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.rmi.RemoteException;
-
-public class ClientSecurity {
-
- public static final String IDENTITY_RESOLVER_STRATEGY = "openejb.client.identityResolver";
-
- private static ServerMetaData server;
- private static IdentityResolver identityResolver;
- private static Object staticClientIdentity;
- private static final InheritableThreadLocal<Object> threadClientIdentity = new InheritableThreadLocal<Object>();
-
- static {
- // determine the server uri
- final String serverUri = System.getProperty("openejb.server.uri");
-
- if (serverUri != null) {
- // determine the server location
- try {
- final URI location = new URI(serverUri);
- server = new ServerMetaData(location);
- } catch (final Exception e) {
- if (!serverUri.contains("://")) {
- try {
- final URI location = new URI("oejb://" + serverUri);
- server = new ServerMetaData(location);
- } catch (final URISyntaxException ignored) {
- }
- }
- }
- }
- }
-
- public static ServerMetaData getServer() {
- return server;
- }
-
- public static void setServer(final ServerMetaData server) {
- ClientSecurity.server = server;
- }
-
- /**
- * Login the spedified user using the specified password. This is a global login for the
- * entire Java Virtural Machine. If you would like to have a thread scoped login, use
- * ClientSecurity.login(username, password, true);
- * </p>
- * This is the equivalent of ClientSecurity.login(username, password, false);
- *
- * @param username the user to login
- * @param password the password for the user
- * @throws FailedLoginException if the username and password combination are not valid or
- * if there is a problem communiating with the server
- */
- public static void login(final String username, final String password) throws FailedLoginException {
- login(username, password, false);
- }
-
- /**
- * Login the spedified user using the specified password either globally for the
- * entire Java Virtural Machine or scoped to the thread.
- * </p>
- * When using thread scoped login, you should logout in a finally block. This particularly
- * when using thread pools. If a thread is returned to the pool with a login attached to the
- * thread the next user of that thread will inherit the thread scoped login.
- *
- * @param username the user to login
- * @param password the password for the user
- * @param threadScoped if true the login is scoped to the thread; otherwise the login is global
- * for the entire Java Virtural Machine
- * @throws FailedLoginException if the username and password combination are not valid or
- * if there is a problem communiating with the server
- */
- public static void login(final String username, final String password, final boolean threadScoped) throws FailedLoginException {
- final Object clientIdentity = directAuthentication(username, password, server);
- if (threadScoped) {
- threadClientIdentity.set(clientIdentity);
- } else {
- staticClientIdentity = clientIdentity;
- }
- identityResolver = new SimpleIdentityResolver();
- }
-
- /**
- * Clears the thread and global login data.
- */
- public static void logout() {
- threadClientIdentity.set(null);
- staticClientIdentity = null;
- }
-
- /**
- * This is a helper method for login modules. Directly authenticates with the server using the specified
- * username and password returning the identity token for the client. This methods does not store the
- * identity token and the caller must arrange for the to be available to the OpenEJB proxies via an
- * IdentityResolver.
- *
- * @param username the username for authentication
- * @param password the password for authentication
- * @param server ServerMetaData
- * @return the client identity token
- * @throws FailedLoginException if the username password combination is not valid
- */
- public static Object directAuthentication(final String username, final String password, final ServerMetaData server) throws FailedLoginException {
- return directAuthentication(null, username, password, server);
- }
-
- public static Object directAuthentication(final String securityRealm, final String username, final String password, final ServerMetaData server) throws FailedLoginException {
- // authenticate
- final AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password);
- final AuthenticationResponse authRes;
- try {
- authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server);
- } catch (final RemoteException e) {
- throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e);
- }
-
- // check the response
- if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) {
- throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause());
- }
-
- // return the response object
- return authRes.getIdentity().getClientIdentity();
- }
-
- public static Object getIdentity() {
- return getIdentityResolver().getIdentity();
- }
-
- public static IdentityResolver getIdentityResolver() {
- if (identityResolver == null) {
- final String strategy = System.getProperty(IDENTITY_RESOLVER_STRATEGY);
- if (strategy == null) {
- identityResolver = new JaasIdentityResolver();
- } else {
- // find the strategy class
- final ResourceFinder finder = new ResourceFinder("META-INF/");
- final Class identityResolverClass;
- try {
- identityResolverClass = finder.findClass(IdentityResolver.class.getName() + "/" + strategy);
- } catch (final Exception e) {
- throw new IllegalArgumentException("Could not find client identity strategy '" + strategy + "'");
- }
-
- // verify the interface
- if (!IdentityResolver.class.isAssignableFrom(identityResolverClass)) {
- throw new IllegalArgumentException("Client identity strategy '" + strategy + "' " +
- "class '" + identityResolverClass.getName() + "' does not implement the " +
- "interface '" + IdentityResolver.class.getSimpleName() + "'");
- }
-
- // create the class
- try {
- identityResolver = (IdentityResolver) identityResolverClass.newInstance();
- } catch (final Exception e) {
- throw new IllegalArgumentException("Unable to create client identity strategy '" + strategy + "' " +
- "class '" + identityResolverClass.getName() + "'", e);
- }
- }
-
- }
- return identityResolver;
- }
-
- public static void setIdentityResolver(final IdentityResolver identityResolver) {
- ClientSecurity.identityResolver = identityResolver;
- }
-
- private ClientSecurity() {
- }
-
- public static class SimpleIdentityResolver implements IdentityResolver {
-
- @Override
- public Object getIdentity() {
- Object clientIdentity = threadClientIdentity.get();
- if (clientIdentity == null) {
- clientIdentity = staticClientIdentity;
- }
- return clientIdentity;
- }
- }
-}
+/**
+ *
+ * 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.client;
+
+import javax.security.auth.login.FailedLoginException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.rmi.RemoteException;
+
+public class ClientSecurity {
+
+ public static final String IDENTITY_RESOLVER_STRATEGY = "openejb.client.identityResolver";
+
+ private static ServerMetaData server;
+ private static IdentityResolver identityResolver;
+ private static Object staticClientIdentity;
+ private static final InheritableThreadLocal<Object> threadClientIdentity = new InheritableThreadLocal<Object>();
+
+ static {
+ // determine the server uri
+ final String serverUri = System.getProperty("openejb.server.uri");
+
+ if (serverUri != null) {
+ // determine the server location
+ try {
+ final URI location = new URI(serverUri);
+ server = new ServerMetaData(location);
+ } catch (final Exception e) {
+ if (!serverUri.contains("://")) {
+ try {
+ final URI location = new URI("oejb://" + serverUri);
+ server = new ServerMetaData(location);
+ } catch (final URISyntaxException ignored) {
+ }
+ }
+ }
+ }
+ }
+
+ public static ServerMetaData getServer() {
+ return server;
+ }
+
+ public static void setServer(final ServerMetaData server) {
+ ClientSecurity.server = server;
+ }
+
+ /**
+ * Login the spedified user using the specified password. This is a global login for the
+ * entire Java Virtural Machine. If you would like to have a thread scoped login, use
+ * ClientSecurity.login(username, password, true);
+ * </p>
+ * This is the equivalent of ClientSecurity.login(username, password, false);
+ *
+ * @param username the user to login
+ * @param password the password for the user
+ * @throws FailedLoginException if the username and password combination are not valid or
+ * if there is a problem communiating with the server
+ */
+ public static void login(final String username, final String password) throws FailedLoginException {
+ login(username, password, false);
+ }
+
+ /**
+ * Login the spedified user using the specified password either globally for the
+ * entire Java Virtural Machine or scoped to the thread.
+ * </p>
+ * When using thread scoped login, you should logout in a finally block. This particularly
+ * when using thread pools. If a thread is returned to the pool with a login attached to the
+ * thread the next user of that thread will inherit the thread scoped login.
+ *
+ * @param username the user to login
+ * @param password the password for the user
+ * @param threadScoped if true the login is scoped to the thread; otherwise the login is global
+ * for the entire Java Virtural Machine
+ * @throws FailedLoginException if the username and password combination are not valid or
+ * if there is a problem communiating with the server
+ */
+ public static void login(final String username, final String password, final boolean threadScoped) throws FailedLoginException {
+ final Object clientIdentity = directAuthentication(username, password, server);
+ if (threadScoped) {
+ threadClientIdentity.set(clientIdentity);
+ } else {
+ staticClientIdentity = clientIdentity;
+ }
+ identityResolver = new SimpleIdentityResolver();
+ }
+
+ /**
+ * Clears the thread and global login data.
+ */
+ public static void logout() {
+ threadClientIdentity.set(null);
+ staticClientIdentity = null;
+ }
+
+ /**
+ * This is a helper method for login modules. Directly authenticates with the server using the specified
+ * username and password returning the identity token for the client. This methods does not store the
+ * identity token and the caller must arrange for the to be available to the OpenEJB proxies via an
+ * IdentityResolver.
+ *
+ * @param username the username for authentication
+ * @param password the password for authentication
+ * @param server ServerMetaData
+ * @return the client identity token
+ * @throws FailedLoginException if the username password combination is not valid
+ */
+ public static Object directAuthentication(final String username, final String password, final ServerMetaData server) throws FailedLoginException {
+ return directAuthentication(null, username, password, server);
+ }
+
+ public static Object directAuthentication(final String securityRealm, final String username, final String password, final ServerMetaData server) throws FailedLoginException {
+ // authenticate
+ final AuthenticationRequest authReq = new AuthenticationRequest(securityRealm, username, password);
+ final AuthenticationResponse authRes;
+ try {
+ authRes = (AuthenticationResponse) Client.request(authReq, new AuthenticationResponse(), server);
+ } catch (final RemoteException e) {
+ throw (FailedLoginException) new FailedLoginException("Unable to authenticate with server " + server).initCause(e);
+ }
+
+ // check the response
+ if (authRes.getResponseCode() != ResponseCodes.AUTH_GRANTED) {
+ throw (FailedLoginException) new FailedLoginException("This principal is not authenticated.").initCause(authRes.getDeniedCause());
+ }
+
+ // return the response object
+ return authRes.getIdentity().getClientIdentity();
+ }
+
+ public static Object getIdentity() {
+ return getIdentityResolver().getIdentity();
+ }
+
+ public static IdentityResolver getIdentityResolver() {
+ if (identityResolver == null) {
+ final String strategy = System.getProperty(IDENTITY_RESOLVER_STRATEGY);
+ if (strategy == null) {
+ identityResolver = new JaasIdentityResolver();
+ } else {
+ // find the strategy class
+ final ResourceFinder finder = new ResourceFinder("META-INF/");
+ final Class identityResolverClass;
+ try {
+ identityResolverClass = finder.findClass(IdentityResolver.class.getName() + "/" + strategy);
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("Could not find client identity strategy '" + strategy + "'");
+ }
+
+ // verify the interface
+ if (!IdentityResolver.class.isAssignableFrom(identityResolverClass)) {
+ throw new IllegalArgumentException("Client identity strategy '" + strategy + "' " +
+ "class '" + identityResolverClass.getName() + "' does not implement the " +
+ "interface '" + IdentityResolver.class.getSimpleName() + "'");
+ }
+
+ // create the class
+ try {
+ identityResolver = (IdentityResolver) identityResolverClass.newInstance();
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("Unable to create client identity strategy '" + strategy + "' " +
+ "class '" + identityResolverClass.getName() + "'", e);
+ }
+ }
+
+ }
+ return identityResolver;
+ }
+
+ public static void setIdentityResolver(final IdentityResolver identityResolver) {
+ ClientSecurity.identityResolver = identityResolver;
+ }
+
+ private ClientSecurity() {
+ }
+
+ public static class SimpleIdentityResolver implements IdentityResolver {
+
+ @Override
+ public Object getIdentity() {
+ Object clientIdentity = threadClientIdentity.get();
+ if (clientIdentity == null) {
+ clientIdentity = staticClientIdentity;
+ }
+ return clientIdentity;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java b/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
index 56d2623..c066c9f 100755
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/DirectConnectionStrategy.java
@@ -1,33 +1,33 @@
-/*
- * 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.client;
-
-import java.io.IOException;
-
-public class DirectConnectionStrategy implements ConnectionStrategy {
-
- @Override
- public Connection connect(final ClusterMetaData cluster, final ServerMetaData server) throws IOException {
- final Connection connection = ConnectionManager.getConnection(server.getLocation());
-
- // Grabbing the URI from the associated connection allows the ConnectionFactory to
- // employ discovery to find and connect to a server. We then attempt to connect
- // to the discovered server rather than repeat the discovery process again.
- cluster.setLastLocation(connection.getURI());
- return connection;
- }
-}
+/*
+ * 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.client;
+
+import java.io.IOException;
+
+public class DirectConnectionStrategy implements ConnectionStrategy {
+
+ @Override
+ public Connection connect(final ClusterMetaData cluster, final ServerMetaData server) throws IOException {
+ final Connection connection = ConnectionManager.getConnection(server.getLocation());
+
+ // Grabbing the URI from the associated connection allows the ConnectionFactory to
+ // employ discovery to find and connect to a server. We then attempt to connect
+ // to the discovered server rather than repeat the discovery process again.
+ cluster.setLastLocation(connection.getURI());
+ return connection;
+ }
+}