Author: rareddy
Date: 2010-01-29 15:42:18 -0500 (Fri, 29 Jan 2010)
New Revision: 1787
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
Modified:
branches/JCA/build/assembly/adminshell/adminshell-dependencies.xml
branches/JCA/build/kit-adminshell/connection.properties
branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/JCA/jboss-integration/pom.xml
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/pom.xml
branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-944: TEIID-910: adding a separate socket based connection provision for the Admin;
users can make a socket based connection and access the admin api, this also solves the
remoting dependency issue from profile service
Modified: branches/JCA/build/assembly/adminshell/adminshell-dependencies.xml
===================================================================
--- branches/JCA/build/assembly/adminshell/adminshell-dependencies.xml 2010-01-29 20:39:07
UTC (rev 1786)
+++ branches/JCA/build/assembly/adminshell/adminshell-dependencies.xml 2010-01-29 20:42:18
UTC (rev 1787)
@@ -28,11 +28,6 @@
<unpack>false</unpack>
<useTransitiveDependencies>true</useTransitiveDependencies>
<useDefaultExcludes>true</useDefaultExcludes>
- <excludes>
- <exclude>org.jboss.teiid:teiid-client</exclude>
- <exclude>org.jboss.teiid:teiid-client-jdbc</exclude>
- <exclude>org.jboss.teiid:teiid-common-core</exclude>
- </excludes>
</dependencySet>
</dependencySets>
Modified: branches/JCA/build/kit-adminshell/connection.properties
===================================================================
--- branches/JCA/build/kit-adminshell/connection.properties 2010-01-29 20:39:07 UTC (rev
1786)
+++ branches/JCA/build/kit-adminshell/connection.properties 2010-01-29 20:42:18 UTC (rev
1787)
@@ -1,4 +1,7 @@
-user=admin
-password=teiid
+jdbc.user=admin
+jdbc.password=teiid
jdbc.url=jdbc:teiid:admin@mm://localhost:31000;
-admin.url=mm://localhost:31000
\ No newline at end of file
+
+admin.url=mm://localhost:31443
+admin.user=admin
+admin.password=admin
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2010-01-29
20:42:18 UTC (rev 1787)
@@ -37,6 +37,7 @@
<property name="VDBRepository"><inject
bean="VDBRepository"/></property>
<!-- Comma separated list of domains to be used -->
<property name="securityDomains">teiid-security</property>
+ <property
name="adminSecurityDomain">jmx-console</property>
<property name="sessionMaxLimit">5000</property>
<property name="sessionExpirationTimeLimit">0</property>
</bean>
@@ -54,10 +55,11 @@
<bean name="RuntimeEngineDeployer"
class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
<property name="containerHelper"><inject
bean="ContainerHelper"/></property>
- <property name="socketConfiguration"><inject
bean="SocketConfiguration"/></property>
+ <property name="jdbcSocketConfiguration"><inject
bean="JdbcSocketConfiguration"/></property>
+ <property name="adminSocketConfiguration"><inject
bean="AdminSocketConfiguration"/></property>
</bean>
- <bean name="SocketConfiguration"
class="org.teiid.transport.SocketConfiguration">
+ <bean name="JdbcSocketConfiguration"
class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
<property name="bindAddress">localhost</property>
<property name="portNumber">31000</property>
@@ -67,10 +69,10 @@
<property name="inputBufferSize">0</property>
<!-- SO_SNDBUF size, 0 indicates that system default should be used (default
0) -->
<property name="outputBufferSize">0</property>
- <property name="SSLConfiguration"><inject
bean="SSLConfiguration"/></property>
+ <property name="SSLConfiguration"><inject
bean="JdbcSslConfiguration"/></property>
</bean>
- <bean name="SSLConfiguration"
class="org.teiid.transport.SSLConfiguration">
+ <bean name="JdbcSslConfiguration"
class="org.teiid.transport.SSLConfiguration">
<property name="sslEnabled">false</property>
<property name="keystoreFilename">cert.keystore</property>
<property name="keystorePassword">passwd</property>
@@ -83,6 +85,33 @@
<property name="authenticationMode">1-way</property>
<property name="clientEncryptionEnabled">true</property>
</bean>
+
+ <bean name="AdminSocketConfiguration"
class="org.teiid.transport.SocketConfiguration">
+ <property name="enabled">true</property>
+ <property name="bindAddress">localhost</property>
+ <property name="portNumber">31443</property>
+ <!-- Max number of threads dedicated to Admin and initial request processing
(default 15) -->
+ <property name="maxSocketThreads">4</property>
+ <!-- SO_RCVBUF size, 0 indicates that system default should be used (default
0) -->
+ <property name="inputBufferSize">0</property>
+ <!-- SO_SNDBUF size, 0 indicates that system default should be used (default
0) -->
+ <property name="outputBufferSize">0</property>
+ <property name="SSLConfiguration"><inject
bean="AdminSslConfiguration"/></property>
+ </bean>
+
+ <bean name="AdminSslConfiguration"
class="org.teiid.transport.SSLConfiguration">
+ <property name="sslEnabled">false</property>
+ <property name="keystoreFilename">cert.keystore</property>
+ <property name="keystorePassword">passwd</property>
+ <property name="keystoreType">JKS</property>
+ <property name="sslProtocol">SSLv3</property>
+ <property name="keymanagementAlgorithm">false</property>
+ <property
name="truststoreFilename">cert.truststore</property>
+ <property name="truststorePassword">passwd</property>
+ <!-- 1-way, 2-way, anonymous -->
+ <property name="authenticationMode">anonymous</property>
+ <property name="clientEncryptionEnabled">true</property>
+ </bean>
<!-- teiid's default security domain, replace this with your own if needs to
be any other JAAS domain -->
<application-policy xmlns="urn:jboss:security-beans:1.0"
name="teiid-security">
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -76,6 +76,8 @@
public static final String USER_NAME = "user"; //$NON-NLS-1$
// constant for password part of url
public static final String PASSWORD = "password"; //$NON-NLS-1$
+
+ public static final String ADMIN = "admin"; //$NON-NLS-1$
}
public static final String DOT_DELIMITER = "."; //$NON-NLS-1$
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2010-01-29 20:39:07
UTC (rev 1786)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2010-01-29 20:42:18
UTC (rev 1787)
@@ -22,6 +22,7 @@
package org.teiid.adminapi;
+import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.Properties;
@@ -81,6 +82,15 @@
* if there's a system error.
*/
void deleteConnectorType(String name) throws AdminException;
+
+ /**
+ * Export Connector Type rar file
+ *
+ * @param @param name of the Connector Type
+ * @return InputStream of contents of the rar file
+ * @throws AdminException if there's a system error.
+ */
+ InputStream exportConnectorType(String name) throws AdminException;
/**
* Deploy a {@link ConnectorBinding} to Configuration
@@ -100,6 +110,16 @@
* @throws AdminException if there's a system error.
*/
void deleteConnectorBinding(String deployedName) throws AdminException;
+
+ /**
+ * Export a {@link ConnectorBinding} to character Array in XML format
+ *
+ * @param deployedName the unique identifier for a {@link ConnectorBinding}.
+ * @return character Array in XML format
+ * @throws AdminException
+ * if there's a system error.
+ */
+ InputStream exportConnectorBinding(String deployedName) throws AdminException;
/**
* Deploy a {@link VDB} file.
@@ -121,24 +141,16 @@
void deleteVDB(String vdbName, int vdbVersion) throws AdminException;
/**
- * Add User Defined Function model to the system. If one is already deployed before
this
- * will replace the previous, otherwise add this as the new UDF model. Once the UDF
is added
- * the new UDF model is loaded.
- * @param modelFileContents - UDF contents
- * @param classpath - classpath for the UDF
- * @throws AdminException
+ * Export VDB to byte array
+ *
+ * @param vdbName identifier of the {@link VDB}
+ * @param vdbVersion {@link VDB} version
+ * @return InputStream of the VDB
+ * @throws AdminException if there's a system error.
*/
- void addUDF(byte[] modelFileContents, String classpath) throws AdminException;
+ InputStream exportVDB(String vdbName, int vdbVersion) throws AdminException;
/**
- * Delete the User Defined Function model. Note that this will not delete any
supporting
- * extension jar files added, those need to be deleted separately.
- * @throws AdminException
- */
- void deleteUDF() throws AdminException;
-
-
- /**
* Set a process level property.
* @param propertyName - name of the property
* @param propertyValue - value of the property
@@ -317,19 +329,8 @@
* @throws AdminException if there's a system error.
*/
void cancelRequest(long sessionId, long requestId) throws AdminException;
-
+
/**
- * Change the status of a Deployed VDB
- *
- * @param name Name of the Virtual Database
- * @param version Version of the Virtual Database
- * @param status Active, InActive, Delete
- * @throws AdminException if there's a system error.
- */
- public void changeVDBStatus(String name, String version, int status)
- throws AdminException;
-
- /**
* Mark the given global transaction as rollback only.
* @param transactionId
* @throws AdminException
@@ -371,4 +372,9 @@
* @throws AdminException
*/
Collection<PropertyDefinition> getDataSourcePropertyDefinitions() throws
AdminException;
+
+ /**
+ * Closes the admin connection
+ */
+ void close();
}
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java
(rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminapi;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+
+import com.metamatrix.admin.AdminPlugin;
+import com.metamatrix.api.exception.security.LogonException;
+import com.metamatrix.client.ExceptionUtil;
+import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.comm.platform.CommPlatformPlugin;
+import com.metamatrix.common.comm.platform.socket.client.SocketServerConnectionFactory;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+/**
+ * Singleton factory for ServerAdmins.
+ * @since 4.3
+ */
+public class AdminFactory {
+
+ private static final int DEFAULT_BOUNCE_WAIT = 2000;
+
+ private final class ReconnectingProxy implements InvocationHandler {
+
+ private Admin target;
+ private ServerConnection registry;
+ private Properties p;
+ private boolean closed;
+
+ public ReconnectingProxy(Properties p) throws ConnectionException,
CommunicationException {
+ this.p = p;
+ this.registry = serverConnectionFactory.getConnection(p);
+ this.target = registry.getService(Admin.class);
+ }
+
+ private synchronized Admin getTarget() throws AdminComponentException,
CommunicationException {
+ if (closed) {
+ throw new
AdminComponentException(CommPlatformPlugin.Util.getString("ERR.014.001.0001"));
//$NON-NLS-1$
+ }
+ if (target != null && registry.isOpen()) {
+ return target;
+ }
+ try {
+ registry = serverConnectionFactory.getConnection(p);
+ } catch (ConnectionException e) {
+ throw new AdminComponentException(e.getMessage());
+ }
+ target = registry.getService(Admin.class);
+ return target;
+ }
+
+ //## JDBC4.0-begin ##
+ @Override
+ //## JDBC4.0-end ##
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ if (method.getName().equals("close")) { //$NON-NLS-1$
+ close();
+ return null;
+ }
+ Throwable t = null;
+ for (int i = 0; i < 3; i++) {
+ try {
+ return method.invoke(getTarget(), args);
+ } catch (InvocationTargetException e) {
+ if (ExceptionUtil.getExceptionOfType(e, CommunicationException.class) != null) {
+ // communication exception occurred, lose the old connection and try again.
+ this.target = null;
+ if (method.getName().endsWith("restart")) { //$NON-NLS-1$
+ bounceSystem(true);
+ return null;
+ }
+ continue;
+ }
+ throw e.getTargetException();
+ } catch (CommunicationException e) {
+ t = e;
+ }
+ }
+ throw t;
+ }
+
+ public synchronized void close() {
+ if (closed) {
+ return;
+ }
+ this.closed = true;
+ if (registry != null) {
+ registry.close();
+ }
+ }
+
+ public void bounceSystem(boolean waitUntilDone) {
+ if (!waitUntilDone) {
+ return;
+ }
+ //we'll wait 2 seconds for the server to come up
+ try {
+ Thread.sleep(bounceWait);
+ } catch (InterruptedException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+
+ //we'll wait 30 seconds for the server to come back up
+ for (int i = 0; i < 15; i++) {
+ try {
+ getTarget().getProcesses(AdminObject.WILDCARD);
+ return;
+ } catch (Exception e) {
+ //reestablish a connection and retry
+ try {
+ Thread.sleep(bounceWait);
+ } catch (InterruptedException ex) {
+ throw new MetaMatrixRuntimeException(ex);
+ }
+ }
+ }
+ }
+ }
+
+ public static final String DEFAULT_APPLICATION_NAME = "Admin"; //$NON-NLS-1$
+
+ /**Singleton instance*/
+ private static AdminFactory instance = new
AdminFactory(SocketServerConnectionFactory.getInstance(), DEFAULT_BOUNCE_WAIT);
+
+ private ServerConnectionFactory serverConnectionFactory;
+ private int bounceWait;
+
+ AdminFactory(ServerConnectionFactory connFactory, int bounceWait) {
+ this.serverConnectionFactory = connFactory;
+ this.bounceWait = bounceWait;
+ }
+
+ /**Get the singleton instance*/
+ public static AdminFactory getInstance() {
+ return instance;
+ }
+
+
+ /**
+ * Creates a ServerAdmin with the specified connection properties.
+ * Uses the DEFAULT_APPLICATION_NAME as the application name.
+ * @param userName
+ * @param password
+ * @param serverURL
+ * @return
+ * @throws LogonException
+ * @throws AdminException
+ * @throws CommunicationException
+ * @throws LogonException
+ * @since 4.3
+ */
+ public Admin createAdmin(String userName,
+ char[] password,
+ String serverURL) throws AdminException {
+
+ return createAdmin(userName, password, serverURL, DEFAULT_APPLICATION_NAME);
+
+ }
+
+ /**
+ * Creates a ServerAdmin with the specified connection properties.
+ * @param userName
+ * @param password
+ * @param serverURL
+ * @return
+ * @throws LogonException
+ * @throws AdminException
+ * @throws CommunicationException
+ * @throws LogonException
+ * @since 4.3
+ */
+ public Admin createAdmin(String userName,
+ char[] password,
+ String serverURL,
+ String applicationName) throws AdminException {
+
+ if (userName == null || userName.trim().length() == 0) {
+ throw new
IllegalArgumentException(AdminPlugin.Util.getString("ERR.014.001.0099"));
//$NON-NLS-1$
+ }
+
+ final Properties p = new Properties();
+ p.setProperty(MMURL.CONNECTION.APP_NAME, applicationName);
+ p.setProperty(MMURL.CONNECTION.USER_NAME, userName);
+ if (password != null) {
+ p.setProperty(MMURL.CONNECTION.PASSWORD, new String(password));
+ }
+ p.setProperty(MMURL.CONNECTION.SERVER_URL, serverURL);
+ return createAdmin(p);
+ }
+
+ public Admin createAdmin(Properties p) throws AdminException {
+ p = PropertiesUtils.clone(p);
+ p.remove(MMURL.JDBC.VDB_NAME);
+ p.remove(MMURL.JDBC.VDB_VERSION);
+ p.setProperty(MMURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
+ p.setProperty(MMURL.CONNECTION.ADMIN, Boolean.TRUE.toString());
+
+ try {
+ Admin serverAdmin = (Admin)Proxy.newProxyInstance(this.getClass().getClassLoader(),
new Class[] { Admin.class }, new ReconnectingProxy(p));
+ return serverAdmin;
+ } catch (ConnectionException e) {
+ throw new AdminComponentException(e.getMessage());
+ } catch (CommunicationException e) {
+ throw new AdminComponentException(e.getMessage());
+ }
+ }
+
+}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -29,13 +29,6 @@
public abstract class TeiidAdmin implements Admin, Serializable {
@Override
- public void addUDF(byte[] modelFileContents, String classpath)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
public void assignBindingToModel(String connectorBindingName,
String vdbName, String vdbVersion, String modelName)
throws AdminException {
@@ -51,20 +44,8 @@
}
- @Override
- public void deleteUDF() throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
@Override
- public void changeVDBStatus(String name, String version, int status)
- throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
public Collection<ProcessObject> getProcesses(String processIdentifier) throws
AdminException {
ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
//list.add(manager.getProcess());
Modified:
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
===================================================================
---
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -67,7 +67,7 @@
public SessionMetadata createSession(String userName,
Credentials credentials,
String applicationName,
- Properties properties)
+ Properties properties, boolean admin)
throws LoginException, SessionServiceException;
/**
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -63,6 +63,7 @@
private String securityDomain;
private Object securityContext;
private VDBMetaData vdb;
+ private boolean admin;
public DQPWorkContext() {
}
@@ -195,4 +196,12 @@
public VDBMetaData getVDB() {
return vdb;
}
+
+ public void markAsAdmin() {
+ this.admin = true;
+ }
+
+ public boolean isAdmin() {
+ return this.admin;
+ }
}
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2010-01-29 20:39:07 UTC (rev 1786)
+++ branches/JCA/jboss-integration/pom.xml 2010-01-29 20:42:18 UTC (rev 1787)
@@ -49,14 +49,17 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-engine</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-runtime</artifactId>
+ <artifactId>teiid-runtime</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -91,18 +94,12 @@
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-jboss-embedded</artifactId>
- <scope>test</scope>
- </dependency>
-
<!-- these for just running profile service remotely -->
<dependency>
<groupId>org.jboss.naming</groupId>
<artifactId>jnp-client</artifactId>
<version>5.0.3.GA</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
@@ -110,43 +107,50 @@
<artifactId>jboss-aop</artifactId>
<classifier>client</classifier>
<version>2.1.1.GA</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
<version>2.5.1</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.aspects</groupId>
<artifactId>jboss-security-aspects</artifactId>
<version>1.0.0.GA</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.aspects</groupId>
<artifactId>jboss-remoting-aspects</artifactId>
<version>1.0.1.GA</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>oswego-concurrent</groupId>
<artifactId>concurrent</artifactId>
<version>1.3.4-jboss-update1</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-server</artifactId>
<version>5.1.0.GA</version>
- <scope>runtime</scope>
+ <scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-profileservice</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
Modified:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -26,6 +26,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,7 +55,7 @@
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.virtual.VFS;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
@@ -77,7 +79,6 @@
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.TransactionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.dqp.internal.process.DQPManagementView;
import com.metamatrix.core.CoreConstants;
@@ -94,16 +95,20 @@
private static ComponentType TXTYPE = new ComponentType("ConnectionFactory",
"Tx");
private static ComponentType DQPTYPE = new ComponentType("teiid",
"dqp");
private static ComponentType DSTYPE = new ComponentType("DataSource",
"XA");
+ private static String DQPNAME =
"org.teiid.dqp.internal.process.DQPManagementView";
-
private ManagementView view;
private DeploymentManager deploymentMgr;
- public Admin(ProfileService ps) {
- this.view = ps.getViewManager();
+ static {
+ VFS.init();
+ }
+
+ public Admin(ManagementView view, DeploymentManager deployMgr) {
+ this.view = view;
this.view.load();
- this.deploymentMgr = ps.getDeploymentManager();
+ this.deploymentMgr = deployMgr;
try {
this.deploymentMgr.loadProfile(DEFAULT_PROFILE_KEY);
} catch (Exception e) {
@@ -111,15 +116,26 @@
}
}
- private ManagementView getView() {
+ private ManagementView getView() throws AdminProcessingException {
+ if (this.view == null) {
+ throw new AdminProcessingException("The admin connection is already
closed");
+ }
this.view.load();
return this.view;
}
- private DeploymentManager getDeploymentManager() {
+ private DeploymentManager getDeploymentManager() throws AdminProcessingException{
+ if (this.deploymentMgr == null) {
+ throw new AdminProcessingException("The admin connection is already
closed");
+ }
return this.deploymentMgr;
}
+ public void close() {
+ this.view = null;
+ this.deploymentMgr = null;
+ }
+
// private DQPManagement getDQPManagement() throws Exception {
// final ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
//
@@ -153,6 +169,26 @@
}
return null;
}
+
+ @Override
+ public InputStream exportConnectorBinding(String deployedName) throws AdminException {
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc != null) {
+ return exportDeployment(mc.getDeployment().getName());
+ }
+ return null;
+ }
+
+ private InputStream exportDeployment(String url) throws AdminComponentException {
+ try {
+ URL contentURL = new URL(url);
+ return contentURL.openStream();
+ } catch (MalformedURLException e) {
+ throw new AdminComponentException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
private ManagedComponent getConnectorBindingComponent(String deployedName) throws
AdminProcessingException {
try {
@@ -361,6 +397,15 @@
}
@Override
+ public InputStream exportVDB(String vdbName, int vdbVersion) throws AdminException{
+ ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+ if (mc != null) {
+ return exportDeployment(mc.getDeployment().getName());
+ }
+ return null;
+ }
+
+ @Override
public VDB getVDB(String vdbName, int vdbVersion) throws AdminException{
ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
if (mc != null) {
@@ -445,7 +490,7 @@
public Collection<Session> getSessions() throws AdminException {
try {
Collection<Session> sessionList = new ArrayList<Session>();
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc, "getActiveSessions");
MetaValue[] sessions = ((CollectionValueSupport)value).getElements();
for (MetaValue mv:sessions) {
@@ -460,7 +505,7 @@
@Override
public void terminateSession(long sessionId) throws AdminException {
try {
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "terminateSession",
SimpleValueSupport.wrap(sessionId));
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
@@ -471,7 +516,7 @@
public Collection<Request> getRequests() throws AdminException {
try {
Collection<Request> requestList = new ArrayList<Request>();
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc, "getRequests");
MetaValue[] requests = ((CollectionValueSupport)value).getElements();
for (MetaValue mv:requests) {
@@ -487,7 +532,7 @@
public Collection<Request> getRequestsForSession(long sessionId) throws
AdminException {
try {
Collection<Request> requestList = new ArrayList<Request>();
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc, "getRequestsForSession",
SimpleValueSupport.wrap(sessionId));
MetaValue[] requests = ((CollectionValueSupport)value).getElements();
for (MetaValue mv:requests) {
@@ -502,7 +547,7 @@
@Override
public void cancelRequest(long sessionId, long requestId) throws AdminException{
try {
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "cancelRequest",
SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(requestId));
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
@@ -567,6 +612,18 @@
}
@Override
+ public InputStream exportConnectorType(String connectorName) throws AdminException {
+ if (!connectorName.endsWith(".rar")) {
+ connectorName = connectorName + ".rar";
+ }
+ String deployerName = getRarDeployerName(connectorName);
+ if (deployerName != null) {
+ return exportDeployment(deployerName);
+ }
+ return null;
+ }
+
+ @Override
public void restart() throws AdminException {
ConnectorBinding binding = getConnectorBinding(TEIID_RUNTIME_ENGINE);
stopConnectorBinding(binding);
@@ -584,7 +641,7 @@
public Collection<String> getCacheTypes() throws AdminException {
try {
Collection<String> requestList = new ArrayList<String>();
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc, "getCacheTypes");
MetaValue[] requests = ((CollectionValueSupport)value).getElements();
for (MetaValue mv:requests) {
@@ -599,7 +656,7 @@
@Override
public void clearCache(String cacheType) throws AdminException{
try {
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "clearCache",
SimpleValueSupport.wrap(cacheType));
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
@@ -610,7 +667,7 @@
public Collection<Transaction> getTransactions() throws AdminException {
try {
Collection<Transaction> txnList = new ArrayList<Transaction>();
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc, "getTransactions");
MetaValue[] requests = ((CollectionValueSupport)value).getElements();
for (MetaValue mv:requests) {
@@ -625,7 +682,7 @@
@Override
public void terminateTransaction(String xid) throws AdminException {
try {
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
ManagedUtil.executeOperation(mc, "terminateTransaction",
MetaValueFactory.getInstance().create(xid));
} catch (Exception e) {
throw new AdminComponentException(e.getMessage(), e);
@@ -635,7 +692,7 @@
@Override
public WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException
{
try {
- ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(),
DQPTYPE);
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
MetaValue value = ManagedUtil.executeOperation(mc,
"getWorkManagerStatistics", SimpleValueSupport.wrap(identifier));
return (WorkerPoolStatistics)MetaValueFactory.getInstance().unwrap(value,
WorkerPoolStatistics.class);
} catch (Exception e) {
@@ -819,4 +876,6 @@
jo.close();
return jarFile;
}
+
+
}
Modified:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -21,12 +21,26 @@
*/
package org.teiid.adminapi.jboss;
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.profileservice.spi.ProfileService;
import org.teiid.adminapi.AdminComponentException;
@@ -34,26 +48,20 @@
public static Admin getLocal() throws AdminComponentException {
ProfileConnection pc = new ProfileConnection();
- return new Admin(pc.connect(null, null, null));
+ return new Admin(pc.getManagementView(), pc.getDeploymentManager());
}
public static Admin getRemote(String provideURL, String userid, String password) throws
AdminComponentException {
- ProfileConnection pc = new ProfileConnection();
- return new Admin(pc.connect(provideURL, userid, password));
+ ProfileConnection pc = new ProfileConnection(provideURL, userid, password);
+ return new Admin(pc.getManagementView(), pc.getDeploymentManager());
}
- public static Admin getRemote(String provideURL) throws AdminComponentException {
- ProfileConnection pc = new ProfileConnection();
- return new Admin(pc.connect(provideURL, null, null));
- }
-
/**
* Connection to profile service from a remote VM or local connection
*/
static private class ProfileConnection {
private static final String PROFILE_SERVICE_JNDI_NAME = "ProfileService";
private static final String SECURE_PROFILE_SERVICE_JNDI_NAME =
"SecureProfileService/remote";
- private static final String JNDI_LOGIN_INITIAL_CONTEXT_FACTORY =
"org.jboss.security.jndi.JndiLoginInitialContextFactory";
private static final String NAMING_CONTEXT_FACTORY =
"org.jnp.interfaces.NamingContextFactory";
private static final String JNP_TIMEOUT_JNP_INIT_PROP = "jnp.timeout";
private static final String JNP_SOTIMEOUT_JNP_INIT_PROP =
"jnp.sotimeout";
@@ -76,7 +84,30 @@
*/
private static final boolean JNP_DISABLE_DISCOVERY = true;
- public ProfileService connect(String providerURL, String user, String password) throws
AdminComponentException {
+ private ProfileService profileService;
+ private String userName;
+ private String password;
+
+
+ public ProfileConnection() throws AdminComponentException {
+ this.profileService = connect(null, null, null);
+ }
+
+ public ProfileConnection(String providerURL, String user, String password) throws
AdminComponentException {
+ this.userName = user;
+ this.password = password;
+ this.profileService = connect(providerURL, user, password);
+ }
+
+ public ManagementView getManagementView() {
+ return this.profileService.getViewManager();
+ }
+
+ public DeploymentManager getDeploymentManager() {
+ return this.profileService.getDeploymentManager();
+ }
+
+ private ProfileService connect(String providerURL, String user, String password) throws
AdminComponentException {
ClassLoader originalContextClassLoader =
Thread.currentThread().getContextClassLoader();
try {
// local connection
@@ -87,25 +118,25 @@
Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, providerURL);
- if (user != null) {
- // authenticated remote login
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
JNDI_LOGIN_INITIAL_CONTEXT_FACTORY);
- env.setProperty(Context.SECURITY_PRINCIPAL, user);
- env.setProperty(Context.SECURITY_CREDENTIALS, password);
- env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP,
String.valueOf(JNP_DISABLE_DISCOVERY));
- InitialContext ic = new InitialContext(env);
- return (ProfileService)ic.lookup(SECURE_PROFILE_SERVICE_JNDI_NAME);
- }
// un-authenticated remote login
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
NAMING_CONTEXT_FACTORY);
+ env.setProperty(Context.SECURITY_PRINCIPAL, user);
+ env.setProperty(Context.SECURITY_CREDENTIALS, password);
+ env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true");
env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP,
String.valueOf(JNP_SO_TIMEOUT));
env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP,
String.valueOf(JNP_DISABLE_DISCOVERY));
env.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
InitialContext ic = new InitialContext(env);
- return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
+
+ try {
+ return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
+ } catch(NamingException e) {
+ ProfileService ps =
(ProfileService)ic.lookup(SECURE_PROFILE_SERVICE_JNDI_NAME);
+ return
(ProfileService)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]
{ProfileService.class}, new JaasSecurityHandler(ps, this.userName, this.password));
+ }
} catch(NamingException e) {
throw new AdminComponentException(e);
} finally {
@@ -113,4 +144,46 @@
}
}
}
+
+ static class JaasSecurityHandler implements InvocationHandler {
+ private Object target;
+ private LoginContext loginContext;
+
+ public JaasSecurityHandler(Object target, final String username, final String
password) {
+ this.target = target;
+ Configuration jaasConfig = new JBossConfiguration();
+ try {
+ this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME,
null, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
+ for (Callback callback : callbacks) {
+ if (callback instanceof NameCallback) {
+ NameCallback nameCallback = (NameCallback)callback;
+ nameCallback.setName(username);
+ }
+ else if (callback instanceof PasswordCallback) {
+ PasswordCallback passwordCallback = (PasswordCallback)callback;
+ passwordCallback.setPassword(password.toCharArray());
+ }
+ else {
+ throw new UnsupportedCallbackException(callback, "Unrecognized
Callback: " + callback);
+ }
+ }
+
+ }
+ }, jaasConfig);
+ }
+ catch (LoginException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ this.loginContext.login();
+ Object returnValue = method.invoke(this.target, args);
+ this.loginContext.logout();
+ return returnValue;
+ }
+ }
}
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -0,0 +1,63 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program 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 General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.teiid.adminapi.jboss;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.AppConfigurationEntry;
+
+/**
+ * A JAAS configuration for a JBoss client. This is the programmatic equivalent of the
following auth.conf file:
+ *
+ * <code>
+ * jboss
+ * {
+ * org.jboss.security.ClientLoginModule required
+ * multi-threaded=true;
+ * };
+ * </code>
+ *
+ * @author Ian Springer
+ */
+public class JBossConfiguration extends Configuration {
+ public static final String JBOSS_ENTRY_NAME = "profileservice";
+
+ private static final String JBOSS_LOGIN_MODULE_CLASS_NAME =
"org.jboss.security.ClientLoginModule";
+ private static final String MULTI_THREADED_OPTION = "multi-threaded";
+
+ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
+ if (JBOSS_ENTRY_NAME.equals(name)) {
+ Map options = new HashMap(1);
+ options.put(MULTI_THREADED_OPTION, Boolean.TRUE.toString());
+ AppConfigurationEntry appConfigurationEntry = new
AppConfigurationEntry(JBOSS_LOGIN_MODULE_CLASS_NAME,
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
+ return new AppConfigurationEntry[] {appConfigurationEntry};
+ }
+ throw new IllegalArgumentException("Unknown entry name: " + name);
+ }
+
+ public void refresh() {
+ return;
+ }
+}
Modified:
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -35,6 +35,9 @@
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
import org.teiid.ContainerHelper;
import org.teiid.ContainerUtil;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.jboss.AdminProvider;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
@@ -62,8 +65,10 @@
private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
protected Logger log = Logger.getLogger(getClass());
private ContainerHelper containerHelper;
- private SocketTransport socketTransport;
- private SocketConfiguration socketConfiguration;
+ private SocketTransport jdbcSocketTransport;
+ private SocketConfiguration jdbcSocketConfiguration;
+ private SocketTransport adminSocketTransport;
+ private SocketConfiguration adminSocketConfiguration;
public RuntimeEngineDeployer() {
super(ManagedConnectionFactoryDeploymentGroup.class);
@@ -77,10 +82,8 @@
for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
String connectorDefinition = data.getConnectionDefinition();
if
(connectorDefinition.equals("com.metamatrix.common.comm.api.ServerConnectionFactory"))
{
-
startEngine();
-
- log.info("Teiid Engine Started = " + new
Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
+ log.info("Teiid Engine Started = " + new
Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
}
}
}
@@ -104,12 +107,21 @@
this.containerHelper = helper;
}
- public void setSocketConfiguration(SocketConfiguration socketConfig) {
- this.socketConfiguration = socketConfig;
+ public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
+ this.jdbcSocketConfiguration = socketConfig;
}
- private void startEngine() {
- ServerConnectionFactory scf = ContainerUtil.lookup(TEIID_RUNTIME);
+ public void setAdminSocketConfiguration(SocketConfiguration socketConfig) {
+ this.adminSocketConfiguration = socketConfig;
+ }
+
+ private void startEngine() throws DeploymentException {
+ ServerConnectionFactory scf = null;
+ try {
+ scf = ContainerUtil.lookup(TEIID_RUNTIME);
+ } catch (MetaMatrixRuntimeException e) {
+ throw new DeploymentException(e.getMessage());
+ }
// create the necessary services
createClientServices(scf);
@@ -117,16 +129,21 @@
// Start the socket transport
DQPConfiguration config = scf.getService(DQPConfiguration.class);
if (config.getBindAddress() != null) {
- this.socketConfiguration.setBindAddress(config.getBindAddress());
+ this.jdbcSocketConfiguration.setBindAddress(config.getBindAddress());
}
if (config.getPortNumber() > 0) {
- this.socketConfiguration.setPortNumber(config.getPortNumber());
+ this.jdbcSocketConfiguration.setPortNumber(config.getPortNumber());
}
- this.socketTransport = new SocketTransport(this.socketConfiguration);
- this.socketTransport.setWorkManager(scf.getService(WorkManager.class));
- this.socketTransport.start();
+ this.jdbcSocketTransport = new SocketTransport(this.jdbcSocketConfiguration);
+ this.jdbcSocketTransport.setWorkManager(scf.getService(WorkManager.class));
+ this.jdbcSocketTransport.start();
+ log.info("Teiid JDBC = " +
(this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber());
//$NON-NLS-1$
+ this.adminSocketTransport = new SocketTransport(this.adminSocketConfiguration);
+ this.adminSocketTransport.setWorkManager(scf.getService(WorkManager.class));
+ this.adminSocketTransport.start();
+ log.info("Teiid Admin = " +
(this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber());
//$NON-NLS-1$
}
private void stopEngine() {
@@ -139,14 +156,19 @@
// this bean is already shutdown
}
- // Stop socket transport
- if (this.socketTransport != null) {
- this.socketTransport.stop();
- this.socketTransport = null;
+ // Stop socket transport(s)
+ if (this.jdbcSocketTransport != null) {
+ this.jdbcSocketTransport.stop();
+ this.jdbcSocketTransport = null;
}
+
+ if (this.adminSocketTransport != null) {
+ this.adminSocketTransport.stop();
+ this.adminSocketTransport = null;
+ }
}
- private void createClientServices(ServerConnectionFactory scf) {
+ private void createClientServices(ServerConnectionFactory scf) throws
DeploymentException {
DQPCore dqp = new DQPCore();
dqp.setTransactionService(getTransactionService("localhost",
scf.getService(XATerminator.class)));
dqp.setWorkManager(scf.getService(WorkManager.class));
@@ -161,6 +183,14 @@
scf.registerClientService(ILogon.class, new LogonImpl(dqp.getSessionService(),
"teiid-cluster"), com.metamatrix.common.util.LogConstants.CTX_SERVER);
scf.registerClientService(ClientSideDQP.class, dqp,
LogConstants.CTX_QUERY_SERVICE);
+
+ try {
+ scf.registerClientService(Admin.class, AdminProvider.getLocal(),
LogConstants.CTX_ADMIN_API);
+ } catch (AdminComponentException e) {
+ throw new DeploymentException(e.getCause());
+ }
+
+ scf.registerClientService(ContainerHelper.class, this.containerHelper,
LogConstants.CTX_DQP);
}
private TransactionService getTransactionService(String processName, XATerminator
terminator) {
@@ -170,4 +200,5 @@
txnService.setXidFactory(new XidFactory());
return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG,
txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
}
+
}
Modified:
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
---
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -7,6 +7,7 @@
import static junit.framework.Assert.assertTrue;
import java.io.File;
+import java.io.InputStream;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;
@@ -16,6 +17,7 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminFactory;
import org.teiid.adminapi.ConnectionPoolStatistics;
import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.PropertyDefinition;
@@ -25,6 +27,7 @@
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.WorkerPoolStatistics;
+import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.core.util.UnitTestUtil;
@@ -38,7 +41,8 @@
//if (!Bootstrap.getInstance().isStarted()) Bootstrap.getInstance().bootstrap();
ds = new ServerDatasourceConnection();
conn = (com.metamatrix.jdbc.api.Connection)ds.getConnection("admin");
- admin = AdminProvider.getRemote( "jnp://localhost:1099");
+ admin = AdminProvider.getRemote( "jnp://localhost:1099",
"javaduke", "anotherduke");
+ //admin = AdminFactory.getInstance().createAdmin("admin",
"admin".toCharArray(), "mm://localhost:31443");
}
@After
@@ -286,5 +290,20 @@
names = admin.getConnectorTypes();
assertTrue(!names.contains("connector-loopy"));
}
+
+ @Test
+ public void testExportVDB() throws Exception{
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/Admin.vdb");
+
+ assertTrue(!f.exists());
+
+ InputStream in = admin.exportVDB("Admin", 1);
+ if (in != null) {
+ ObjectConverterUtil.write(in, f);
+ }
+
+ assertTrue(f.exists());
+ f.delete();
+ }
}
Modified: branches/JCA/pom.xml
===================================================================
--- branches/JCA/pom.xml 2010-01-29 20:39:07 UTC (rev 1786)
+++ branches/JCA/pom.xml 2010-01-29 20:42:18 UTC (rev 1787)
@@ -86,13 +86,14 @@
<descriptor>build/assembly/jboss-container/dependencies.xml</descriptor>
<descriptor>build/assembly/jboss-container/connectors.xml</descriptor>
<descriptor>build/assembly/jboss-container/dist.xml</descriptor>
+
<descriptor>build/assembly/adminshell/adminshell-dependencies.xml</descriptor>
+
<descriptor>build/assembly/adminshell/adminshell-dist.xml</descriptor>
+
<!--
<descriptor>build/assembly/runtime/dependencies.xml</descriptor>
<descriptor>build/assembly/runtime/dist.xml</descriptor>
<descriptor>build/assembly/cdk/cdk-dependencies.xml</descriptor>
<descriptor>build/assembly/cdk/cdk-dist.xml</descriptor>
-
<descriptor>build/assembly/adminshell/adminshell-dependencies.xml</descriptor>
-
<descriptor>build/assembly/adminshell/adminshell-dist.xml</descriptor>
<descriptor>documentation/assembly/docs.xml</descriptor>
-->
@@ -437,38 +438,42 @@
<groupId>org.jboss.man</groupId>
<artifactId>jboss-managed</artifactId>
<version>2.1.0.SP1</version>
- <scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ <version>2.1.0.SP1</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.GA</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>2.1.2.GA</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs-spi</artifactId>
<version>2.0.7.GA</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs</artifactId>
<version>2.0.7.GA</version>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-connector</artifactId>
<version>5.1.0.GA</version>
- <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>2.5.1</version>
+ </dependency>
<dependency>
<groupId>beanshell</groupId>
<artifactId>bsh</artifactId>
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -34,6 +34,7 @@
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkManager;
+import org.teiid.adminapi.Admin;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -43,6 +44,7 @@
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.jdbc.LogConfigurationProvider;
import com.metamatrix.jdbc.LogListernerProvider;
import com.metamatrix.platform.security.api.ILogon;
@@ -126,21 +128,49 @@
try {
if (!(iface.equals(ILogon.class))) {
((ILogon)clientServices.get(ILogon.class)).assertIdentity(SessionToken.getSession());
+ assosiateSecurityContext();
}
+
+ // if this is admin session, do not allow any interface other then
"Admin"
+ if (DQPWorkContext.getWorkContext().isAdmin()) {
+ if (!(iface.equals(Admin.class)) &&
!arg1.getName().equals("ping")) {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ throw new
IllegalAccessException(DQPEmbeddedPlugin.Util.getString("Illegal_access_on_admin",
context.getSubject(), context.getClientAddress()));
+ }
+ }
+
return arg1.invoke(instance, arg2);
} catch (InvocationTargetException e) {
exception = e.getTargetException();
} catch(Throwable t){
exception = t;
} finally {
+ clearSecurityContext();
+ DQPWorkContext.releaseWorkContext();
Thread.currentThread().setContextClassLoader(current);
- DQPWorkContext.releaseWorkContext();
}
throw ExceptionUtil.convertException(arg1, exception);
}
});
}
+
+ private boolean assosiateSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ ContainerHelper helper =
(ContainerHelper)this.clientServices.get(ContainerHelper.class);
+ return helper.assosiateSecurityContext(context.getSecurityDomain(),
context.getSecurityContext());
+ }
+ return false;
+ }
+ private void clearSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ ContainerHelper helper =
(ContainerHelper)this.clientServices.get(ContainerHelper.class);
+ helper.clearSecurityContext(context.getSecurityDomain());
+ }
+ }
+
// public MMProcess getProcess() {
//
// Properties props = this.bootProperties;
Modified: branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
---
branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -75,8 +75,8 @@
private Map<Long, SessionMetadata> sessionCache = new
ConcurrentHashMap<Long, SessionMetadata>();
private transient Timer sessionMonitor = new Timer("SessionMonitor",
true);
private AtomicLong idSequence = new AtomicLong();
- private boolean isSecurityEnabled = false;
private LinkedList<String> securityDomains = new LinkedList<String>();
+ private LinkedList<String> adminSecurityDomains = new
LinkedList<String>();
//
-----------------------------------------------------------------------------------
@@ -120,7 +120,7 @@
}
@Override
- public SessionMetadata createSession(String userName, Credentials credentials, String
applicationName, Properties properties)
+ public SessionMetadata createSession(String userName, Credentials credentials, String
applicationName, Properties properties, boolean adminConnection)
throws LoginException, SessionServiceException {
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
@@ -130,10 +130,15 @@
LoginContext loginContext = null;
String securityDomain = "none";
Object securityContext = null;
- if (this.isSecurityEnabled) {
+ List<String> domains = this.securityDomains;
+ if (adminConnection) {
+ domains = this.adminSecurityDomains;
+ }
+
+ if (!domains.isEmpty()) {
// Authenticate user...
// if not authenticated, this method throws exception
- MembershipServiceImpl membership = authenticate(userName, credentials,
applicationName);
+ MembershipServiceImpl membership = authenticate(userName, credentials,
applicationName, domains);
loginContext = membership.getLoginContext();
userName = membership.getUserName();
securityDomain = membership.getSecurityDomain();
@@ -192,10 +197,10 @@
return newSession;
}
- protected MembershipServiceImpl authenticate(String userName, Credentials credentials,
String applicationName)
+ protected MembershipServiceImpl authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains)
throws LoginException {
MembershipServiceImpl membership = new MembershipServiceImpl();
- membership.authenticateUser(userName, credentials, applicationName,
this.securityDomains);
+ membership.authenticateUser(userName, credentials, applicationName, domains);
return membership;
}
@@ -274,11 +279,8 @@
public void setSecurityDomains(String domainNameOrder) {
if (domainNameOrder != null && domainNameOrder.trim().length()>0) {
- isSecurityEnabled = true;
- }
- LogManager.logDetail(LogConstants.CTX_MEMBERSHIP, "Security Enabled: "
+ isSecurityEnabled); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_MEMBERSHIP, "Security Enabled:
true"); //$NON-NLS-1$
- if (isSecurityEnabled) {
List domainNames = StringUtil.split(domainNameOrder, ",");
//$NON-NLS-1$
Iterator domainNameItr = domainNames.iterator();
while ( domainNameItr.hasNext() ) {
@@ -287,6 +289,11 @@
}
}
}
+
+ public void setAdminSecurityDomain(String domain) {
+ this.adminSecurityDomains.add(domain);
+ LogManager.logDetail(LogConstants.CTX_MEMBERSHIP, "Admin Security Enabled:
true"); //$NON-NLS-1$
+ }
public void start() {
this.sessionMonitor.schedule(new TimerTask() {
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -69,10 +69,12 @@
if (password != null) {
credential = new Credentials(password.toCharArray());
}
-
+
+ boolean adminConnection =
Boolean.parseBoolean(connProps.getProperty(MMURL.CONNECTION.ADMIN, "false"));
try {
- SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps);
- long sessionID = updateDQPContext(sessionInfo);
+ SessionMetadata sessionInfo = service.createSession(user,credential, applicationName,
connProps, adminConnection);;
+
+ long sessionID = updateDQPContext(sessionInfo, adminConnection);
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful
for \"", user, "\" - created SessionID \"", "" +
sessionID, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
if (connProps.getProperty("localConnection",
"false").equalsIgnoreCase("true")) {
service.setLocalSession(sessionID);
@@ -85,7 +87,7 @@
}
}
- private long updateDQPContext(SessionMetadata s) {
+ private long updateDQPContext(SessionMetadata s, boolean adminConnection) {
long sessionID = s.getSessionId();
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
@@ -108,6 +110,10 @@
workContext.setVdbVersion(vdb.getVersion());
workContext.setVdb(vdb);
}
+
+ if (adminConnection) {
+ workContext.markAsAdmin();
+ }
DQPWorkContext.setWorkContext(workContext);
return sessionID;
}
@@ -145,6 +151,6 @@
if (!st.equals(checkSession)) {
throw new InvalidSessionException();
}
- this.updateDQPContext(sessionInfo);
+ this.updateDQPContext(sessionInfo, false);
}
}
Modified:
branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
===================================================================
---
branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2010-01-29
20:42:18 UTC (rev 1787)
@@ -274,3 +274,5 @@
SocketTransport.1=Bound to address {0} listening on port {1}
SocketTransport.2=Problem starting server binding to address {0} and listening on port
{1}
SocketTransport.3=Socket transport is not enabled for Teiid.
+
+Illegal_access_on_admin=Illegal use of admin based connection by : {0}, {1}
\ No newline at end of file
Modified:
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
---
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-01-29
20:39:07 UTC (rev 1786)
+++
branches/JCA/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -44,7 +44,7 @@
}
- SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties()); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties(), false); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains);
}
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-29
20:39:07 UTC (rev 1786)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-29
20:42:18 UTC (rev 1787)
@@ -53,7 +53,7 @@
session.setSessionId(1);
session.addAttchment(SessionToken.class, new SessionToken(1, userName));
- Mockito.stub(ssi.createSession(userName, null, applicationName,p)).toReturn(session);
+ Mockito.stub(ssi.createSession(userName, null, applicationName,p,
false)).toReturn(session);
LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$