Author: rareddy
Date: 2011-11-16 17:49:58 -0500 (Wed, 16 Nov 2011)
New Revision: 3659
Added:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Log4jListener.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAttachments.java
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
Removed:
branches/as7/runtime/src/main/java/org/teiid/deployers/TeiidAttachments.java
branches/as7/runtime/src/main/java/org/teiid/logging/Log4jListener.java
branches/as7/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java
Modified:
branches/as7/engine/pom.xml
branches/as7/jboss-integration/pom.xml
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorStructureDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructureDeployer.java
branches/as7/metadata/pom.xml
branches/as7/pom.xml
branches/as7/runtime/pom.xml
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorUtil.java
branches/as7/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
branches/as7/test-integration/pom.xml
Log:
TEIID-1720: Worked in reducing the dependency structure, such that only jboss-integration
has deep jboss dependencies.
Modified: branches/as7/engine/pom.xml
===================================================================
--- branches/as7/engine/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/engine/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -71,25 +71,14 @@
<artifactId>jta</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<scope>provided</scope>
</dependency>
- <!--
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs-spi</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
- -->
- <dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxonhe</artifactId>
</dependency>
Modified: branches/as7/jboss-integration/pom.xml
===================================================================
--- branches/as7/jboss-integration/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/jboss-integration/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -44,22 +44,6 @@
<artifactId>connector-api</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-controller</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-clustering-jgroups</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>staxmapper</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.jboss</groupId>
@@ -72,14 +56,8 @@
<artifactId>jboss-msc</artifactId>
<scope>provided</scope>
</dependency>
-
+
<dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-xjc</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<scope>provided</scope>
@@ -91,18 +69,19 @@
<scope>provided</scope>
</dependency>
+ <!-- This dependency is to read the ra.xml file details -->
<dependency>
<groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-server</artifactId>
+ <artifactId>jboss-as-connector</artifactId>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-connector</artifactId>
+ <artifactId>jboss-as-security</artifactId>
<scope>provided</scope>
- </dependency>
-
+ </dependency>
+
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-subsystem-test</artifactId>
@@ -115,112 +94,25 @@
<scope>provided</scope>
</dependency>
- <!--
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.integration</groupId>
- <artifactId>jboss-profileservice-spi</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-connector</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.microcontainer</groupId>
- <artifactId>jboss-aop-mc-int</artifactId>
- <version>2.0.6.GA</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.security</groupId>
- <artifactId>jbosssx</artifactId>
- <version>2.0.3.SP1</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jnp-client</artifactId>
- <version>5.0.3.GA</version>
- <scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.jboss.remoting</groupId>
- <artifactId>jboss-remoting</artifactId>
- <version>2.5.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-security-aspects</artifactId>
- <version>1.0.0.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-remoting-aspects</artifactId>
- <version>1.0.1.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>oswego-concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <version>1.3.4-jboss-update1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-server</artifactId>
- <version>5.1.0.GA</version>
- <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>
- -->
<dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.teiid.connectors</groupId>
<artifactId>translator-jdbc</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
Added:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
(rev 0)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -0,0 +1,109 @@
+/*
+ * 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.jboss;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.as.security.plugins.SecurityDomainContext;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.SimplePrincipal;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.runtime.RuntimePlugin;
+import org.teiid.security.Credentials;
+import org.teiid.services.SessionServiceImpl;
+import org.teiid.services.TeiidLoginContext;
+
+public class JBossSessionService extends SessionServiceImpl {
+
+ private Map<String, SecurityDomainContext> securityDomainMap;
+
+ public JBossSessionService(Map<String, SecurityDomainContext> securityDomainMap)
{
+ this.securityDomainMap = securityDomainMap;
+ }
+
+ @Override
+ protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, boolean onlyallowPassthrough)
+ throws LoginException {
+ return authenticateUser(userName, credentials, applicationName, domains,
securityDomainMap, onlyallowPassthrough);
+ }
+
+ private TeiidLoginContext authenticateUser(String username, final Credentials
credential, String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, boolean onlyallowPassthrough)
+ throws LoginException {
+
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[]
{"authenticateUser", username, applicationName}); //$NON-NLS-1$
+
+ final String baseUsername = getBaseUsername(username);
+
+ if (onlyallowPassthrough) {
+ for (String domain:getDomainsForUser(domains, username)) {
+ Subject existing = this.securityHelper.getSubjectInContext(domain);
+ if (existing != null) {
+ return new TeiidLoginContext(getUserName(existing)+AT+domain, existing, domain,
this.securityHelper.getSecurityContext(domain));
+ }
+ }
+ throw new
LoginException(RuntimePlugin.Util.getString("no_passthrough_identity_found"));
//$NON-NLS-1$
+ }
+
+
+ // If username specifies a domain (user@domain) only that domain is authenticated
against.
+ // If username specifies no domain, then all domains are tried in order.
+ for (String domain:getDomainsForUser(domains, username)) {
+ // this is the configured login for teiid
+ SecurityDomainContext securityDomainContext = securityDomainMap.get(domain);
+ if (securityDomainContext != null) {
+ AuthenticationManager authManager =
securityDomainContext.getAuthenticationManager();
+ if (authManager != null) {
+ Principal userPrincipal = new SimplePrincipal(username);
+ Subject subject = new Subject();
+ boolean isValid = authManager.isValid(userPrincipal,
credential==null?null:new String(credential.getCredentialsAsCharArray()), subject);
+ if (isValid) {
+ String userName = baseUsername+AT+domain;
+ Object securityContext = this.securityHelper.createSecurityContext(domain,
userPrincipal, credential==null?null:new String(credential.getCredentialsAsCharArray()),
subject);
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", username, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
+ return new TeiidLoginContext(userName, subject, domain, securityContext);
+ }
+ }
+ }
+ }
+ throw new
LoginException(RuntimePlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect",
username )); //$NON-NLS-1$
+ }
+
+ private String getUserName(Subject subject) {
+ Set<Principal> principals = subject.getPrincipals();
+ for (Principal p:principals) {
+ if (p instanceof Group) {
+ continue;
+ }
+ return p.getName();
+ }
+ return null;
+ }
+
+}
Property changes on:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/JBossSessionService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Log4jListener.java
(from rev 3600, branches/as7/runtime/src/main/java/org/teiid/logging/Log4jListener.java)
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Log4jListener.java
(rev 0)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Log4jListener.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -0,0 +1,120 @@
+/*
+ * 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.jboss;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.teiid.logging.MessageLevel;
+
+
+/**
+ * Log4J Listener
+ */
+public class Log4jListener implements org.teiid.logging.Logger {
+
+ @Override
+ public boolean isEnabled(String context, int level) {
+ if ( context == null ) {
+ return false;
+ }
+ Level logLevel = convert2Log4JLevel(level);
+ if ( logLevel == Level.OFF) {
+ return false;
+ }
+ Logger log = getLogger(context);
+ return log.isEnabledFor(logLevel);
+ }
+
+ @Override
+ public void log(int level, String context, Object msg) {
+ Logger log4j = getLogger(context);
+ log4j.log(convert2Log4JLevel(level), msg);
+ }
+
+ public void log(int level, String context, Throwable t, Object msg) {
+ Logger log4j = getLogger(context);
+ log4j.log(convert2Log4JLevel(level), msg, t);
+ }
+
+ /**
+ * Convert {@link MessageLevel} to {@link Level}
+ * @param level
+ * @return
+ */
+ public static Level convert2Log4JLevel(int level) {
+ switch (level) {
+ case MessageLevel.CRITICAL:
+ return Level.FATAL;
+ case MessageLevel.ERROR:
+ return Level.ERROR;
+ case MessageLevel.WARNING:
+ return Level.WARN;
+ case MessageLevel.INFO:
+ return Level.INFO;
+ case MessageLevel.DETAIL:
+ return Level.DEBUG;
+ case MessageLevel.TRACE:
+ return Level.TRACE;
+ case MessageLevel.NONE:
+ return Level.OFF;
+ }
+ return Level.DEBUG;
+ }
+
+ /**
+ * Convert {@link Level} to {@link MessageLevel}
+ * @param level
+ * @return
+ */
+ public static int convert2MessageLevel(Level level) {
+ switch (level.toInt()) {
+ case Level.FATAL_INT:
+ return MessageLevel.CRITICAL;
+ case Level.ERROR_INT:
+ return MessageLevel.ERROR;
+ case Level.WARN_INT:
+ return MessageLevel.WARNING;
+ case Level.INFO_INT:
+ return MessageLevel.INFO;
+ case Level.DEBUG_INT:
+ return MessageLevel.DETAIL;
+ case Level.OFF_INT:
+ return MessageLevel.NONE;
+ }
+ return MessageLevel.DETAIL;
+ }
+
+ /**
+ * Get the logger for the given context.
+ * @param context
+ * @return
+ */
+ public static Logger getLogger(String context) {
+ return Logger.getLogger(context);
+ }
+
+ @Override
+ public void shutdown() {
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Log4jListener.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-11-16
21:35:50 UTC (rev 3658)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -163,7 +163,17 @@
@Override
protected void performRuntime(final OperationContext context, final ModelNode
operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final
List<ServiceController<?>> newControllers) throws OperationFailedException {
-
+ ClassLoader classloader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(Module.getCallerModule().getClassLoader());
+ initilaizeTeiidEngine(context, operation, newControllers);
+ } finally {
+ Thread.currentThread().setContextClassLoader(classloader);
+ }
+ }
+
+ private void initilaizeTeiidEngine(final OperationContext context, final ModelNode
operation, final List<ServiceController<?>> newControllers)
+ throws OperationFailedException {
ServiceTarget target = context.getServiceTarget();
final JBossLifeCycleListener shutdownListener = new JBossLifeCycleListener();
@@ -198,7 +208,7 @@
newControllers.add(target.addService(TeiidServiceNames.VDB_REPO,
vdbRepositoryService).install());
// VDB Status manager
- final VDBStatusChecker statusChecker = new VDBStatusChecker(vdbRepository);
+ final VDBStatusCheckerExecutorService statusChecker = new
VDBStatusCheckerExecutorService(vdbRepository);
ValueService<VDBStatusChecker> statusService = new
ValueService<VDBStatusChecker>(new
org.jboss.msc.value.Value<VDBStatusChecker>() {
@Override
public VDBStatusChecker getValue() throws IllegalStateException,
IllegalArgumentException {
@@ -206,7 +216,7 @@
}
});
ServiceBuilder<VDBStatusChecker> statusBuilder =
target.addService(TeiidServiceNames.VDB_STATUS_CHECKER, statusService);
-
statusBuilder.addDependency(TeiidServiceNames.executorServiceName(asyncThreadPoolName),
Executor.class, statusChecker.getExecutorInjector());
+
statusBuilder.addDependency(TeiidServiceNames.executorServiceName(asyncThreadPoolName),
Executor.class, statusChecker.executorInjector);
newControllers.add(statusBuilder.install());
// System VDB Service
@@ -335,7 +345,7 @@
processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_JDBC_DRIVER|0x0001, new TranslatorDeployer());
}
- }, OperationContext.Stage.RUNTIME);
+ }, OperationContext.Stage.RUNTIME);
}
private <T> T buildService(Class<T> type, String moduleName) throws
OperationFailedException {
@@ -508,4 +518,17 @@
}
return engine;
}
+
+ static class VDBStatusCheckerExecutorService extends VDBStatusChecker{
+ final InjectedValue<Executor> executorInjector = new
InjectedValue<Executor>();
+
+ public VDBStatusCheckerExecutorService(VDBRepository vdbRepository) {
+ super(vdbRepository);
+ }
+
+ @Override
+ public Executor getExecutor() {
+ return this.executorInjector.getValue();
+ }
+ }
}
Copied: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAttachments.java
(from rev 3600,
branches/as7/runtime/src/main/java/org/teiid/deployers/TeiidAttachments.java)
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAttachments.java
(rev 0)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAttachments.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.teiid.jboss;
+
+import org.jboss.as.server.deployment.AttachmentKey;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.deployers.UDFMetaData;
+import org.teiid.metadata.index.IndexMetadataFactory;
+
+public final class TeiidAttachments {
+
+ enum DeploymentType{VDB, DYNAMIC_VDB, TRANSLATOR};
+
+ public static final AttachmentKey<VDBMetaData> VDB_METADATA =
AttachmentKey.create(VDBMetaData.class);
+ public static final AttachmentKey<UDFMetaData> UDF_METADATA =
AttachmentKey.create(UDFMetaData.class);
+ public static final AttachmentKey<IndexMetadataFactory> INDEX_METADATA =
AttachmentKey.create(IndexMetadataFactory.class);
+
+ public static final AttachmentKey<DeploymentType> DEPLOYMENT_TYPE =
AttachmentKey.create(DeploymentType.class);
+
+ public static boolean isVDBDeployment(final DeploymentUnit deploymentUnit) {
+ return DeploymentType.VDB == deploymentUnit.getAttachment(DEPLOYMENT_TYPE) ||
DeploymentType.DYNAMIC_VDB == deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
+ }
+
+ public static boolean isDynamicVDB(final DeploymentUnit deploymentUnit) {
+ return DeploymentType.DYNAMIC_VDB ==
deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
+ }
+
+ public static void setAsVDBDeployment(final DeploymentUnit deploymentUnit) {
+ deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.VDB);
+ }
+
+ public static void setAsDynamicVDBDeployment(final DeploymentUnit deploymentUnit) {
+ deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.DYNAMIC_VDB);
+ }
+
+ public static void setAsTranslatorDeployment(final DeploymentUnit deploymentUnit) {
+ deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.TRANSLATOR);
+ }
+
+ public static boolean isTranslator(final DeploymentUnit deploymentUnit) {
+ return DeploymentType.TRANSLATOR ==
deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
+ }
+}
Property changes on:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidAttachments.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -41,7 +41,6 @@
import org.jboss.as.controller.registry.AttributeAccess.Storage;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
-import org.teiid.logging.Log4jListener;
import org.teiid.logging.LogManager;
public class TeiidExtension implements Extension {
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -34,7 +34,6 @@
import org.jboss.msc.service.ServiceController;
import org.jboss.msc.service.ServiceTarget;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
-import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.TranslatorUtil;
import org.teiid.deployers.VDBStatusChecker;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorStructureDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorStructureDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TranslatorStructureDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -31,7 +31,6 @@
import org.jboss.as.server.deployment.DeploymentUtils;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.vfs.VirtualFile;
-import org.teiid.deployers.TeiidAttachments;
/**
* Detects a Translator jar and sets flags for deployment.
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java 2011-11-16
21:35:50 UTC (rev 3658)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Transport.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -106,9 +106,9 @@
public void start(StartContext context) throws StartException {
this.csr.setSecurityHelper(new JBossSecurityHelper());
- this.sessionService = new SessionServiceImpl();
+ this.sessionService = new JBossSessionService(this.securityDomains);
if (this.authenticationDomains != null &&
!this.authenticationDomains.isEmpty()) {
- this.sessionService.setSecurityDomains(this.authenticationDomains,
this.securityDomains);
+ this.sessionService.setSecurityDomains(this.authenticationDomains);
}
this.sessionService.setSessionExpirationTimeLimit(this.sessionExpirationTimeLimit);
this.sessionService.setSessionMaxLimit(this.sessionMaxLimit);
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -45,7 +45,6 @@
import org.jboss.vfs.VirtualFileFilter;
import org.jboss.vfs.VisitorAttributes;
import org.jboss.vfs.util.SuffixMatchFilter;
-import org.teiid.deployers.TeiidAttachments;
class VDBDependencyDeployer implements DeploymentUnitProcessor {
public static final String LIB = "/lib"; //$NON-NLS-1$
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -43,7 +43,6 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
-import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -34,7 +34,6 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBMetadataParser;
-import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.UDFMetaData;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -24,22 +24,42 @@
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
import java.util.concurrent.Executor;
import javax.xml.stream.XMLStreamException;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleIdentifier;
+import org.jboss.modules.ModuleLoadException;
import org.jboss.msc.service.Service;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.InjectedValue;
-import org.teiid.adminapi.*;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDB;
import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.impl.*;
+import org.teiid.adminapi.impl.DataPolicyMetadata;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SourceMappingMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.VDBMetadataParser;
+import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidException;
-import org.teiid.deployers.*;
+import org.teiid.deployers.MetadataStoreGroup;
+import org.teiid.deployers.TranslatorUtil;
+import org.teiid.deployers.UDFMetaData;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.TranslatorRepository;
@@ -86,7 +106,8 @@
VDBTranslatorMetaData data = (VDBTranslatorMetaData)t;
String type = data.getType();
- Translator parent = getTranslatorRepository().getTranslatorMetaData(type);
+ VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
+ data.setModuleName(parent.getModuleName());
Set<String> keys = parent.getProperties().stringPropertyNames();
for (String key:keys) {
@@ -261,20 +282,32 @@
throw new
TranslatorNotFoundException(RuntimePlugin.Util.getString("translator_not_found",
deployment.getName(), deployment.getVersion(), name)); //$NON-NLS-1$
}
try {
- ExecutionFactory<Object, Object> ef = map.get(translator);
- if ( ef == null) {
- ef = TranslatorUtil.buildExecutionFactory(translator);
- if (ef instanceof DelegatingExecutionFactory) {
- DelegatingExecutionFactory delegator = (DelegatingExecutionFactory)ef;
- String delegateName = delegator.getDelegateName();
- if (delegateName != null) {
- ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName,
vdbRepo, repo, deployment, map, building);
- ((DelegatingExecutionFactory) ef).setDelegate(delegate);
+ ExecutionFactory<Object, Object> ef = map.get(translator);
+ if ( ef == null) {
+
+ ClassLoader classloader = Thread.currentThread().getContextClassLoader();
+ if (translator.getModuleName() != null) {
+ try {
+ final ModuleIdentifier moduleId =
ModuleIdentifier.create(translator.getModuleName());
+ final Module module = Module.getCallerModuleLoader().loadModule(moduleId);
+ classloader = module.getClassLoader();
+ } catch (ModuleLoadException e) {
+ throw new TeiidException(e,
RuntimePlugin.Util.getString("failed_load_module", translator.getModuleName(),
translator.getName())); //$NON-NLS-1$
+ }
+ }
+
+ ef = TranslatorUtil.buildExecutionFactory(translator, classloader);
+ if (ef instanceof DelegatingExecutionFactory) {
+ DelegatingExecutionFactory delegator = (DelegatingExecutionFactory)ef;
+ String delegateName = delegator.getDelegateName();
+ if (delegateName != null) {
+ ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName,
vdbRepo, repo, deployment, map, building);
+ ((DelegatingExecutionFactory) ef).setDelegate(delegate);
+ }
}
+ map.put(translator, ef);
}
- map.put(translator, ef);
- }
- return ef;
+ return ef;
} catch(TeiidException e) {
throw new TranslatorNotFoundException(e);
}
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructureDeployer.java
===================================================================
---
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructureDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructureDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -23,7 +23,6 @@
import org.jboss.as.server.deployment.*;
import org.jboss.vfs.VirtualFile;
-import org.teiid.deployers.TeiidAttachments;
import org.teiid.metadata.VdbConstants;
Copied:
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
(from rev 3600,
branches/as7/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java)
===================================================================
---
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
(rev 0)
+++
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -0,0 +1,185 @@
+/*
+ * 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.jboss;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.security.auth.Subject;
+
+import junit.framework.TestCase;
+
+import org.jboss.as.security.plugins.SecurityDomainContext;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.SimplePrincipal;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.security.Credentials;
+import org.teiid.security.SecurityHelper;
+import org.teiid.services.TeiidLoginContext;
+
+@SuppressWarnings("nls")
+public class TestJBossSessionServiceImpl extends TestCase {
+
+ private SecurityHelper buildSecurityHelper() throws Exception {
+ Principal p = Mockito.mock(Principal.class);
+ Mockito.stub(p.getName()).toReturn("alreadylogged"); //$NON-NLS-1$
+ HashSet<Principal> principals = new HashSet<Principal>();
+ principals.add(p);
+
+ Subject subject = new Subject(false, principals, new HashSet(), new HashSet());
+ SecurityHelper sh = Mockito.mock(SecurityHelper.class);
+ Mockito.stub(sh.getSubjectInContext("passthrough")).toReturn(subject);
//$NON-NLS-1$
+
+ return sh;
+ }
+
+
+ public void testAuthenticate() throws Exception {
+ Credentials credentials = new Credentials("pass1".toCharArray());
+
+ SecurityHelper ms = buildSecurityHelper();
+
+ List<String> domains = new ArrayList<String>();
+ domains.add("testFile"); //$NON-NLS-1$
+ Map<String, SecurityDomainContext> securityDomainMap = new
HashMap<String, SecurityDomainContext>();
+ SecurityDomainContext securityContext =
Mockito.mock(SecurityDomainContext.class);
+ AuthenticationManager authManager = new AuthenticationManager() {
+ public String getSecurityDomain() {
+ return null;
+ }
+ public boolean isValid(Principal principal, Object credential, Subject activeSubject)
{
+ return true;
+ }
+ public boolean isValid(Principal principal, Object credential) {
+ return true;
+ }
+
+ @Override
+ public Principal getTargetPrincipal(Principal anotherDomainPrincipal, Map<String,
Object> contextMap) {
+ return null;
+ }
+ @Override
+ public Subject getActiveSubject() {
+ return null;
+ }
+ };
+
+ Mockito.stub(securityContext.getAuthenticationManager()).toReturn(authManager);
+ securityDomainMap.put("testFile", securityContext); //$NON-NLS-1$
+
+ JBossSessionService jss = new JBossSessionService(securityDomainMap);
+ jss.setSecurityHelper(ms);
+ jss.setSecurityDomains(domains);
+
+ TeiidLoginContext c = jss.authenticate("user1", credentials, null,
domains, false); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("user1@testFile", c.getUserName()); //$NON-NLS-1$
+ }
+
+
+ public void testPassThrough() throws Exception {
+ SecurityHelper ms = buildSecurityHelper();
+
+ List<String> domains = new ArrayList<String>();
+ domains.add("passthrough"); //$NON-NLS-1$
+ Map<String, SecurityDomainContext> securityDomainMap = new
HashMap<String, SecurityDomainContext>();
+
+ JBossSessionService jss = new JBossSessionService(securityDomainMap);
+ jss.setSecurityHelper(ms);
+ jss.setSecurityDomains(domains);
+
+ TeiidLoginContext c = jss.authenticate("user1", new
Credentials("pass1".toCharArray()), null, domains, true); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertEquals("alreadylogged@passthrough", c.getUserName());
//$NON-NLS-1$
+ }
+
+ public void validateSession(boolean securityEnabled) throws Exception {
+ final TeiidLoginContext impl = Mockito.mock(TeiidLoginContext.class);
+ Mockito.stub(impl.getUserName()).toReturn("steve@somedomain");
+ final ArrayList<String> domains = new ArrayList<String>();
+ domains.add("somedomain");
+
+ Map<String, SecurityDomainContext> securityDomainMap = new HashMap<String,
SecurityDomainContext>();
+ SecurityDomainContext securityContext =
Mockito.mock(SecurityDomainContext.class);
+
+ AuthenticationManager authManager = Mockito.mock(AuthenticationManager.class);
+ Mockito.stub(authManager.isValid(new SimplePrincipal("steve"),
"pass1", new Subject())).toReturn(true);
+
+ Mockito.stub(securityContext.getAuthenticationManager()).toReturn(authManager);
+ securityDomainMap.put("somedomain", securityContext); //$NON-NLS-1$
+
+ JBossSessionService jss = new JBossSessionService(securityDomainMap);
+ jss.setSecurityHelper(buildSecurityHelper());
+ jss.setSecurityDomains(Arrays.asList("somedomain"));
+
+ try {
+ jss.validateSession(String.valueOf(1));
+ fail("exception expected"); //$NON-NLS-1$
+ } catch (InvalidSessionException e) {
+
+ }
+
+ SessionMetadata info = jss.createSession("steve", new
Credentials("pass1".toCharArray()), "foo", new Properties(), true);
//$NON-NLS-1$ //$NON-NLS-2$
+ if (securityEnabled) {
+ Mockito.verify(authManager).isValid(new SimplePrincipal("steve"),
"pass1", new Subject());
+ }
+
+ String id1 = info.getSessionId();
+ jss.validateSession(id1);
+
+ assertEquals(1, jss.getActiveSessionsCount());
+ assertEquals(0, jss.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
+
+ jss.closeSession(id1);
+
+ try {
+ jss.validateSession(id1);
+ fail("exception expected"); //$NON-NLS-1$
+ } catch (InvalidSessionException e) {
+
+ }
+
+ try {
+ jss.closeSession(id1);
+ fail("exception expected"); //$NON-NLS-1$
+ } catch (InvalidSessionException e) {
+
+ }
+ }
+
+ @Test public void testvalidateSession() throws Exception{
+ validateSession(true);
+ }
+
+ @Test public void testvalidateSession2() throws Exception {
+ validateSession(false);
+ }
+}
Property changes on:
branches/as7/jboss-integration/src/test/java/org/teiid/jboss/TestJBossSessionServiceImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/metadata/pom.xml
===================================================================
--- branches/as7/metadata/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/metadata/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -63,18 +63,6 @@
<artifactId>jboss-vfs</artifactId>
<scope>provided</scope>
</dependency>
- <!--
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.man</groupId>
- <artifactId>jboss-managed</artifactId>
- </dependency>
- -->
<dependency>
<groupId>org.jboss.logging</groupId>
Modified: branches/as7/pom.xml
===================================================================
--- branches/as7/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -412,6 +412,11 @@
<version>1.0.0.GA</version>
</dependency>
<dependency>
+ <groupId>org.jboss.modules</groupId>
+ <artifactId>jboss-modules</artifactId>
+ <version>1.0.3.GA</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>3.0.1.GA</version>
@@ -465,8 +470,13 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-generator</artifactId>
<version>1.0.0.CR1</version>
- </dependency>
+ </dependency>
<dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.2.0.CR1</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-clustering-jgroups</artifactId>
<version>${jbossas-version}</version>
Modified: branches/as7/runtime/pom.xml
===================================================================
--- branches/as7/runtime/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/runtime/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -50,64 +50,24 @@
<artifactId>teiid-metadata</artifactId>
</dependency>
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>provided</scope>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<scope>provided</scope>
</dependency>
-
<dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
+ <groupId>org.jboss.modules</groupId>
+ <artifactId>jboss-modules</artifactId>
<scope>provided</scope>
- </dependency>
-
+ </dependency>
<dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-security</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-generator</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!--
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-core</artifactId>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
<scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs-spi</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.integration</groupId>
- <artifactId>jboss-profileservice-spi</artifactId>
- <scope>provided</scope>
- </dependency>
- -->
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -29,18 +29,15 @@
import java.util.Random;
import java.util.UUID;
-import org.jboss.modules.Module;
-import org.jboss.modules.ModuleIdentifier;
-import org.jboss.modules.ModuleLoadException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
import org.teiid.metadata.Datatype;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.metadata.FunctionParameter;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.Table;
-import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.metadata.Table.Type;
import org.teiid.translator.TranslatorException;
@@ -521,11 +518,6 @@
FunctionMethod func = addFunction("has_function_privilege"); //$NON-NLS-1$
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- try {
- classLoader =
Module.getModuleFromCallerModuleLoader(ModuleIdentifier.create("org.jboss.teiid")).getClassLoader();
//$NON-NLS-1$
- } catch (ModuleLoadException e) {
- // only in test situations
- }
ArrayList<FunctionParameter> inParams = new
ArrayList<FunctionParameter>();
inParams.add(new FunctionParameter("oid",
DataTypeManager.DefaultDataTypes.INTEGER, ""));//$NON-NLS-1$ //$NON-NLS-2$
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -25,9 +25,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
+import java.util.concurrent.Executors;
-import org.jboss.as.server.deployment.module.TempFileProviderService;
-import org.jboss.modules.Module;
+import org.jboss.vfs.TempFileProvider;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.teiid.core.CoreConstants;
@@ -40,16 +40,26 @@
public class SystemVDBDeployer {
private VDBRepository vdbRepository;
private Closeable file;
+
+ private static final TempFileProvider PROVIDER;
+ static {
+ try {
+ PROVIDER = TempFileProvider.create("teiid-deployment",
Executors.newScheduledThreadPool(2)); //$NON-NLS-1$
+ }
+ catch (final IOException ioe) {
+ throw new RuntimeException("Failed to create temp file
provider");//$NON-NLS-1$
+ }
+ }
public void start() {
try {
VirtualFile mountPoint = VFS.getChild("content/" +
CoreConstants.SYSTEM_VDB); //$NON-NLS-1$
if (!mountPoint.exists()) {
- InputStream contents =
Module.getCallerModule().getClassLoader().findResourceAsStream(CoreConstants.SYSTEM_VDB,
false);
+ InputStream contents =
Thread.currentThread().getContextClassLoader().getResourceAsStream(CoreConstants.SYSTEM_VDB);
if (contents == null) {
throw new
TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found"));
//$NON-NLS-1$
}
- this.file = VFS.mountZip(contents, CoreConstants.SYSTEM_VDB, mountPoint,
TempFileProviderService.provider());
+ this.file = VFS.mountZip(contents, CoreConstants.SYSTEM_VDB, mountPoint, PROVIDER);
}
// uri conversion is only to remove the spaces in URL, note this only with above kind
situation
Deleted: branches/as7/runtime/src/main/java/org/teiid/deployers/TeiidAttachments.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/TeiidAttachments.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/TeiidAttachments.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.teiid.deployers;
-
-import org.jboss.as.server.deployment.AttachmentKey;
-import org.jboss.as.server.deployment.DeploymentUnit;
-import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.metadata.index.IndexMetadataFactory;
-
-public final class TeiidAttachments {
-
- enum DeploymentType{VDB, DYNAMIC_VDB, TRANSLATOR};
-
- public static final AttachmentKey<VDBMetaData> VDB_METADATA =
AttachmentKey.create(VDBMetaData.class);
- public static final AttachmentKey<UDFMetaData> UDF_METADATA =
AttachmentKey.create(UDFMetaData.class);
- public static final AttachmentKey<IndexMetadataFactory> INDEX_METADATA =
AttachmentKey.create(IndexMetadataFactory.class);
-
- public static final AttachmentKey<DeploymentType> DEPLOYMENT_TYPE =
AttachmentKey.create(DeploymentType.class);
-
- public static boolean isVDBDeployment(final DeploymentUnit deploymentUnit) {
- return DeploymentType.VDB == deploymentUnit.getAttachment(DEPLOYMENT_TYPE) ||
DeploymentType.DYNAMIC_VDB == deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
- }
-
- public static boolean isDynamicVDB(final DeploymentUnit deploymentUnit) {
- return DeploymentType.DYNAMIC_VDB ==
deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
- }
-
- public static void setAsVDBDeployment(final DeploymentUnit deploymentUnit) {
- deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.VDB);
- }
-
- public static void setAsDynamicVDBDeployment(final DeploymentUnit deploymentUnit) {
- deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.DYNAMIC_VDB);
- }
-
- public static void setAsTranslatorDeployment(final DeploymentUnit deploymentUnit) {
- deploymentUnit.putAttachment(DEPLOYMENT_TYPE, DeploymentType.TRANSLATOR);
- }
-
- public static boolean isTranslator(final DeploymentUnit deploymentUnit) {
- return DeploymentType.TRANSLATOR ==
deploymentUnit.getAttachment(DEPLOYMENT_TYPE);
- }
-}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java 2011-11-16
21:35:50 UTC (rev 3658)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/TranslatorUtil.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -29,9 +29,6 @@
import java.util.Properties;
import java.util.TreeMap;
-import org.jboss.modules.Module;
-import org.jboss.modules.ModuleIdentifier;
-import org.jboss.modules.ModuleLoadException;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.core.TeiidException;
@@ -90,23 +87,11 @@
}
}
- public static ExecutionFactory buildExecutionFactory(VDBTranslatorMetaData data) throws
TeiidException {
+ public static ExecutionFactory buildExecutionFactory(VDBTranslatorMetaData data,
ClassLoader classLoader) throws TeiidException {
ExecutionFactory executionFactory;
-
- ClassLoader classloader = Thread.currentThread().getContextClassLoader();
- if (data.getModuleName() != null) {
- try {
- final ModuleIdentifier moduleId =
ModuleIdentifier.create(data.getModuleName());
- final Module module = Module.getCallerModuleLoader().loadModule(moduleId);
- classloader = module.getClassLoader();
- } catch (ModuleLoadException e) {
- throw new TeiidException(e,
RuntimePlugin.Util.getString("failed_load_module", data.getModuleName(),
data.getName())); //$NON-NLS-1$
- }
- }
-
try {
String executionClass =
data.getPropertyValue(VDBTranslatorMetaData.EXECUTION_FACTORY_CLASS);
- Object o = ReflectionHelper.create(executionClass, null, classloader);
+ Object o = ReflectionHelper.create(executionClass, null, classLoader);
if(!(o instanceof ExecutionFactory)) {
throw new TeiidException(RuntimePlugin.Util.getString("invalid_class",
executionClass));//$NON-NLS-1$
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -23,8 +23,10 @@
import java.util.LinkedList;
import java.util.concurrent.Executor;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
-import org.jboss.msc.value.InjectedValue;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -39,7 +41,6 @@
public class VDBStatusChecker {
private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private VDBRepository vdbRepository;
- private final InjectedValue<Executor> executorInjector = new
InjectedValue<Executor>();
public VDBStatusChecker(VDBRepository vdbRepository) {
this.vdbRepository = vdbRepository;
@@ -171,11 +172,8 @@
return null;
}
- public InjectedValue<Executor> getExecutorInjector(){
- return this.executorInjector;
- }
- private Executor getExecutor() {
- return this.executorInjector.getValue();
+ public Executor getExecutor() {
+ return new ThreadPoolExecutor(1, 1, 1, TimeUnit.SECONDS, new
SynchronousQueue<Runnable>());
}
}
Deleted: branches/as7/runtime/src/main/java/org/teiid/logging/Log4jListener.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/logging/Log4jListener.java 2011-11-16
21:35:50 UTC (rev 3658)
+++ branches/as7/runtime/src/main/java/org/teiid/logging/Log4jListener.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -1,119 +0,0 @@
-/*
- * 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.logging;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-
-/**
- * Log4J Listener
- */
-public class Log4jListener implements org.teiid.logging.Logger {
-
- @Override
- public boolean isEnabled(String context, int level) {
- if ( context == null ) {
- return false;
- }
- Level logLevel = convert2Log4JLevel(level);
- if ( logLevel == Level.OFF) {
- return false;
- }
- Logger log = getLogger(context);
- return log.isEnabledFor(logLevel);
- }
-
- @Override
- public void log(int level, String context, Object msg) {
- Logger log4j = getLogger(context);
- log4j.log(convert2Log4JLevel(level), msg);
- }
-
- public void log(int level, String context, Throwable t, Object msg) {
- Logger log4j = getLogger(context);
- log4j.log(convert2Log4JLevel(level), msg, t);
- }
-
- /**
- * Convert {@link MessageLevel} to {@link Level}
- * @param level
- * @return
- */
- public static Level convert2Log4JLevel(int level) {
- switch (level) {
- case MessageLevel.CRITICAL:
- return Level.FATAL;
- case MessageLevel.ERROR:
- return Level.ERROR;
- case MessageLevel.WARNING:
- return Level.WARN;
- case MessageLevel.INFO:
- return Level.INFO;
- case MessageLevel.DETAIL:
- return Level.DEBUG;
- case MessageLevel.TRACE:
- return Level.TRACE;
- case MessageLevel.NONE:
- return Level.OFF;
- }
- return Level.DEBUG;
- }
-
- /**
- * Convert {@link Level} to {@link MessageLevel}
- * @param level
- * @return
- */
- public static int convert2MessageLevel(Level level) {
- switch (level.toInt()) {
- case Level.FATAL_INT:
- return MessageLevel.CRITICAL;
- case Level.ERROR_INT:
- return MessageLevel.ERROR;
- case Level.WARN_INT:
- return MessageLevel.WARNING;
- case Level.INFO_INT:
- return MessageLevel.INFO;
- case Level.DEBUG_INT:
- return MessageLevel.DETAIL;
- case Level.OFF_INT:
- return MessageLevel.NONE;
- }
- return MessageLevel.DETAIL;
- }
-
- /**
- * Get the logger for the given context.
- * @param context
- * @return
- */
- public static Logger getLogger(String context) {
- return Logger.getLogger(context);
- }
-
- @Override
- public void shutdown() {
- }
-
-}
\ No newline at end of file
Modified: branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -44,7 +45,6 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
-import org.jboss.as.security.plugins.SecurityDomainContext;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.impl.SessionMetadata;
@@ -69,7 +69,8 @@
/**
* This class serves as the primary implementation of the Session Service.
*/
-public class SessionServiceImpl implements SessionService {
+public abstract class SessionServiceImpl implements SessionService {
+ public static final String AT = "@"; //$NON-NLS-1$
/*
* Configuration state
*/
@@ -82,18 +83,16 @@
* Injected state
*/
private VDBRepository vdbRepository;
- private SecurityHelper securityHelper;
+ protected SecurityHelper securityHelper;
private DQPCore dqp;
private Map<String, SessionMetadata> sessionCache = new
ConcurrentHashMap<String, SessionMetadata>();
- private Timer sessionMonitor = new Timer("SessionMonitor", true);
//$NON-NLS-1$
- private Map<String, SecurityDomainContext> securityDomainMap;
+ private Timer sessionMonitor = new Timer("SessionMonitor", true);
//$NON-NLS-1$
private List<String> securityDomainNames;
- public void setSecurityDomains(List<String> domainNames, Map<String,
SecurityDomainContext> domains) {
+ public void setSecurityDomains(List<String> domainNames) {
this.securityDomainNames = domainNames;
- this.securityDomainMap = domains;
}
//
-----------------------------------------------------------------------------------
@@ -163,7 +162,7 @@
// Authenticate user...
// if not authenticated, this method throws exception
boolean onlyAllowPassthrough =
Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
"false")); //$NON-NLS-1$
- TeiidLoginContext membership = authenticate(userName, credentials,
applicationName, domains, this.securityDomainMap, this.securityHelper,
onlyAllowPassthrough);
+ TeiidLoginContext membership = authenticate(userName, credentials,
applicationName, domains, onlyAllowPassthrough);
userName = membership.getUserName();
securityDomain = membership.getSecurityDomain();
securityContext = membership.getSecurityContext();
@@ -198,6 +197,9 @@
this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
+
+ abstract protected TeiidLoginContext authenticate(String userName, Credentials
credentials, String applicationName, List<String> domains, boolean
onlyallowPassthrough)
+ throws LoginException;
VDBMetaData getActiveVDB(String vdbName, String vdbVersion) throws
SessionServiceException {
VDBMetaData vdb = null;
@@ -239,12 +241,6 @@
return vdb;
}
- protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, SecurityHelper helper, boolean
onlyallowPassthrough)
- throws LoginException {
- TeiidLoginContext membership = new TeiidLoginContext(helper);
- membership.authenticateUser(userName, credentials, applicationName, domains,
securityDomainMap, onlyallowPassthrough);
- return membership;
- }
@Override
public LoginContext createLoginContext(final String securityDomain, final String user,
final String password) throws LoginException{
@@ -267,8 +263,7 @@
}
};
- TeiidLoginContext context = new TeiidLoginContext(this.securityHelper);
- return context.createLoginContext(securityDomain, handler);
+ return new LoginContext(securityDomain, handler);
}
@Override
@@ -410,4 +405,86 @@
public String getKrb5SecurityDomain(){
return this.krb5SecurityDomain;
}
+
+ protected Collection<String> getDomainsForUser(List<String> domains,
String username) {
+ // If username is null, return all domains
+ if (username == null) {
+ return domains;
+ }
+
+ String domain = getDomainName(username);
+
+ if (domain == null) {
+ return domains;
+ }
+
+ // ------------------------------------------
+ // Handle usernames having @ sign
+ // ------------------------------------------
+ String domainHolder = null;
+ for (String d:domains) {
+ if(d.equalsIgnoreCase(domain)) {
+ domainHolder = d;
+ break;
+ }
+ }
+
+ if (domainHolder == null) {
+ return Collections.emptyList();
+ }
+
+ LinkedList<String> result = new LinkedList<String>();
+ result.add(domainHolder);
+ return result;
+ }
+
+ protected static String getBaseUsername(String username) {
+ if (username == null) {
+ return username;
+ }
+
+ int index = getQualifierIndex(username);
+
+ String result = username;
+
+ if (index != -1) {
+ result = username.substring(0, index);
+ }
+
+ //strip the escape character from the remaining ats
+ return result.replaceAll("\\\\"+AT, AT); //$NON-NLS-1$
+ }
+
+ static String escapeName(String name) {
+ if (name == null) {
+ return name;
+ }
+
+ return name.replaceAll(AT, "\\\\"+AT); //$NON-NLS-1$
+ }
+
+ static String getDomainName(String username) {
+ if (username == null) {
+ return username;
+ }
+
+ int index = getQualifierIndex(username);
+
+ if (index != -1) {
+ return username.substring(index + 1);
+ }
+
+ return null;
+ }
+
+ static int getQualifierIndex(String username) {
+ int index = username.length();
+ while ((index = username.lastIndexOf(AT, --index)) != -1) {
+ if (index > 0 && username.charAt(index - 1) != '\\') {
+ return index;
+ }
+ }
+
+ return -1;
+ }
}
Modified: branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
---
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -22,105 +22,28 @@
package org.teiid.services;
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-import org.jboss.as.security.plugins.SecurityDomainContext;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.SimplePrincipal;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.runtime.RuntimePlugin;
-import org.teiid.security.Credentials;
-import org.teiid.security.SecurityHelper;
-
/**
* This class serves as the primary implementation of the
* Membership Service. Based on the security domains specified this class delegates the
responsibility of
* authenticating user to those security domains in the order they are defined.
*/
public class TeiidLoginContext {
- public static final String AT = "@"; //$NON-NLS-1$
+
private Subject subject;
private String userName;
private String securitydomain;
private Object securityContext;
- private SecurityHelper securityHelper;
- public TeiidLoginContext(SecurityHelper helper) {
- this.securityHelper = helper;
+ public TeiidLoginContext(String userName, Subject subject, String securityDomain, Object
sc) {
+ this.userName = userName;
+ this.subject = subject;
+ this.securitydomain = securityDomain;
+ this.securityContext = sc;
}
-
- public void authenticateUser(String username, final Credentials credential,
- String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, boolean onlyallowPassthrough)
- throws LoginException {
-
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[]
{"authenticateUser", username, applicationName}); //$NON-NLS-1$
-
- final String baseUsername = getBaseUsername(username);
-
- if (onlyallowPassthrough) {
- for (String domain:getDomainsForUser(domains, username)) {
- Subject existing = this.securityHelper.getSubjectInContext(domain);
- if (existing != null) {
- this.userName = getUserName(existing)+AT+domain;
- this.securitydomain = domain;
- this.subject = existing;
- this.securityContext = this.securityHelper.getSecurityContext(domain);
- return;
- }
- }
- throw new
LoginException(RuntimePlugin.Util.getString("no_passthrough_identity_found"));
//$NON-NLS-1$
- }
-
-
- // If username specifies a domain (user@domain) only that domain is authenticated
against.
- // If username specifies no domain, then all domains are tried in order.
- for (String domain:getDomainsForUser(domains, username)) {
- // this is the configured login for teiid
- SecurityDomainContext securityDomainContext = securityDomainMap.get(domain);
- if (securityDomainContext != null) {
- AuthenticationManager authManager =
securityDomainContext.getAuthenticationManager();
- if (authManager != null) {
- Principal userPrincipal = new SimplePrincipal(username);
- Subject subject = new Subject();
- boolean isValid = authManager.isValid(userPrincipal,
credential==null?null:new String(credential.getCredentialsAsCharArray()), subject);
- if (isValid) {
- this.userName = baseUsername+AT+domain;
- this.securitydomain = domain;
- this.securityContext =
this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal,
credential==null?null:new String(credential.getCredentialsAsCharArray()), subject);
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon
successful for \"", username, "\""}); //$NON-NLS-1$
//$NON-NLS-2$
- return;
- }
- }
- }
- }
- throw new
LoginException(RuntimePlugin.Util.getString("SessionServiceImpl.The_username_0_and/or_password_are_incorrect",
username )); //$NON-NLS-1$
- }
-
- private String getUserName(Subject subject) {
- Set<Principal> principals = subject.getPrincipals();
- for (Principal p:principals) {
- if (p instanceof Group) {
- continue;
- }
- return p.getName();
- }
- return null;
- }
-
+
public String getUserName() {
return this.userName;
}
@@ -136,90 +59,4 @@
public Object getSecurityContext() {
return this.securityContext;
}
-
- public LoginContext createLoginContext(String domain, CallbackHandler handler) throws
LoginException {
- return new LoginContext(domain, handler);
- }
-
- static String getBaseUsername(String username) {
- if (username == null) {
- return username;
- }
-
- int index = getQualifierIndex(username);
-
- String result = username;
-
- if (index != -1) {
- result = username.substring(0, index);
- }
-
- //strip the escape character from the remaining ats
- return result.replaceAll("\\\\"+AT, AT); //$NON-NLS-1$
- }
-
- static String escapeName(String name) {
- if (name == null) {
- return name;
- }
-
- return name.replaceAll(AT, "\\\\"+AT); //$NON-NLS-1$
- }
-
- static String getDomainName(String username) {
- if (username == null) {
- return username;
- }
-
- int index = getQualifierIndex(username);
-
- if (index != -1) {
- return username.substring(index + 1);
- }
-
- return null;
- }
-
- static int getQualifierIndex(String username) {
- int index = username.length();
- while ((index = username.lastIndexOf(AT, --index)) != -1) {
- if (index > 0 && username.charAt(index - 1) != '\\') {
- return index;
- }
- }
-
- return -1;
- }
-
- private Collection<String> getDomainsForUser(List<String> domains, String
username) {
- // If username is null, return all domains
- if (username == null) {
- return domains;
- }
-
- String domain = getDomainName(username);
-
- if (domain == null) {
- return domains;
- }
-
- // ------------------------------------------
- // Handle usernames having @ sign
- // ------------------------------------------
- String domainHolder = null;
- for (String d:domains) {
- if(d.equalsIgnoreCase(domain)) {
- domainHolder = d;
- break;
- }
- }
-
- if (domainHolder == null) {
- return Collections.emptyList();
- }
-
- LinkedList<String> result = new LinkedList<String>();
- result.add(domainHolder);
- return result;
- }
}
Modified: branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorUtil.java
===================================================================
---
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorUtil.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/test/java/org/teiid/deployers/TestTranslatorUtil.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -38,9 +38,8 @@
tm.addProperty("MyProperty", "correctly-assigned");
tm.setExecutionFactoryClass(MyTranslator.class);
+ MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm,
this.getClass().getClassLoader());
- MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm);
-
assertEquals("correctly-assigned", my.getMyProperty());
}
@@ -49,9 +48,8 @@
tm.addProperty("myproperty", "correctly-assigned");
tm.setExecutionFactoryClass(MyTranslator.class);
+ MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm,
this.getClass().getClassLoader());
- MyTranslator my = (MyTranslator)TranslatorUtil.buildExecutionFactory(tm);
-
assertEquals("correctly-assigned", my.getMyProperty());
}
Deleted:
branches/as7/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java
===================================================================
---
branches/as7/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/test/java/org/teiid/services/TestMembershipServiceImpl.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -1,114 +0,0 @@
-/*
- * 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.services;
-
-import java.security.Principal;
-import java.util.*;
-
-import javax.security.auth.Subject;
-
-import junit.framework.TestCase;
-
-import org.jboss.as.security.plugins.SecurityDomainContext;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.SimplePrincipal;
-import org.mockito.Mockito;
-import org.teiid.security.Credentials;
-import org.teiid.security.SecurityHelper;
-
-@SuppressWarnings("nls")
-public class TestMembershipServiceImpl extends TestCase {
-
-
- public void testBaseUsername() throws Exception {
-
- assertEquals("foo(a)bar.com",
TeiidLoginContext.getBaseUsername("foo\\@bar.com(a)foo")); //$NON-NLS-1$
//$NON-NLS-2$
-
- assertEquals("foo",
TeiidLoginContext.getDomainName("me\\@bar.com(a)foo")); //$NON-NLS-1$
//$NON-NLS-2$
-
- assertEquals(null, TeiidLoginContext.getDomainName("@"));
//$NON-NLS-1$
-
- assertEquals("@", TeiidLoginContext.getBaseUsername("@"));
//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private TeiidLoginContext createMembershipService() throws Exception {
- Principal p = Mockito.mock(Principal.class);
- Mockito.stub(p.getName()).toReturn("alreadylogged"); //$NON-NLS-1$
- HashSet<Principal> principals = new HashSet<Principal>();
- principals.add(p);
-
- Subject subject = new Subject(false, principals, new HashSet(), new HashSet());
- SecurityHelper sh = Mockito.mock(SecurityHelper.class);
- Mockito.stub(sh.getSubjectInContext("passthrough")).toReturn(subject);
//$NON-NLS-1$
-
- TeiidLoginContext membershipService = new TeiidLoginContext(sh);
- return membershipService;
- }
-
-
- public void testAuthenticate() throws Exception {
- Credentials credentials = new Credentials("pass1".toCharArray());
- TeiidLoginContext ms = createMembershipService();
- List<String> domains = new ArrayList<String>();
- domains.add("testFile"); //$NON-NLS-1$
- Map<String, SecurityDomainContext> securityDomainMap = new
HashMap<String, SecurityDomainContext>();
- SecurityDomainContext securityContext =
Mockito.mock(SecurityDomainContext.class);
- AuthenticationManager authManager = new AuthenticationManager() {
- public String getSecurityDomain() {
- return null;
- }
- public boolean isValid(Principal principal, Object credential, Subject activeSubject)
{
- return true;
- }
- public boolean isValid(Principal principal, Object credential) {
- return true;
- }
-
- @Override
- public Principal getTargetPrincipal(Principal anotherDomainPrincipal, Map<String,
Object> contextMap) {
- return null;
- }
- @Override
- public Subject getActiveSubject() {
- return null;
- }
- };
-
- Mockito.stub(securityContext.getAuthenticationManager()).toReturn(authManager);
- securityDomainMap.put("testFile", securityContext); //$NON-NLS-1$
-
- ms.authenticateUser("user1", credentials, null,
domains,securityDomainMap, false); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("user1@testFile", ms.getUserName()); //$NON-NLS-1$
- }
-
-
- public void testPassThrough() throws Exception {
- TeiidLoginContext ms = createMembershipService();
- List<String> domains = new ArrayList<String>();
- domains.add("passthrough"); //$NON-NLS-1$
- Map<String, SecurityDomainContext> securityDomainMap = new
HashMap<String, SecurityDomainContext>();
- ms.authenticateUser("user1", new
Credentials("pass1".toCharArray()), null, domains, securityDomainMap, true);
//$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals("alreadylogged@passthrough", ms.getUserName());
//$NON-NLS-1$
- }
-}
Modified:
branches/as7/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java
===================================================================
---
branches/as7/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/runtime/src/test/java/org/teiid/services/TestSessionServiceImpl.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -1,98 +1,38 @@
package org.teiid.services;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
-import java.util.*;
+import java.util.List;
-import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
-import org.jboss.as.security.plugins.SecurityDomainContext;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.SimplePrincipal;
+import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.adminapi.VDB.Status;
-import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.client.security.InvalidSessionException;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.service.SessionServiceException;
import org.teiid.security.Credentials;
-import org.teiid.security.SecurityHelper;
@SuppressWarnings("nls")
public class TestSessionServiceImpl {
-
- public void validateSession(boolean securityEnabled) throws Exception {
- final TeiidLoginContext impl = Mockito.mock(TeiidLoginContext.class);
- Mockito.stub(impl.getUserName()).toReturn("steve@somedomain");
- final ArrayList<String> domains = new ArrayList<String>();
- domains.add("somedomain");
+ SessionServiceImpl ssi;
+ @Before
+ public void setup() {
+ ssi = new SessionServiceImpl() {
- SessionServiceImpl ssi = new SessionServiceImpl() {
@Override
- protected TeiidLoginContext authenticate(String userName, Credentials credentials,
String applicationName, List<String> domains, Map<String,
SecurityDomainContext> securityDomainMap, SecurityHelper helper, boolean passthough)
- throws LoginException {
- impl.authenticateUser(userName, credentials, applicationName, domains,
securityDomainMap, passthough);
- return impl;
+ protected TeiidLoginContext authenticate(String userName,
+ Credentials credentials, String applicationName,
+ List<String> domains, boolean onlyallowPassthrough)
+ throws LoginException {
+ return null;
}
};
-
- Map<String, SecurityDomainContext> securityDomainMap = new HashMap<String,
SecurityDomainContext>();
- SecurityDomainContext securityContext =
Mockito.mock(SecurityDomainContext.class);
- AuthenticationManager authManager = Mockito.mock(AuthenticationManager.class);
- Credentials credentials = new Credentials("pass1".toCharArray());
- Mockito.stub(authManager.isValid(new SimplePrincipal("user1"),
credentials, new Subject())).toReturn(true);
- Mockito.stub(securityContext.getAuthenticationManager()).toReturn(authManager);
- securityDomainMap.put("somedomain", securityContext); //$NON-NLS-1$
-
- ssi.setSecurityDomains(Arrays.asList("somedomain"), securityDomainMap);
-
- try {
- ssi.validateSession(String.valueOf(1));
- fail("exception expected"); //$NON-NLS-1$
- } catch (InvalidSessionException e) {
-
- }
-
- SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties(), true); //$NON-NLS-1$ //$NON-NLS-2$
- if (securityEnabled) {
- Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains, securityDomainMap, false);
- }
-
- String id1 = info.getSessionId();
- ssi.validateSession(id1);
-
- assertEquals(1, ssi.getActiveSessionsCount());
- assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
-
- ssi.closeSession(id1);
-
- try {
- ssi.validateSession(id1);
- fail("exception expected"); //$NON-NLS-1$
- } catch (InvalidSessionException e) {
-
- }
-
- try {
- ssi.closeSession(id1);
- fail("exception expected"); //$NON-NLS-1$
- } catch (InvalidSessionException e) {
-
- }
}
- @Test public void testvalidateSession() throws Exception{
- validateSession(true);
- }
-
- @Test public void testvalidateSession2() throws Exception {
- validateSession(false);
- }
-
@Test
public void testActiveVDBWithNoVersion() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
@@ -104,7 +44,6 @@
Mockito.stub(repo.getVDB("name")).toReturn(vdb);
- SessionServiceImpl ssi = new SessionServiceImpl();
ssi.setVDBRepository(repo);
ssi.getActiveVDB("name", null);
@@ -123,7 +62,6 @@
Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
- SessionServiceImpl ssi = new SessionServiceImpl();
ssi.setVDBRepository(repo);
ssi.getActiveVDB("name", "1");
@@ -143,7 +81,6 @@
Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
- SessionServiceImpl ssi = new SessionServiceImpl();
ssi.setVDBRepository(repo);
ssi.getActiveVDB("name.1", null);
@@ -162,7 +99,6 @@
Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
- SessionServiceImpl ssi = new SessionServiceImpl();
ssi.setVDBRepository(repo);
try {
@@ -183,7 +119,6 @@
Mockito.stub(repo.getVDB("name", 1)).toReturn(vdb);
- SessionServiceImpl ssi = new SessionServiceImpl();
ssi.setVDBRepository(repo);
try {
@@ -198,4 +133,15 @@
} catch (SessionServiceException e) {
}
}
+
+ public void testBaseUsername() throws Exception {
+
+ assertEquals("foo(a)bar.com",
SessionServiceImpl.getBaseUsername("foo\\@bar.com(a)foo")); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertEquals("foo",
SessionServiceImpl.getDomainName("me\\@bar.com(a)foo")); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertEquals(null, SessionServiceImpl.getDomainName("@"));
//$NON-NLS-1$
+
+ assertEquals("@", SessionServiceImpl.getBaseUsername("@"));
//$NON-NLS-1$ //$NON-NLS-2$
+ }
}
Modified:
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
---
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-11-16
21:35:50 UTC (rev 3658)
+++
branches/as7/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-11-16
22:49:58 UTC (rev 3659)
@@ -22,18 +22,16 @@
package org.teiid.jdbc;
import java.io.File;
-import java.security.Principal;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
-import org.jboss.as.security.plugins.SecurityDomainContext;
-import org.jboss.security.AuthenticationManager;
import org.mockito.Mockito;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.VDB;
@@ -76,9 +74,11 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.tempdata.GlobalTableStore;
import org.teiid.query.tempdata.GlobalTableStoreImpl;
+import org.teiid.security.Credentials;
import org.teiid.security.SecurityHelper;
import org.teiid.services.BufferServiceImpl;
import org.teiid.services.SessionServiceImpl;
+import org.teiid.services.TeiidLoginContext;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
import org.teiid.transport.LocalServerConnection;
@@ -87,7 +87,16 @@
@SuppressWarnings({"nls", "serial"})
public class FakeServer extends ClientServiceRegistryImpl implements ConnectionProfile {
- SessionServiceImpl sessionService = new SessionServiceImpl();
+ SessionServiceImpl sessionService = new SessionServiceImpl() {
+ @Override
+ protected TeiidLoginContext authenticate(String userName,
+ Credentials credentials, String applicationName,
+ List<String> domains, boolean onlyallowPassthrough)
+ throws LoginException {
+ return new TeiidLoginContext(userName+"(a)"+domains.get(0), new Subject(),
domains.get(0), new Object());
+ }
+
+ };
LogonImpl logon;
DQPCore dqp = new DQPCore();
VDBRepository repo = new VDBRepository();
@@ -108,40 +117,9 @@
}
public FakeServer(DQPConfiguration config, boolean realBufferMangaer) {
-
- Map<String, SecurityDomainContext> securityDomainMap = new HashMap<String,
SecurityDomainContext>();
- SecurityDomainContext securityContext = Mockito.mock(SecurityDomainContext.class);
- AuthenticationManager authManager = new AuthenticationManager() {
- @Override
- public String getSecurityDomain() {
- return null;
- }
- @Override
- public boolean isValid(Principal principal, Object credential) {
- return true;
- }
- @Override
- public boolean isValid(Principal principal, Object credential,Subject activeSubject)
{
- return true;
- }
- @Override
- public Subject getActiveSubject() {
- return null;
- }
- @Override
- public Principal getTargetPrincipal(
- Principal anotherDomainPrincipal,
- Map<String, Object> contextMap) {
- return null;
- }
-
- };
- Mockito.stub(securityContext.getAuthenticationManager()).toReturn(authManager);
- securityDomainMap.put("somedomain", securityContext); //$NON-NLS-1$
sessionService.setSecurityHelper(Mockito.mock(SecurityHelper.class));
+ sessionService.setSecurityDomains(Arrays.asList("somedomain"));
- sessionService.setSecurityDomains(Arrays.asList("somedomain"),
securityDomainMap);
-
this.logon = new LogonImpl(sessionService, null);
this.repo.addListener(new VDBLifeCycleListener() {
Modified: branches/as7/test-integration/pom.xml
===================================================================
--- branches/as7/test-integration/pom.xml 2011-11-16 21:35:50 UTC (rev 3658)
+++ branches/as7/test-integration/pom.xml 2011-11-16 22:49:58 UTC (rev 3659)
@@ -98,12 +98,18 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-clustering-jgroups</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-security</artifactId>
- <scope>provided</scope>
- </dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<modules>