[teiid-commits] teiid SVN: r3195 - in branches/7.4.x: api/src/main/java/org/teiid and 18 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue May 24 22:55:49 EDT 2011


Author: shawkins
Date: 2011-05-24 22:55:47 -0400 (Tue, 24 May 2011)
New Revision: 3195

Added:
   branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/
   branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
Modified:
   branches/7.4.x/api/pom.xml
   branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java
   branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java
   branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java
   branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
   branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html
   branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java
   branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
   branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
   branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java
   branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
   branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
   branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
   branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
   branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
   branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java
   branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
   branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java
   branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
   branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
   branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
   branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
   branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
Log:
TEIID-1586 increasing audit information by adding a client reported hardware address, and updating the context objects to include more information.

Modified: branches/7.4.x/api/pom.xml
===================================================================
--- branches/7.4.x/api/pom.xml	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/pom.xml	2011-05-25 02:55:47 UTC (rev 3195)
@@ -7,8 +7,8 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>teiid-api</artifactId>
-  <name>Teiid Translator API</name>
-  <description>API for creating Translators and other common extenders in Teiid</description>
+  <name>Teiid API</name>
+  <description>API for creating Translators and other extensions to Teiid</description>
   
   <dependencies>
     <dependency>
@@ -19,6 +19,12 @@
     
     <dependency>
       <groupId>org.jboss.teiid</groupId>
+      <artifactId>teiid-client</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.teiid</groupId>
       <artifactId>teiid-common-core</artifactId>
       <type>test-jar</type>
       <scope>test</scope>

Modified: branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -22,35 +22,100 @@
 
 package org.teiid;
 
+import java.io.Serializable;
 import java.util.Properties;
 import java.util.TimeZone;
 
 import javax.security.auth.Subject;
 
+import org.teiid.adminapi.Session;
+
 /**
  * Context information for the currently executing command.
  * Can be used as an argument to UDFs.
  */
 public interface CommandContext {
 	
+	/**
+	 * Get the current user name
+	 * @return
+	 */
 	String getUserName();
 	
+	/**
+	 * Get the current vdb name
+	 * @return
+	 */
 	String getVdbName();
 	
+	/**
+	 * Get the current vdb version
+	 * @return
+	 */
 	int getVdbVersion();
 	
+	/**
+	 * Get the connection id
+	 * @return
+	 */
 	String getConnectionID();
 	
+	/**
+	 * Get the environment properties.  The returned properties are associated only with the currently executing command.
+	 * The only built-in key/value in the properties is the key "sessionid" with the same value as getConnectionID()
+	 * @return
+	 * @deprecated
+	 */
 	Properties getEnvironmentProperties();
 	
+	/**
+	 * Get the next random double value 
+	 * @return
+	 */
 	double getNextRand();
 	
+	/**
+	 * Sets the seed value and returns the next random double value.  
+	 * Additional calls to {@link #getNextRand()} will be based upon the seed value.
+	 * @param seed
+	 * @return
+	 */
 	double getNextRand(long seed);
 	
+	/**
+	 * Get the processor batch size set on the BufferManager
+	 * @return
+	 */
 	int getProcessorBatchSize();
 	
+	/**
+	 * Get the server {@link TimeZone}
+	 * @return
+	 */
 	TimeZone getServerTimeZone();
 	
+	/**
+	 * Get the current subject
+	 * @return
+	 */
 	Subject getSubject();
 
+	/**
+	 * Get the current session
+	 * @return
+	 */
+	Session getSession();
+
+	/**
+	 * Get the current command payload
+	 * @return may be null if the client did not set a payload
+	 */
+	Serializable getCommandPayload();
+
+	/**
+	 * Get the current request id 
+	 * @return
+	 */
+	String getRequestId();
+
 }

Modified: branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -24,20 +24,22 @@
 
 import java.util.Arrays;
 
+import org.teiid.CommandContext;
+
 /**
  * Log format for auditing.
  */
 public class AuditMessage {
 	private String context;
 	private String activity;
-	private String principal;
-	private Object[] resources;
+	private String[] resources;
+	private CommandContext commandContext;
 
-	public AuditMessage(String context, String activity, String principal, String[] resources ) {
+	public AuditMessage(String context, String activity, String[] resources, CommandContext commandContext) {
 	    this.context = context;
 	    this.activity = activity;
-	    this.principal = principal;
 	    this.resources = resources;
+	    this.commandContext = commandContext;
 	}
 
     public String getContext() {
@@ -49,15 +51,20 @@
     }
 
     public String getPrincipal() {
-        return this.principal;
+        return this.commandContext.getUserName();
     }
 
-	public Object[] getResources() {
+	public String[] getResources() {
 		return this.resources;
 	}
-
+	
+	public CommandContext getCommandContext() {
+		return commandContext;
+	}
+	
 	public String toString() {
         StringBuffer msg = new StringBuffer();
+        msg.append( this.commandContext.getRequestId());
         msg.append(" ["); //$NON-NLS-1$
         msg.append( getPrincipal() );
         msg.append("] <"); //$NON-NLS-1$

Modified: branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -27,6 +27,8 @@
 
 public class LogMessage implements Serializable{
 
+	private static final long serialVersionUID = -134503344442009940L;
+	
 	private Object[] msgParts;
 
 	public LogMessage(Object[] msgParts) {

Modified: branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,8 +26,10 @@
 
 import javax.security.auth.Subject;
 
+import org.teiid.adminapi.Session;
 
 
+
 /**
  * The security context provides information about the user context in which
  * this query is being run.
@@ -138,4 +140,10 @@
      * @return
      */
     boolean isTransactional();
+    
+    /**
+     * Get the current session.
+     * @return
+     */
+    Session getSession();
 }

Modified: branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html	2011-05-25 02:55:47 UTC (rev 3195)
@@ -52,7 +52,7 @@
 		</UL>
 	<LI><B>Enhanced Sort Join</B> - the partitioned merge join was replaced with an enhanced sort join.  The enhanced sort join will use the actual row counts from each side of the relation to perform a index based join if one side is small enough, a partial sort of the larger side and a repeated merge join if the tuples are unbalanced but one side is not small enough to form an index, or a standard sort merge join if the tuples are balanced.
 	<LI><B>JDK1.5 JDBC Client JAR</B> - A retro-translated Teiid client JDBC jar now available to use with JDK 1.5 VM. Note only the JDBC API is supported, not the Admin API, or retrieving query plans as XML.
-	<LI><B>Security Improvements</B> - UDF and pushdown functions can now be protected with data roles.  Also the CommandContext can provide the Subject for custom security checks in UDFs.
+	<LI><B>Security Improvements</B> - UDF and pushdown functions can now be protected with data roles.  Also the CommandContext/ExecutionContext have access to the org.teiid.adminapi.Session and JAAS Subject for custom security checks in UDFs.
 	<LI><B>Cache Invalidation</B> - Prepared plan and result set caches have will invalidate entries based upon metadata and data changes respectively.  See the cache configuration maxStaleness setting and the Admin and Developer Guides for more.
 	<LI><B>Runtime Updates of Metadata</B> - ALTER statements have been added to change view/procedure/INSTEAD OF trigger (update procedure) definitions.  A CREATE TRIGGER statement is also available to add an INSTEAD OF trigger (update procedures) to views. 
 	System procedures were added to set extension metadata and stat values.  By default all effects of metadata updates happen only on running vdbs across the cluster.  To make the changes persistent see the Developers Guide Runtime Updates section.

Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -24,12 +24,11 @@
 
 
 /**
- * A Session is a lasting connection between a client and a Teiid System.
+ * A Session represents a single connection between a client and the server.
  * 
- * A user may be allowed to have multiple sessions active simultaneously.
- * 
+ * A user is allowed to have multiple sessions active simultaneously.
  */
-public interface Session extends  AdminObject {
+public interface Session extends AdminObject {
     
     /**
      * Get the Last time Client has check to see if the server is still available
@@ -90,6 +89,12 @@
     public String getClientHostName();
     
     /**
+     * Get the client hardware (typically MAC) address. Note this value is reported from the client.
+     * @return the hardware address as a hex string or null if not available.
+     */
+    public String getClientHardwareAddress();
+    
+    /**
      * Get the time the {@link Session} was created.
      * @return
      */

Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -35,7 +35,10 @@
 
 /**
  * Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ * 
  */
+/* TODO: it would probably be good to let ipAddress denote the connecting address 
+ and add clientIpAdress as the client reported value */
 @MetaMapping(SessionMetadataMapper.class)
 public class SessionMetadata extends AdminObjectImpl implements Session {
 
@@ -45,6 +48,7 @@
     private long createdTime;
     private String ipAddress;
     private String clientHostName;    
+    private String clientHardwareAddress;
     private String userName;
     private String vdbName;
     private int vdbVersion;
@@ -59,7 +63,7 @@
     private transient boolean embedded;
 
 	@Override
-	@ManagementProperty(description="Application assosiated with Session", readOnly=true)
+	@ManagementProperty(description="Application associated with Session", readOnly=true)
 	public String getApplicationName() {
 		return this.applicationName;
 	}
@@ -89,7 +93,7 @@
 	}
 
 	@Override
-	@ManagementProperty(description="IP address from where session is created", readOnly=true)
+	@ManagementProperty(description="IP address of session client", readOnly=true)
 	public String getIPAddress() {
 		return this.ipAddress;
 	}
@@ -119,7 +123,7 @@
 	}
 
 	@Override
-	@ManagementProperty(description="User name assosiated with session", readOnly=true)
+	@ManagementProperty(description="User name associated with session", readOnly=true)
 	public String getUserName() {
 		return this.userName;
 	}
@@ -129,7 +133,7 @@
 	}
 
 	@Override
-	@ManagementProperty(description="VDB name assosiated with session", readOnly=true)
+	@ManagementProperty(description="VDB name associated with session", readOnly=true)
 	public String getVDBName() {
 		return this.vdbName;
 	}
@@ -139,7 +143,7 @@
 	}
 
 	@Override
-	@ManagementProperty(description="VDB version name assosiated with session", readOnly=true)
+	@ManagementProperty(description="VDB version name associated with session", readOnly=true)
 	public int getVDBVersion() {
 		return this.vdbVersion;
 	}
@@ -168,6 +172,7 @@
     	str.append("; createdTime=").append(new Date(createdTime));
     	str.append("; applicationName=").append(applicationName);
     	str.append("; clientHostName=").append(clientHostName);
+    	str.append("; clientHardwareAddress=").append(clientHardwareAddress);
     	str.append("; IPAddress=").append(ipAddress);
     	str.append("; securityDomain=").append(securityDomain); 
     	str.append("; lastPingTime=").append(new Date(lastPingTime));
@@ -218,4 +223,14 @@
 		return embedded;
 	}
 	
+	@Override
+	@ManagementProperty(description="Hardware address reported by the client", readOnly=true)
+	public String getClientHardwareAddress() {
+		return this.clientHardwareAddress;
+	}
+	
+	public void setClientHardwareAddress(String clientHardwareAddress) {
+		this.clientHardwareAddress = clientHardwareAddress;
+	}
+	
 }

Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -43,6 +43,7 @@
 	private static final String LAST_PING_TIME = "lastPingTime"; //$NON-NLS-1$
 	private static final String IP_ADDRESS = "IPAddress"; //$NON-NLS-1$
 	private static final String CLIENT_HOST_NAME = "clientHostName"; //$NON-NLS-1$
+	private static final String CLIENT_MAC = "clientMAC"; //$NON-NLS-1$
 	private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
 	private static final String APPLICATION_NAME = "applicationName"; //$NON-NLS-1$
 	private static final MutableCompositeMetaType metaType;
@@ -60,6 +61,7 @@
 		metaType.addItem(VDB_NAME, VDB_NAME, SimpleMetaType.STRING);
 		metaType.addItem(VDB_VERSION, VDB_VERSION, SimpleMetaType.INTEGER_PRIMITIVE);
 		metaType.addItem(SECURITY_DOMAIN, SECURITY_DOMAIN, SimpleMetaType.STRING);
+		metaType.addItem(CLIENT_MAC, CLIENT_MAC, SimpleMetaType.STRING);
 		metaType.freeze();
 	}
 	
@@ -91,7 +93,7 @@
 			session.set(VDB_NAME,SimpleValueSupport.wrap(object.getVDBName()));
 			session.set(VDB_VERSION, SimpleValueSupport.wrap(object.getVDBVersion()));
 			session.set(SECURITY_DOMAIN, SimpleValueSupport.wrap(object.getSecurityDomain()));
-			
+			session.set(CLIENT_MAC, SimpleValueSupport.wrap(object.getSecurityDomain()));
 			return session;
 		}
 		throw new IllegalArgumentException("Cannot convert session " + object); //$NON-NLS-1$
@@ -116,6 +118,7 @@
 			session.setVDBName((String) metaValueFactory.unwrap(compositeValue.get(VDB_NAME)));
 			session.setVDBVersion((Integer) metaValueFactory.unwrap(compositeValue.get(VDB_VERSION)));
 			session.setSecurityDomain((String) metaValueFactory.unwrap(compositeValue.get(SECURITY_DOMAIN)));
+			session.setClientHardwareAddress((String) metaValueFactory.unwrap(compositeValue.get(CLIENT_MAC)));
 			return session;
 		}
 		throw new IllegalStateException("Unable to unwrap session " + metaValue); //$NON-NLS-1$

Modified: branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -51,6 +51,7 @@
 	public static interface CONNECTION {
 		public static final String CLIENT_IP_ADDRESS = "clientIpAddress"; //$NON-NLS-1$
 		public static final String CLIENT_HOSTNAME = "clientHostName"; //$NON-NLS-1$
+		public static final String CLIENT_MAC = "clientMAC"; //$NON-NLS-1$
 		/**
 		 * If true, will automatically select a new server instance after a communication exception.
 		 * @since 5.6

Modified: branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,8 @@
 import java.lang.reflect.Proxy;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
+import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -323,8 +325,19 @@
 			InetAddress addr = InetAddress.getLocalHost();
 			connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, addr.getHostAddress());
 			connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName());
+			NetworkInterface ni = NetworkInterface.getByInetAddress(addr);
+			if (ni != null && ni.getHardwareAddress() != null) {
+				StringBuilder sb = new StringBuilder();
+				for (byte b : ni.getHardwareAddress()) {
+					sb.append(PropertiesUtils.toHex(b >> 4));
+					sb.append(PropertiesUtils.toHex(b));
+				}
+				connectionProperties.put(TeiidURL.CONNECTION.CLIENT_MAC, sb.toString());
+			}
         } catch (UnknownHostException err1) {
         	connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, "UnknownClientAddress"); //$NON-NLS-1$
+        } catch (SocketException e) {
+        	
         }
 	}
 

Added: branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
===================================================================
--- branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java	                        (rev 0)
+++ branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -0,0 +1,35 @@
+/*
+ * 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 net.sf.retrotranslator.runtime.java.net;
+
+import java.net.NetworkInterface;
+import java.net.SocketException;
+
+public class _NetworkInterface {
+	
+	@SuppressWarnings("unused")
+	public static byte[] getHardwareAddress(NetworkInterface ni) throws SocketException {
+		return null;
+	}
+
+}


Property changes on: branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
===================================================================
--- branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -716,7 +716,7 @@
      * Convert a nibble to a hex character
      * @param   nibble  the nibble to convert.
      */
-    private static char toHex(int nibble) {
+    public static char toHex(int nibble) {
     return hexDigit[(nibble & 0xF)];
     }
 

Modified: branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
===================================================================
--- branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml	2011-05-25 02:55:47 UTC (rev 3195)
@@ -33,19 +33,73 @@
             <title>Command Logging API</title>
             <para>
                 If you want to build a custom appender for command logging that will have access to 
-                log4j "LoggingEvents" to the "COMMAND_LOG" context, it will have a message that is an instance of
-                <code>org.teiid.logging.CommandLogMessage</code> defined in the <code>teiid-api-&versionNumber;.jar</code> 
-                use these class in your development. The CommmdLogMessage include information about vdb, session, command-sql etc.
+                log4j "LoggingEvents" to the "COMMAND_LOG" contextthe appender will receive a message that is an instance of
+                <code>org.teiid.logging.CommandLogMessage</code> wrapped in a <code>org.teiid.logging.LogMessage</code>.  The relevant Teiid classes are defined in the <code>teiid-api-&versionNumber;.jar</code>. 
+                The CommmdLogMessage includes information about vdb, session, command sql, etc.  CommandLogMessages are logged at the DEBUG level.
             </para>
+            <example>
+				<title>Sample CommandLogMessage Usage</title>
+				<programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+import org.teiid.logging.*;
+
+public class CustomAppender extends AppenderSkeleton 
+{
+  
+  protected void append(LoggingEvent event) {
+    if (event.getMessage() instanceof LogMessage) {
+      LogMessage logMessage = (LogMessage)event.getMessage();
+      if (logMessage.getMessageParts()[0] instanceof CommandLogMessage) {
+        CommandLogMessage clMessage = (CommandLogMessage)logMessage.getMessageParts()[0];
+        String sql = clMessage.getSql();
+        ...
+        //log to a database, trigger an email, etc.
+      }
+    }
+    ...
+  }
+  
+  ...
+  
+}]]></programlisting>
+			</example>
         </section>
         
         <section id="audit_logging">
             <title>Audit Logging API</title>
             <para>If you want to build a custom appender for command logging that will have access to 
-                log4j "LoggingEvents" to the "AUDIT_LOG" context, it will have a message that is an instance of
-                <code>org.teiid.logging.AuditMessage</code> defined in the <code>teiid-api-&versionNumber;.jar</code> 
-                use this class in your development. AuditMessage include  information about user, the action, and the
-                target(s) of the action.</para>                            
+                log4j "LoggingEvents" to the "org.teiid.AUDIT_LOG" context, the appender will receive a message that is an instance of
+                <code>org.teiid.logging.AuditMessage</code> wrapped in a <code>org.teiid.logging.LogMessage</code>.  The relevant Teiid classes are defined in the <code>teiid-api-&versionNumber;.jar</code>. The <code>AuditMessage</code> includes information about user, the action, and the
+                target(s) of the action.  AuditMessages are logged at the DEBUG level.
+            </para>                            
+            <example>
+				<title>Sample AuditMessage Usage</title>
+				<programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+import org.teiid.logging.*;
+
+public class CustomAppender extends AppenderSkeleton 
+{
+  
+  protected void append(LoggingEvent event) {
+    if (event.getMessage() instanceof LogMessage) {
+      LogMessage logMessage = (LogMessage)event.getMessage();
+      if (logMessage.getMessageParts()[0] instanceof AuditMessage) {
+        AuditMessage auditMessage = (AuditMessage)logMessage.getMessageParts()[0];
+        String activity = auditMessage.getActivity();
+        ...
+        //log to a database, trigger an email, etc.
+      }
+    }
+    ...
+  }
+  
+  ...
+  
+}]]></programlisting>
+			</example>
         </section>
 	</section>
 </chapter>
\ No newline at end of file

Modified: branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
===================================================================
--- branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml	2011-05-25 02:55:47 UTC (rev 3195)
@@ -161,7 +161,7 @@
 				<para>Code Requirements</para>
 				<listitem>
 					<para>The java class containing the function method must be defined
-						public.
+						public.  <note><para>As many UDF methods as you want can be declared on the same class.</para></note>
             </para>
 				</listitem>
 				<listitem>
@@ -184,7 +184,7 @@
 			</itemizedlist>
 			<para>You may optionally add an additional <code>org.teiid.CommandContext</code> argument as the first parameter.  
 			The <code>CommandContext</code> interface provides access to information about the current command, such as the executing user, Subject, the vdb, the session id, etc.  
-			This <code>CommandContext</code> parameter does not need to be delared in the function metadata.</para>
+			This <code>CommandContext</code> parameter should not be delared in the function metadata.</para>
 			<example>
 				<title>Sample code</title>
 				<programlisting language="Java" role="JAVA"><![CDATA[package org.something;
@@ -207,6 +207,23 @@
    }
 }]]></programlisting>
 			</example>
+			<example>
+				<title>Sample CommandContext Usage</title>
+				<programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+
+public class SessionInfo 
+{
+   /**
+   * @param context 
+   * @return the created Timestamp 
+   */
+   public static Timestamp sessionCreated(CommandContext context)
+   {
+      return new Timestamp(context.getSession().getCreatedTime());
+   }
+}]]></programlisting>
+            <para>The corresponding UDF would be declared as Timestamp sessionCreated().</para>
+			</example>
 		</section>
 		<section>
 			<title>Post Code Activities</title>

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -100,6 +100,7 @@
                 );
         this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
         this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
+        this.securityContext.setSession(requestMsg.getWorkContext().getSession());
         
         this.connector = manager.getExecutionFactory();
     	VDBMetaData vdb = requestMsg.getWorkContext().getVDB();

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
 
 import javax.security.auth.Subject;
 
+import org.teiid.adminapi.Session;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.translator.ExecutionContext;
@@ -64,6 +65,7 @@
     
     private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
 	private List<Exception> warnings = new LinkedList<Exception>();
+	private Session session;
     
     public ExecutionContextImpl(String vdbName, int vdbVersion,  Serializable executionPayload, 
                                 String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
@@ -204,4 +206,13 @@
 		warnings.clear();
 		return result;
 	}
+	
+	@Override
+	public Session getSession() {
+		return this.session;
+	}
+	
+	public void setSession(Session session) {
+		this.session = session;
+	}
 }

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -34,7 +34,9 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.teiid.CommandContext;
 import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Session;
 import org.teiid.adminapi.DataPolicy.PermissionType;
 import org.teiid.adminapi.impl.DataPolicyMetadata;
 import org.teiid.api.exception.query.QueryMetadataException;
@@ -86,13 +88,13 @@
     }
     
     private HashMap<String, DataPolicy> allowedPolicies;
-    private String userName;
     private boolean allowCreateTemporaryTablesDefault = true;
     private boolean allowFunctionCallsByDefault = true;
+    private CommandContext commandContext;
 
-    public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, String user) {
+    public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, CommandContext commandContext) {
         this.allowedPolicies = policies;
-        this.userName = user;
+        this.commandContext = commandContext;
     }
     
     public void setAllowCreateTemporaryTablesDefault(
@@ -150,7 +152,7 @@
     	logResult(resources, context, allowed);
     	if (!allowed) {
 		    handleValidationError(
-			        QueryPlugin.Util.getString("ERR.018.005.0095", userName, "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$  //$NON-NLS-2$
+			        QueryPlugin.Util.getString("ERR.018.005.0095", commandContext.getUserName(), "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$  //$NON-NLS-2$
 			        symbols);
     	}
 	}
@@ -158,7 +160,7 @@
 	private void logRequest(Set<String> resources, Context context) {
 		if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
 	        // Audit - request
-	    	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+	    	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
 	    	LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
         }
 	}
@@ -374,7 +376,7 @@
 	    // is not authorized in the exception message
 	    
 	    handleValidationError(
-	        QueryPlugin.Util.getString("ERR.018.005.0095", userName, actionCode), //$NON-NLS-1$                    
+	        QueryPlugin.Util.getString("ERR.018.005.0095", commandContext.getUserName(), actionCode), //$NON-NLS-1$                    
 	        inaccessibleSymbols);
 	}
 
@@ -409,10 +411,10 @@
 			boolean granted) {
 		if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
 	        if (granted) {
-	        	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+	        	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
 	        	LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
 	        } else {
-	        	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-denied", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+	        	AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-denied", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
 	        	LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
 	        }
 		}

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
 
 /**
  * Defines a validator that checks for proper authorization.  
@@ -33,7 +34,7 @@
 public interface AuthorizationValidator {
 	
 	void validate(Command command, QueryMetadataInterface metadata,
-			DQPWorkContext workContext) throws QueryValidatorException, TeiidComponentException;
+			DQPWorkContext workContext, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException;
 	
 	boolean hasRole(String roleName, DQPWorkContext workContext);
 }

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
 import org.teiid.core.TeiidComponentException;
 import org.teiid.query.metadata.QueryMetadataInterface;
 import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
 
 /**
  * The default Teiid authorization validator
@@ -44,9 +45,9 @@
 	}
 
 	@Override
-	public void validate(Command command, QueryMetadataInterface metadata, DQPWorkContext workContext) throws QueryValidatorException, TeiidComponentException {
+	public void validate(Command command, QueryMetadataInterface metadata, DQPWorkContext workContext, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException {
 		if (useEntitlements && !workContext.getVDB().getDataPolicies().isEmpty()) {
-			AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(workContext.getAllowedDataPolicies(), workContext.getUserName());
+			AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(workContext.getAllowedDataPolicies(), commandContext);
 			visitor.setAllowCreateTemporaryTablesDefault(allowCreateTemporaryTablesByDefault);
 			visitor.setAllowFunctionCallsByDefault(allowFunctionCallsByDefault);
 			Request.validateWithVisitor(visitor, metadata, command);

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -158,8 +158,6 @@
             processPlan = cachedPlan.clone();
             //already in cache. obtain the values from cache
             analysisRecord = prepPlan.getAnalysisRecord();
-            
-            createCommandContext();
         }
         
         if (requestMsg.isBatchedUpdate()) {

Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -205,9 +205,9 @@
         this.metadata = tma;
     }
     
-    protected void createCommandContext() throws QueryValidatorException {
-    	boolean returnsResultSet = userCommand.returnsResultSet();
-    	this.returnsUpdateCount = !(userCommand instanceof StoredProcedure) && !returnsResultSet;
+    protected void createCommandContext(Command command) throws QueryValidatorException {
+    	boolean returnsResultSet = command.returnsResultSet();
+    	this.returnsUpdateCount = !(command instanceof StoredProcedure) && !returnsResultSet;
     	if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT && !returnsUpdateCount) 
     			|| (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET && !returnsResultSet)) {
         	throw new QueryValidatorException(QueryPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -252,6 +252,8 @@
         context.setResultSetCacheEnabled(this.resultSetCacheEnabled);
         context.setUserRequestSourceConcurrency(this.userRequestConcurrency);
         context.setSubject(workContext.getSubject());
+        this.context.setSession(workContext.getSession());
+        this.context.setRequestId(this.requestId);
     }
     
     @Override
@@ -381,11 +383,9 @@
         this.analysisRecord = new AnalysisRecord(requestMsg.getShowPlan() != ShowPlan.OFF, requestMsg.getShowPlan() == ShowPlan.DEBUG);
                 
         resolveCommand(command);
-        
+
         validateAccess(userCommand);
         
-        createCommandContext();
-
         Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, true);
         for (GroupSymbol groupSymbol : groups) {
 			if (groupSymbol.isTempTable()) {
@@ -464,7 +464,8 @@
 	}
 
 	protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
-		this.authorizationValidator.validate(command, metadata, workContext);
+		createCommandContext(command);
+		this.authorizationValidator.validate(command, metadata, workContext, context);
 	}
 	
 }

Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
 
 import org.teiid.query.sql.LanguageObject;
 import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
 import org.teiid.query.sql.visitor.SQLStringVisitor;
 
 
@@ -50,7 +51,7 @@
     }
     
     public abstract void acceptVisitor(LanguageVisitor visitor);
-    public abstract void collectGroups(Collection groups);
+    public abstract void collectGroups(Collection<GroupSymbol> groups);
     public abstract Object clone();
 
     public boolean isMakeDep() {

Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
 import org.teiid.core.util.EquivalenceUtil;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
 
 
 /**
@@ -165,7 +166,7 @@
      * Collect all GroupSymbols for this from clause.
      * @param groups Groups to add to
      */
-    public void collectGroups(Collection groups) {
+    public void collectGroups(Collection<GroupSymbol> groups) {
         if(this.leftClause != null) { 
             this.leftClause.collectGroups(groups);
         } 

Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -83,7 +83,7 @@
 		public ProjectedColumn copyTo(ProjectedColumn copy) {
 			copy.name = this.name;
 			copy.type = this.type;
-			copy.symbol = (ElementSymbol)this.symbol.clone();
+			copy.symbol = this.symbol.clone();
 			return copy;
 		}
 		
@@ -101,14 +101,14 @@
 	}
     
 	public void copy(TableFunctionReference copy) {
-		copy.symbol = (GroupSymbol)this.symbol.clone();
+		copy.symbol = this.symbol.clone();
 		if (correlatedReferences != null) {
 			copy.correlatedReferences = correlatedReferences.clone();
 		}
 	}
 
 	@Override
-	public void collectGroups(Collection groups) {
+	public void collectGroups(Collection<GroupSymbol> groups) {
 		groups.add(getGroupSymbol());
 	}
 	

Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -2,7 +2,6 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 
 import net.sf.saxon.sxpath.XPathExpression;
@@ -195,11 +194,6 @@
 	}
 
 	@Override
-	public void collectGroups(Collection groups) {
-		groups.add(getGroupSymbol());
-	}
-	
-	@Override
 	public boolean equals(Object obj) {
 		if (obj == this) {
 			return true;

Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -33,6 +33,7 @@
 
 import javax.security.auth.Subject;
 
+import org.teiid.adminapi.Session;
 import org.teiid.api.exception.query.QueryProcessingException;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.TeiidComponentException;
@@ -40,6 +41,7 @@
 import org.teiid.dqp.internal.process.PreparedPlan;
 import org.teiid.dqp.internal.process.SessionAwareCache;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.dqp.message.RequestID;
 import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -117,6 +119,10 @@
 	    private int userRequestSourceConcurrency;
 	    private Subject subject;
 	    private HashSet<Object> dataObjects;
+
+		public Session session;
+
+		public RequestID requestId;
 	}
 	
 	private GlobalState globalState = new GlobalState();
@@ -567,4 +573,22 @@
 		this.dataObjects = dataObjectsAccessed;
 	}
 	
+	@Override
+	public Session getSession() {
+		return this.globalState.session;
+	}
+	
+	public void setSession(Session session) {
+		this.globalState.session = session;
+	}
+	
+	@Override
+	public String getRequestId() {
+		return this.globalState.requestId.toString();
+	}
+	
+	public void setRequestId(RequestID requestId) {
+		this.globalState.requestId = requestId;
+	}
+	
 }

Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -29,11 +29,13 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.DataPolicy.PermissionType;
 import org.teiid.adminapi.impl.DataPolicyMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
 import org.teiid.api.exception.query.QueryParserException;
@@ -47,6 +49,7 @@
 import org.teiid.query.sql.lang.Command;
 import org.teiid.query.sql.symbol.ElementSymbol;
 import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
 import org.teiid.query.validator.Validator;
 import org.teiid.query.validator.ValidatorFailure;
 import org.teiid.query.validator.ValidatorReport;
@@ -55,6 +58,11 @@
 public class TestAuthorizationValidationVisitor {
 
     public static final String CONN_ID = "connID"; //$NON-NLS-1$
+    private static CommandContext context = new CommandContext();
+    
+    @BeforeClass public static void oneTimeSetup() {
+    	context.setSession(new SessionMetadata());
+    }
 
     PermissionMetaData addResource(PermissionType type, boolean flag, String resource) {
     	PermissionMetaData p = new PermissionMetaData();
@@ -172,7 +180,7 @@
         HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
         policies.put(policy.getName(), policy);
         
-        AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, "test"); //$NON-NLS-1$
+        AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, context); //$NON-NLS-1$
         visitor.setAllowFunctionCallsByDefault(false);
         ValidatorReport report = Validator.validate(command, metadata, visitor);
         if(report.hasItems()) {
@@ -321,7 +329,7 @@
 	private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, TeiidComponentException {
 		VDBMetaData vdb = RealMetadataFactory.example1VDB();
 		vdb.getModel("pm1").setVisible(visible); //$NON-NLS-1$
-		AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
+		AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), context); //$NON-NLS-1$
 		String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
 		Command command = QueryParser.getQueryParser().parseCommand(sql);
 		Request.validateWithVisitor(mvvv, RealMetadataFactory.example1Cached(), command);

Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
 import org.teiid.client.RequestMessage;
 import org.teiid.client.RequestMessage.StatementType;
 import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
@@ -79,7 +80,7 @@
         RequestMessage message = new RequestMessage();
         DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
         
-        request.initialize(message, null, null,new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null); 
+        request.initialize(message, BufferManagerFactory.getStandaloneBufferManager(), null,new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null); 
         request.initMetadata();
         request.setAuthorizationValidator(new DataRoleAuthorizationValidator(true, true, true));
         request.validateAccess(command);

Modified: branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -185,6 +185,7 @@
         newSession.setApplicationName(applicationName);
         newSession.setClientHostName(properties.getProperty(TeiidURL.CONNECTION.CLIENT_HOSTNAME));
         newSession.setIPAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS));
+        newSession.setClientHardwareAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_MAC));
         newSession.setSecurityDomain(securityDomain);
         if (vdb != null) {
 	        newSession.setVDBName(vdb.getName());
@@ -195,7 +196,7 @@
         newSession.setLoginContext(loginContext);
         newSession.setSecurityContext(securityContext);
         newSession.setVdb(vdb);
-        LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", userName, "\" - created SessionID \"", newSession.getSessionToken().getSessionID(), "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful, created", newSession }); //$NON-NLS-1$ 
         this.sessionCache.put(newSession.getSessionId(), newSession);
         return newSession;
 	}

Modified: branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -118,7 +118,6 @@
 				this.loginContext.login();
 				this.userName = baseUsername+AT+domain;
 				this.securitydomain = domain;
-				LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", username, "\""}); //$NON-NLS-1$ //$NON-NLS-2$
 				return;
 			} catch (LoginException e) {
 				LogManager.logDetail(LogConstants.CTX_SECURITY,e, e.getMessage()); 

Modified: branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2011-05-25 02:55:47 UTC (rev 3195)
@@ -60,7 +60,7 @@
 	public LogonResult logon(Properties connProps) throws LogonException,
 			ComponentNotFoundException {
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		SessionToken oldToken = workContext.getSessionToken();
+		String oldSessionId = workContext.getSessionId();
         String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
         // user may be null if using trustedToken to log on
         String user = connProps.getProperty(TeiidURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
@@ -78,9 +78,9 @@
 	        if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
 				sessionInfo.setEmbedded(true);
 	        }
-	        if (oldToken != null) {
+	        if (oldSessionId != null) {
 	        	try {
-					this.service.closeSession(oldToken.getSessionID());
+					this.service.closeSession(oldSessionId);
 				} catch (InvalidSessionException e) {
 				}
 	        }



More information about the teiid-commits mailing list