JBoss Portal SVN: r9058 - modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/db.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-21 05:18:37 -0500 (Wed, 21 Nov 2007)
New Revision: 9058
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java
Log:
JBPORTAL-1720 patch
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java 2007-11-21 10:18:12 UTC (rev 9057)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java 2007-11-21 10:18:37 UTC (rev 9058)
@@ -549,8 +549,8 @@
}
catch (ParseException e)
{
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException("Can't convert the date in the user profile. value=[" + value + "].", e);
+ }
}
protected String toString(Object value)
16 years, 7 months
JBoss Portal SVN: r9057 - modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/db.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-21 05:18:12 -0500 (Wed, 21 Nov 2007)
New Revision: 9057
Modified:
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/db/HibernateUserImpl.java
Log:
JBPORTAL-1720 patch
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/db/HibernateUserImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/db/HibernateUserImpl.java 2007-11-21 10:12:05 UTC (rev 9056)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/db/HibernateUserImpl.java 2007-11-21 10:18:12 UTC (rev 9057)
@@ -549,8 +549,8 @@
}
catch (ParseException e)
{
- throw new IllegalArgumentException();
- }
+ throw new IllegalArgumentException("Can't convert the date in the user profile. value=[" + value + "].", e);
+ }
}
protected String toString(Object value)
16 years, 7 months
JBoss Portal SVN: r9056 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-21 05:12:05 -0500 (Wed, 21 Nov 2007)
New Revision: 9056
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml
Log:
LDAP configuration update
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml 2007-11-21 09:54:32 UTC (rev 9055)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml 2007-11-21 10:12:05 UTC (rev 9056)
@@ -101,6 +101,65 @@
<sect1>
<title>Configuration of LDAP connection</title>
<sect2>
+ <title>Connection Pooling</title>
+ <para>Portal uses connection pooling provided by <ulink url="http://java.sun.com/products/jndi/tutorial/ldap/connect/pool.html">JNDI</ulink>.
+ It is enabled by default. You can configure connection pooling settings using following options:</para>
+ <programlisting><![CDATA[
+<datasource>
+ <name>LDAP</name>
+ <config>
+ ...
+ <!-- com.sun.jndi.ldap.connect.pool -->
+ <option>
+ <name>pooling</name>
+ <value>true</value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.protocol -->
+ <option>
+ <name>poolingProtocol</name>
+ <value>plain ssl</value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.timeout -->
+ <option>
+ <name>poolingTimeout</name>
+ <value>300000</value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.debug -->
+ <option>
+ <name>pooling</name>
+ <value> ... </value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.initsize -->
+ <option>
+ <name>poolingInitsize</name>
+ <value> ... </value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.maxsize -->
+ <option>
+ <name>poolingMaxsize</name>
+ <value> ... </value>
+ </option>
+
+ <!-- com.sun.jndi.ldap.connect.pool.prefsize -->
+ <option>
+ <name>poolingPrefsize</name>
+ <value> ... </value>
+ </option>
+
+ ...
+ </config>
+</datasource>]]></programlisting>
+ <para>
+ Please refer to the <ulink url="http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html">JNDI Documentation</ulink> to learn about option values.
+ </para>
+
+ </sect2>
+ <sect2>
<title>SSL</title>
<para>The setup is very similar to the one described in LdapLoginModule <ulink url="http://www.jboss.org/wiki/Wiki.jsp?page=LdapLoginModule">wiki page</ulink></para>
<para>You need to modify your identity configuration file and add "protocol"</para>
16 years, 7 months
JBoss Portal SVN: r9055 - in modules/identity/trunk/identity/src: test/resources/config and 1 other directory.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-21 04:54:32 -0500 (Wed, 21 Nov 2007)
New Revision: 9055
Modified:
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModule.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModule.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
modules/identity/trunk/identity/src/test/resources/config/standardidentity-config.xml
Log:
LDAP connection pooling
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -31,6 +31,7 @@
import javax.naming.NamingException;
import javax.naming.InitialContext;
import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
import java.util.Hashtable;
/**
@@ -43,13 +44,32 @@
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+ public final static String CONNECTION_POOL = "com.sun.jndi.ldap.connect.pool";
+ public final static String CONNECTION_POOL_DEBUG = "com.sun.jndi.ldap.connect.pool.debug";
+ public final static String CONNECTION_POOL_INITSIZE = "com.sun.jndi.ldap.connect.pool.initsize";
+ public final static String CONNECTION_POOL_MAXSIZE = "com.sun.jndi.ldap.connect.pool.maxsize";
+ public final static String CONNECTION_POOL_PREFSIZE = "com.sun.jndi.ldap.connect.pool.prefsize";
+ public final static String CONNECTION_POOL_PROTOCOL = "com.sun.jndi.ldap.connect.pool.protocol";
+ public final static String CONNECTION_POOL_TIMEOUT = "com.sun.jndi.ldap.connect.pool.timeout";
+
+ private boolean pooling;
+
+ private String poolingDebug;
+
+ private String poolingInitsize;
+
+ private String poolingMaxsize;
+
+ private String poolingPrefsize;
+
+ private String poolingProtocol;
+
+ private String poolingTimeout;
+
private String jndiName;
private ServiceJNDIBinder jndiBinder;
- //private JNDI.Binding jndiBinding;
-
-
private String name;
private String contextFactory;
@@ -79,10 +99,41 @@
env.put(Context.SECURITY_AUTHENTICATION, this.getAuthentication());
env.put(Context.SECURITY_PRINCIPAL, this.getAdminDN());
env.put(Context.SECURITY_CREDENTIALS, this.getAdminPassword());
+
if (this.getProtocol() != null)
{
env.put(Context.SECURITY_PROTOCOL, this.getProtocol());
}
+
+ if (isPooling())
+ {
+ env.put(CONNECTION_POOL, "true");
+ if (getPoolingDebug() != null)
+ {
+ env.put(CONNECTION_POOL_DEBUG, getPoolingDebug());
+ }
+ if (getPoolingInitsize() != null)
+ {
+ env.put(CONNECTION_POOL_INITSIZE, getPoolingInitsize());
+ }
+ if (getPoolingMaxsize() != null)
+ {
+ env.put(CONNECTION_POOL_MAXSIZE, getPoolingMaxsize());
+ }
+ if (getPoolingPrefsize() != null)
+ {
+ env.put(CONNECTION_POOL_PREFSIZE, getPoolingPrefsize());
+ }
+ if (getPoolingProtocol() != null)
+ {
+ env.put(CONNECTION_POOL_PROTOCOL, getPoolingProtocol());
+ }
+ if (getPoolingTimeout() != null)
+ {
+ env.put(CONNECTION_POOL_TIMEOUT, getPoolingTimeout());
+ }
+ }
+
return env;
}
@@ -126,7 +177,7 @@
if (identityContext != null)
{
- identityContext.register(this, IdentityContext.TYPE_CONNECTION_CONTEXT);
+ identityContext.register(this, IdentityContext.TYPE_CONNECTION_CONTEXT);
}
}
@@ -288,4 +339,74 @@
{
this.identityContext = identityContext;
}
+
+ public boolean isPooling()
+ {
+ return pooling;
+ }
+
+ public void setPooling(boolean pooling)
+ {
+ this.pooling = pooling;
+ }
+
+ public String getPoolingDebug()
+ {
+ return poolingDebug;
+ }
+
+ public void setPoolingDebug(String poolingDebug)
+ {
+ this.poolingDebug = poolingDebug;
+ }
+
+ public String getPoolingInitsize()
+ {
+ return poolingInitsize;
+ }
+
+ public void setPoolingInitsize(String poolingInitsize)
+ {
+ this.poolingInitsize = poolingInitsize;
+ }
+
+ public String getPoolingMaxsize()
+ {
+ return poolingMaxsize;
+ }
+
+ public void setPoolingMaxsize(String poolingMaxsize)
+ {
+ this.poolingMaxsize = poolingMaxsize;
+ }
+
+ public String getPoolingPrefsize()
+ {
+ return poolingPrefsize;
+ }
+
+ public void setPoolingPrefsize(String poolingPrefsize)
+ {
+ this.poolingPrefsize = poolingPrefsize;
+ }
+
+ public String getPoolingProtocol()
+ {
+ return poolingProtocol;
+ }
+
+ public void setPoolingProtocol(String poolingProtocol)
+ {
+ this.poolingProtocol = poolingProtocol;
+ }
+
+ public String getPoolingTimeout()
+ {
+ return poolingTimeout;
+ }
+
+ public void setPoolingTimeout(String poolingTimeout)
+ {
+ this.poolingTimeout = poolingTimeout;
+ }
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -29,6 +29,7 @@
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.directory.DirContext;
@@ -65,7 +66,7 @@
Object[] filterArgs = {name};
-
+
List sr = searchRoles(filter, filterArgs);
if (sr.size() > 1)
{
@@ -114,7 +115,7 @@
filter.append(")");
List sr = searchRoles(filter.toString(), null);
-
+
log.debug("Roles found: " + sr.size());
for (Iterator iterator = sr.iterator(); iterator.hasNext();)
{
@@ -173,7 +174,7 @@
Set rf = new HashSet();
try
{
- //search all entries
+ //search all entries
String filter = getRoleSearchFilter();
//* chars are escaped in filterArgs so we must replace it manually
filter = filter.replaceAll("\\{0\\}", "*");
@@ -208,63 +209,73 @@
*/
public List searchRoles(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(getSearchScope());
- controls.setReturningObjFlag(true);
- controls.setTimeLimit(getSearchTimeLimit());
- //
- filter = filter.replaceAll("\\\\", "\\\\\\\\");
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
- log.debug("Search filter: " + filter);
- if (log.isDebugEnabled() && filterArgs != null)
+ try
{
- for (int i = 0; i < filterArgs.length; i++)
- {
- Object filterArg = filterArgs[i];
- log.debug("Search filterArg: {" + i + "}: " + filterArg);
- }
- }
- log.debug("Search ctx: " + getRoleSearchCtxDNs());
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(getSearchScope());
+ controls.setReturningObjFlag(true);
+ controls.setTimeLimit(getSearchTimeLimit());
- Set roleCtxs = getRoleSearchCtxDNs();
+ //
+ filter = filter.replaceAll("\\\\", "\\\\\\\\");
- if (roleCtxs.size() == 1)
- {
- Enumeration results = null;
- if (filterArgs == null)
+ log.debug("Search filter: " + filter);
+ if (log.isDebugEnabled() && filterArgs != null)
{
- results = getConnectionContext().createInitialContext().search(getRoleCtxDN(), filter, controls);
+ for (int i = 0; i < filterArgs.length; i++)
+ {
+ Object filterArg = filterArgs[i];
+ log.debug("Search filterArg: {" + i + "}: " + filterArg);
+ }
}
- else
- {
- results = getConnectionContext().createInitialContext().search(getRoleCtxDN(), filter, filterArgs, controls);
- }
- return Tools.toList(results);
+ log.debug("Search ctx: " + getRoleSearchCtxDNs());
+ Set roleCtxs = getRoleSearchCtxDNs();
- }
- else
- {
- List merged = new LinkedList();
-
- for (Iterator iterator = roleCtxs.iterator(); iterator.hasNext();)
+ if (roleCtxs.size() == 1)
{
- String roleCtx = (String)iterator.next();
Enumeration results = null;
if (filterArgs == null)
{
- results = getConnectionContext().createInitialContext().search(roleCtx, filter, controls);
+ results = ldapContext.search(getRoleCtxDN(), filter, controls);
}
else
{
- results = getConnectionContext().createInitialContext().search(roleCtx, filter, filterArgs, controls);
+ results = ldapContext.search(getRoleCtxDN(), filter, filterArgs, controls);
}
- merged.addAll(Tools.toList(results));
+ return Tools.toList(results);
+
+
}
+ else
+ {
+ List merged = new LinkedList();
- return merged;
+ for (Iterator iterator = roleCtxs.iterator(); iterator.hasNext();)
+ {
+ String roleCtx = (String)iterator.next();
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(roleCtx, filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(roleCtx, filter, filterArgs, controls);
+ }
+ merged.addAll(Tools.toList(results));
+ }
+
+ return merged;
+ }
}
+ finally
+ {
+ ldapContext.close();
+ }
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -22,25 +22,25 @@
******************************************************************************/
package org.jboss.portal.identity.ldap;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.IdentityConfiguration;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.IdentityConfiguration;
-import org.jboss.portal.common.util.Tools;
-import javax.naming.NamingEnumeration;
import javax.naming.Context;
import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
-import javax.naming.directory.SearchControls;
-import java.util.Set;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.HashSet;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
@@ -93,7 +93,7 @@
//findUserById(Object id) from super
- //findUserById(String id) from super
+ //findUserById(String id) from super
public User createUser(String userName, String password) throws IdentityException, IllegalArgumentException
{
@@ -218,60 +218,70 @@
*/
public List searchUsers(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- controls.setReturningObjFlag(true);
- controls.setTimeLimit(getSearchTimeLimit());
- log.debug("Search filter: " + filter);
- if (log.isDebugEnabled() && filterArgs != null)
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
+ try
{
- for (int i = 0; i < filterArgs.length; i++)
- {
- Object filterArg = filterArgs[i];
- log.debug("Search filterArg: {" + i + "}: " + filterArg);
- }
- }
- log.debug("Search ctx: " + getUserSearchCtxDNs());
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ controls.setReturningObjFlag(true);
+ controls.setTimeLimit(getSearchTimeLimit());
- Set userCtxs = getUserSearchCtxDNs();
-
- if (userCtxs.size() == 1)
- {
- Enumeration results = null;
- if (filterArgs == null)
+ log.debug("Search filter: " + filter);
+ if (log.isDebugEnabled() && filterArgs != null)
{
- results = getConnectionContext().createInitialContext().search(getUserSearchCtxDN(), filter, controls);
+ for (int i = 0; i < filterArgs.length; i++)
+ {
+ Object filterArg = filterArgs[i];
+ log.debug("Search filterArg: {" + i + "}: " + filterArg);
+ }
}
- else
- {
- results = getConnectionContext().createInitialContext().search(getUserSearchCtxDN(), filter, filterArgs, controls);
- }
- return Tools.toList(results);
+ log.debug("Search ctx: " + getUserSearchCtxDNs());
+ Set userCtxs = getUserSearchCtxDNs();
- }
- else
- {
- List merged = new LinkedList();
-
- for (Iterator iterator = userCtxs.iterator(); iterator.hasNext();)
+ if (userCtxs.size() == 1)
{
- String userCtx = (String)iterator.next();
Enumeration results = null;
if (filterArgs == null)
{
- results = getConnectionContext().createInitialContext().search(userCtx, filter, controls);
+ results = ldapContext.search(getUserSearchCtxDN(), filter, controls);
}
else
{
- results = getConnectionContext().createInitialContext().search(userCtx, filter, filterArgs, controls);
+ results = ldapContext.search(getUserSearchCtxDN(), filter, filterArgs, controls);
}
- merged.addAll(Tools.toList(results));
+ return Tools.toList(results);
+
+
}
+ else
+ {
+ List merged = new LinkedList();
- return merged;
+ for (Iterator iterator = userCtxs.iterator(); iterator.hasNext();)
+ {
+ String userCtx = (String)iterator.next();
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(userCtx, filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(userCtx, filter, filterArgs, controls);
+ }
+ merged.addAll(Tools.toList(results));
+ }
+
+ return merged;
+ }
}
+ finally
+ {
+ ldapContext.close();
+ }
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModule.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -35,6 +35,7 @@
import javax.naming.NamingException;
import javax.naming.NamingEnumeration;
import javax.naming.InitialContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.NoSuchElementException;
import java.util.List;
@@ -48,7 +49,7 @@
private LDAPConnectionContext connectionContext;
-
+
public void start() throws Exception
{
if (getConnectionJNDIName() == null)
@@ -71,6 +72,7 @@
public void updateDisplayName(LDAPRoleImpl ldapr, String name) throws IdentityException
{
String attributeName = getDisplayNameAttributeID();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -81,12 +83,23 @@
attr.add(name);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapr.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapr.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set role displayName value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -136,6 +149,9 @@
*/
public Role findRoleByDN(String dn) throws IdentityException, IllegalArgumentException
{
+
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoleByDN(): DN = " + dn);
@@ -145,8 +161,9 @@
throw new IdentityException("Role dn canot be null");
}
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+ Attributes attrs = ldapContext.getAttributes(dn);
+
if (attrs == null)
{
throw new IdentityException("Can't find role entry with DN: " + dn);
@@ -163,6 +180,18 @@
{
throw new IdentityException("Role search failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
return null;
}
@@ -258,7 +287,7 @@
String roleCtx = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_CONTEXT_DN);
if (roleCtx == null)
{
- throw new IdentityException("Configuration option missing: " + IdentityConfiguration.ROLE_CONTEXT_DN);
+ throw new IdentityException("Configuration option missing: " + IdentityConfiguration.ROLE_CONTEXT_DN);
}
return roleCtx;
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -40,6 +40,7 @@
import javax.naming.directory.SearchResult;
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -113,7 +114,7 @@
.append("=")
.append(name)
.append(") ");
- }
+ }
filter.append(")");
List sr = searchRoles(filter.toString(), null);
@@ -159,10 +160,12 @@
throw new IdentityException("Role name cannot be null");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+ LdapContext ctx = (LdapContext)ldapContext.lookup(getContainerDN());
//We store new entry using set of attributes. This should give more flexibility then
//extending user object from ContextDir - configure what objectClass place there
@@ -207,6 +210,17 @@
{
throw new IdentityException("Failed to create role", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return findRoleByName(name);
}
@@ -226,16 +240,28 @@
throw new IdentityException("Cannot obtain DN of role");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext();//.lookup(getContainerDN());
log.debug("removing entry: " + ldapr.getDn());
- ctx.unbind(ldapr.getDn());
+ ldapContext.unbind(ldapr.getDn());
}
catch (Exception e)
{
throw new IdentityException("Failed to remove role: ", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
public int getRolesCount() throws IdentityException
@@ -300,24 +326,34 @@
*/
public List searchRoles(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- controls.setReturningObjFlag(true);
- //String filter = getUidAttributeID().concat("=").concat(userName);
- filter = filter.replaceAll("\\\\", "\\\\\\\\");
- log.debug("Search filter: " + filter);
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
- Enumeration results = null;
- if (filterArgs == null)
+ try
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ controls.setReturningObjFlag(true);
+
+ //String filter = getUidAttributeID().concat("=").concat(userName);
+ filter = filter.replaceAll("\\\\", "\\\\\\\\");
+ log.debug("Search filter: " + filter);
+
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(getContainerDN(), filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(getContainerDN(), filter, filterArgs, controls);
+ }
+ return Tools.toList(results);
}
- else
+ finally
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, filterArgs, controls);
+ ldapContext.close();
}
- return Tools.toList(results);
}
private Map getAttributesToAdd() throws IdentityException
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -39,6 +39,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@@ -53,8 +54,8 @@
public class LDAPStaticGroupMembershipModuleImpl extends LDAPMembershipModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticGroupMembershipModuleImpl.class);
-
+
public Set getRoles(User user) throws IdentityException
{
if (user == null)
@@ -102,7 +103,7 @@
memberName = ldapUser.getUserName();
}
-
+
String filter = getMemberAttributeID().concat("=").concat(memberName);
log.debug("Search filter: " + filter);
@@ -113,7 +114,7 @@
{
SearchResult res = (SearchResult)iterator.next();
DirContext ctx = (DirContext)res.getObject();
- roles.add(getRoleModule().createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
+ roles.add(getRoleModule().createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
}
@@ -155,6 +156,8 @@
Set users = new HashSet();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUsers(): role = " + ldapRole.getDn());
@@ -165,7 +168,7 @@
}
//obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapRole.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapRole.getDn());
//log.debug("Role attributes: " + attrs);
if (attrs == null )
@@ -208,6 +211,17 @@
{
throw new IdentityException("Resolving Role Users failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return users;
@@ -239,6 +253,8 @@
"require the member field to be set). ");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUsers(): role = " + ldapRole.getDn());
@@ -270,7 +286,7 @@
throw new IdentityException("Illegal state - cached user doesn't exist in identity store: ", e);
}
}
-
+
LDAPUserImpl ldapUser = (LDAPUserImpl)user;
if (isUidAttributeIsDN())
@@ -292,17 +308,28 @@
if (users.size() > 0)
{
- getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
}
else
{
- getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapRole.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
}
}
catch (NamingException e)
{
throw new IdentityException("Failed to change Role members", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -365,6 +392,7 @@
memberName = ldapUser.getUserName();
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -402,7 +430,7 @@
Attributes newAttrs = new BasicAttributes(true);
//newAttrs.put(getMemberAttributeID(), attr);
newAttrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+ ldapContext.modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
}
else
{
@@ -424,7 +452,7 @@
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute(getMemberAttributeID(), memberName));
// Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, mods);
+ ldapContext.modifyAttributes(roleDN, mods);
}
//and that should be all...
@@ -433,8 +461,20 @@
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
}
public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
@@ -477,5 +517,5 @@
}
-
+
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -38,6 +38,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@@ -87,6 +88,8 @@
Set roles = new HashSet();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoles(): role = " + ldapUser.getDn());
@@ -97,7 +100,7 @@
}
//obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
//log.debug("User attributes: " + attrs);
if (attrs == null )
@@ -143,6 +146,17 @@
{
throw new IdentityException("Resolving User Roles failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return roles;
@@ -286,6 +300,7 @@
memberOfName = ldapRole.getName();
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -318,7 +333,7 @@
//newAttrs.put(getMemberAttributeID(), attr);
newAttrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+ ldapContext.modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
//and mark this role as done
userDNsToAdd.remove(userDN);
@@ -335,7 +350,7 @@
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute(getMemberAttributeID(), memberOfName));
// Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(userDN, mods);
+ ldapContext.modifyAttributes(userDN, mods);
}
//and that should be all...
@@ -344,6 +359,18 @@
{
throw new IdentityException("Failed to assign users", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
}
public void assignRoles(User user, Set roles) throws IdentityException
@@ -376,6 +403,8 @@
throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoles(): user = " + ldapUser.getDn());
@@ -410,12 +439,23 @@
}
attrs.put(member);
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
}
catch (NamingException e)
{
throw new IdentityException("Failed to change Role members", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModule.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModule.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModule.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -84,6 +84,8 @@
{
String attributeName = getPasswordAttributeId();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//TODO: maybe perform a schema check if this attribute is allowed for such entry
@@ -93,12 +95,23 @@
attr.add(password);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapu.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapu.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set user password value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -160,7 +173,7 @@
//ldapu = new LDAPUserImpl(dn,getIdentityContext(), uida.get().toString());
- //make DN as user ID
+ //make DN as user ID
ldapu = new LDAPUserImpl(dn,getIdentityContext(), dn);
ldapu.setUserName(uida.get().toString());
@@ -183,6 +196,8 @@
*/
public User findUserByDN(String dn) throws IdentityException, IllegalArgumentException, NoSuchUserException
{
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUserByDN(): DN = " + dn);
@@ -192,7 +207,7 @@
throw new IdentityException("User dn canot be null");
}
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+ Attributes attrs = ldapContext.getAttributes(dn);
if (attrs == null)
{
@@ -210,6 +225,17 @@
{
throw new IdentityException("User search failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return null;
}
@@ -223,8 +249,8 @@
* @return
*/
public abstract List searchUsers(String filter, Object[] filterArgs) throws NamingException, IdentityException;
-
+
//**************************
//*** Getter and Setters
//**************************
@@ -384,5 +410,5 @@
{
this.connectionContext = connectionContext;
}
-
+
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -37,6 +37,7 @@
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -58,7 +59,7 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public class LDAPUserModuleImpl extends LDAPUserModule
+public class LDAPUserModuleImpl extends LDAPUserModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModuleImpl.class);
@@ -121,9 +122,9 @@
return findUserByDN(id);
}
-
-
+
+
public User createUser(String userName, String password) throws IdentityException, IllegalArgumentException
{
@@ -143,10 +144,12 @@
log.debug("Creating user: " + userName);
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+ LdapContext ctx = (LdapContext)ldapContext.lookup(getContainerDN());
//We store new entry using set of attributes. This should give more flexibility then
//extending user object from ContextDir - configure what objectClass place there
@@ -187,6 +190,17 @@
{
throw new IdentityException("Failed to create user", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
User u = findUserByUserName(userName);
@@ -212,17 +226,30 @@
throw new IdentityException("Cannot obtain DN of user");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- LdapContext ctx = getConnectionContext().createInitialContext();//.lookup(getContainerDN());
log.debug("removing entry: " + ldapu.getDn());
- ctx.unbind(ldapu.getDn());
+ ldapContext.unbind(ldapu.getDn());
}
catch (Exception e)
{
throw new IdentityException("Failed to remove user: ", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
//user was successfull removed so fire events
fireUserDestroyedEvent(id, userName);
}
@@ -349,16 +376,25 @@
log.debug("Search filter: " + filter);
- Enumeration results = null;
- if (filterArgs == null)
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
+ try
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
- return Tools.toList(results);
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(getContainerDN(), filter, controls);
+ return Tools.toList(results);
+ }
+ else
+ {
+ results = ldapContext.search(getContainerDN(), filter, filterArgs, controls);
+ return Tools.toList(results);
+ }
}
- else
+ finally
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, filterArgs, controls);
- return Tools.toList(results);
+ ldapContext.close();
}
}
Modified: modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
===================================================================
--- modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/main/java/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2007-11-21 09:54:32 UTC (rev 9055)
@@ -37,6 +37,7 @@
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.DirContext;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
@@ -97,9 +98,11 @@
return null;
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
Attribute attr = attrs.get(attributeName);
@@ -116,6 +119,17 @@
{
throw new IdentityException("Cannot get user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
@@ -188,6 +202,8 @@
return;
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//TODO: maybe perform a schema check if this attribute is allowed for such entry
@@ -197,12 +213,23 @@
attr.add(property);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -238,13 +265,15 @@
Map propertyMap = new HashMap();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
Map mappings = resolveAttributesMappingMap();
Set props = mappings.keySet();
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
for (Iterator iterator = props.iterator(); iterator.hasNext();)
{
@@ -272,6 +301,17 @@
{
throw new IdentityException("Cannot get user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return Collections.unmodifiableMap(propertyMap);
}
@@ -296,7 +336,7 @@
}
/**
- * Returns a map of mappings - property name/attribute name.
+ * Returns a map of mappings - property name/attribute name.
* @return
* @throws IdentityException
*/
Modified: modules/identity/trunk/identity/src/test/resources/config/standardidentity-config.xml
===================================================================
--- modules/identity/trunk/identity/src/test/resources/config/standardidentity-config.xml 2007-11-21 09:51:36 UTC (rev 9054)
+++ modules/identity/trunk/identity/src/test/resources/config/standardidentity-config.xml 2007-11-21 09:54:32 UTC (rev 9055)
@@ -59,6 +59,18 @@
<name>JNDIName</name>
<value>java:/portal/LDAPConnectionContext</value>
</option>
+ <option>
+ <name>pooling</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>poolingProtocol</name>
+ <value>plain ssl</value>
+ </option>
+ <option>
+ <name>poolingTimeout</name>
+ <value>300000</value>
+ </option>
</config>
</datasource>
</datasources>
16 years, 7 months
JBoss Portal SVN: r9054 - in modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src: resources/test/config and 1 other directory.
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2007-11-21 04:51:36 -0500 (Wed, 21 Nov 2007)
New Revision: 9054
Modified:
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/resources/test/config/standardidentity-config.xml
Log:
LDAP connection pooling
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -31,6 +31,7 @@
import javax.naming.NamingException;
import javax.naming.InitialContext;
import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
import java.util.Hashtable;
/**
@@ -43,13 +44,32 @@
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+ public final static String CONNECTION_POOL = "com.sun.jndi.ldap.connect.pool";
+ public final static String CONNECTION_POOL_DEBUG = "com.sun.jndi.ldap.connect.pool.debug";
+ public final static String CONNECTION_POOL_INITSIZE = "com.sun.jndi.ldap.connect.pool.initsize";
+ public final static String CONNECTION_POOL_MAXSIZE = "com.sun.jndi.ldap.connect.pool.maxsize";
+ public final static String CONNECTION_POOL_PREFSIZE = "com.sun.jndi.ldap.connect.pool.prefsize";
+ public final static String CONNECTION_POOL_PROTOCOL = "com.sun.jndi.ldap.connect.pool.protocol";
+ public final static String CONNECTION_POOL_TIMEOUT = "com.sun.jndi.ldap.connect.pool.timeout";
+
+ private boolean pooling;
+
+ private String poolingDebug;
+
+ private String poolingInitsize;
+
+ private String poolingMaxsize;
+
+ private String poolingPrefsize;
+
+ private String poolingProtocol;
+
+ private String poolingTimeout;
+
private String jndiName;
private ServiceJNDIBinder jndiBinder;
- //private JNDI.Binding jndiBinding;
-
-
private String name;
private String contextFactory;
@@ -79,10 +99,41 @@
env.put(Context.SECURITY_AUTHENTICATION, this.getAuthentication());
env.put(Context.SECURITY_PRINCIPAL, this.getAdminDN());
env.put(Context.SECURITY_CREDENTIALS, this.getAdminPassword());
+
if (this.getProtocol() != null)
{
env.put(Context.SECURITY_PROTOCOL, this.getProtocol());
}
+
+ if (isPooling())
+ {
+ env.put(CONNECTION_POOL, "true");
+ if (getPoolingDebug() != null)
+ {
+ env.put(CONNECTION_POOL_DEBUG, getPoolingDebug());
+ }
+ if (getPoolingInitsize() != null)
+ {
+ env.put(CONNECTION_POOL_INITSIZE, getPoolingInitsize());
+ }
+ if (getPoolingMaxsize() != null)
+ {
+ env.put(CONNECTION_POOL_MAXSIZE, getPoolingMaxsize());
+ }
+ if (getPoolingPrefsize() != null)
+ {
+ env.put(CONNECTION_POOL_PREFSIZE, getPoolingPrefsize());
+ }
+ if (getPoolingProtocol() != null)
+ {
+ env.put(CONNECTION_POOL_PROTOCOL, getPoolingProtocol());
+ }
+ if (getPoolingTimeout() != null)
+ {
+ env.put(CONNECTION_POOL_TIMEOUT, getPoolingTimeout());
+ }
+ }
+
return env;
}
@@ -288,4 +339,74 @@
{
this.identityContext = identityContext;
}
+
+ public boolean isPooling()
+ {
+ return pooling;
+ }
+
+ public void setPooling(boolean pooling)
+ {
+ this.pooling = pooling;
+ }
+
+ public String getPoolingDebug()
+ {
+ return poolingDebug;
+ }
+
+ public void setPoolingDebug(String poolingDebug)
+ {
+ this.poolingDebug = poolingDebug;
+ }
+
+ public String getPoolingInitsize()
+ {
+ return poolingInitsize;
+ }
+
+ public void setPoolingInitsize(String poolingInitsize)
+ {
+ this.poolingInitsize = poolingInitsize;
+ }
+
+ public String getPoolingMaxsize()
+ {
+ return poolingMaxsize;
+ }
+
+ public void setPoolingMaxsize(String poolingMaxsize)
+ {
+ this.poolingMaxsize = poolingMaxsize;
+ }
+
+ public String getPoolingPrefsize()
+ {
+ return poolingPrefsize;
+ }
+
+ public void setPoolingPrefsize(String poolingPrefsize)
+ {
+ this.poolingPrefsize = poolingPrefsize;
+ }
+
+ public String getPoolingProtocol()
+ {
+ return poolingProtocol;
+ }
+
+ public void setPoolingProtocol(String poolingProtocol)
+ {
+ this.poolingProtocol = poolingProtocol;
+ }
+
+ public String getPoolingTimeout()
+ {
+ return poolingTimeout;
+ }
+
+ public void setPoolingTimeout(String poolingTimeout)
+ {
+ this.poolingTimeout = poolingTimeout;
+ }
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -29,6 +29,7 @@
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.directory.DirContext;
@@ -208,63 +209,73 @@
*/
public List searchRoles(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(getSearchScope());
- controls.setReturningObjFlag(true);
- controls.setTimeLimit(getSearchTimeLimit());
- //
- filter = filter.replaceAll("\\\\", "\\\\\\\\");
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
- log.debug("Search filter: " + filter);
- if (log.isDebugEnabled() && filterArgs != null)
+ try
{
- for (int i = 0; i < filterArgs.length; i++)
- {
- Object filterArg = filterArgs[i];
- log.debug("Search filterArg: {" + i + "}: " + filterArg);
- }
- }
- log.debug("Search ctx: " + getRoleSearchCtxDNs());
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(getSearchScope());
+ controls.setReturningObjFlag(true);
+ controls.setTimeLimit(getSearchTimeLimit());
- Set roleCtxs = getRoleSearchCtxDNs();
+ //
+ filter = filter.replaceAll("\\\\", "\\\\\\\\");
- if (roleCtxs.size() == 1)
- {
- Enumeration results = null;
- if (filterArgs == null)
+ log.debug("Search filter: " + filter);
+ if (log.isDebugEnabled() && filterArgs != null)
{
- results = getConnectionContext().createInitialContext().search(getRoleCtxDN(), filter, controls);
+ for (int i = 0; i < filterArgs.length; i++)
+ {
+ Object filterArg = filterArgs[i];
+ log.debug("Search filterArg: {" + i + "}: " + filterArg);
+ }
}
- else
- {
- results = getConnectionContext().createInitialContext().search(getRoleCtxDN(), filter, filterArgs, controls);
- }
- return Tools.toList(results);
+ log.debug("Search ctx: " + getRoleSearchCtxDNs());
+ Set roleCtxs = getRoleSearchCtxDNs();
- }
- else
- {
- List merged = new LinkedList();
-
- for (Iterator iterator = roleCtxs.iterator(); iterator.hasNext();)
+ if (roleCtxs.size() == 1)
{
- String roleCtx = (String)iterator.next();
Enumeration results = null;
if (filterArgs == null)
{
- results = getConnectionContext().createInitialContext().search(roleCtx, filter, controls);
+ results = ldapContext.search(getRoleCtxDN(), filter, controls);
}
else
{
- results = getConnectionContext().createInitialContext().search(roleCtx, filter, filterArgs, controls);
+ results = ldapContext.search(getRoleCtxDN(), filter, filterArgs, controls);
}
- merged.addAll(Tools.toList(results));
+ return Tools.toList(results);
+
+
}
+ else
+ {
+ List merged = new LinkedList();
- return merged;
+ for (Iterator iterator = roleCtxs.iterator(); iterator.hasNext();)
+ {
+ String roleCtx = (String)iterator.next();
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(roleCtx, filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(roleCtx, filter, filterArgs, controls);
+ }
+ merged.addAll(Tools.toList(results));
+ }
+
+ return merged;
+ }
}
+ finally
+ {
+ ldapContext.close();
+ }
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -22,25 +22,25 @@
******************************************************************************/
package org.jboss.portal.identity.ldap;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.IdentityConfiguration;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.IdentityConfiguration;
-import org.jboss.portal.common.util.Tools;
-import javax.naming.NamingEnumeration;
import javax.naming.Context;
import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
-import javax.naming.directory.SearchControls;
-import java.util.Set;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.HashSet;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
@@ -218,60 +218,70 @@
*/
public List searchUsers(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- controls.setReturningObjFlag(true);
- controls.setTimeLimit(getSearchTimeLimit());
- log.debug("Search filter: " + filter);
- if (log.isDebugEnabled() && filterArgs != null)
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
+ try
{
- for (int i = 0; i < filterArgs.length; i++)
- {
- Object filterArg = filterArgs[i];
- log.debug("Search filterArg: {" + i + "}: " + filterArg);
- }
- }
- log.debug("Search ctx: " + getUserSearchCtxDNs());
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ controls.setReturningObjFlag(true);
+ controls.setTimeLimit(getSearchTimeLimit());
- Set userCtxs = getUserSearchCtxDNs();
-
- if (userCtxs.size() == 1)
- {
- Enumeration results = null;
- if (filterArgs == null)
+ log.debug("Search filter: " + filter);
+ if (log.isDebugEnabled() && filterArgs != null)
{
- results = getConnectionContext().createInitialContext().search(getUserSearchCtxDN(), filter, controls);
+ for (int i = 0; i < filterArgs.length; i++)
+ {
+ Object filterArg = filterArgs[i];
+ log.debug("Search filterArg: {" + i + "}: " + filterArg);
+ }
}
- else
- {
- results = getConnectionContext().createInitialContext().search(getUserSearchCtxDN(), filter, filterArgs, controls);
- }
- return Tools.toList(results);
+ log.debug("Search ctx: " + getUserSearchCtxDNs());
+ Set userCtxs = getUserSearchCtxDNs();
- }
- else
- {
- List merged = new LinkedList();
-
- for (Iterator iterator = userCtxs.iterator(); iterator.hasNext();)
+ if (userCtxs.size() == 1)
{
- String userCtx = (String)iterator.next();
Enumeration results = null;
if (filterArgs == null)
{
- results = getConnectionContext().createInitialContext().search(userCtx, filter, controls);
+ results = ldapContext.search(getUserSearchCtxDN(), filter, controls);
}
else
{
- results = getConnectionContext().createInitialContext().search(userCtx, filter, filterArgs, controls);
+ results = ldapContext.search(getUserSearchCtxDN(), filter, filterArgs, controls);
}
- merged.addAll(Tools.toList(results));
+ return Tools.toList(results);
+
+
}
+ else
+ {
+ List merged = new LinkedList();
- return merged;
+ for (Iterator iterator = userCtxs.iterator(); iterator.hasNext();)
+ {
+ String userCtx = (String)iterator.next();
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(userCtx, filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(userCtx, filter, filterArgs, controls);
+ }
+ merged.addAll(Tools.toList(results));
+ }
+
+ return merged;
+ }
}
+ finally
+ {
+ ldapContext.close();
+ }
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -35,6 +35,7 @@
import javax.naming.NamingException;
import javax.naming.NamingEnumeration;
import javax.naming.InitialContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.NoSuchElementException;
import java.util.List;
@@ -71,6 +72,7 @@
public void updateDisplayName(LDAPRoleImpl ldapr, String name) throws IdentityException
{
String attributeName = getDisplayNameAttributeID();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -81,12 +83,23 @@
attr.add(name);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapr.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapr.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set role displayName value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -136,6 +149,9 @@
*/
public Role findRoleByDN(String dn) throws IdentityException, IllegalArgumentException
{
+
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoleByDN(): DN = " + dn);
@@ -145,8 +161,9 @@
throw new IdentityException("Role dn canot be null");
}
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+ Attributes attrs = ldapContext.getAttributes(dn);
+
if (attrs == null)
{
throw new IdentityException("Can't find role entry with DN: " + dn);
@@ -163,6 +180,18 @@
{
throw new IdentityException("Role search failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
return null;
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -40,6 +40,7 @@
import javax.naming.directory.SearchResult;
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -159,10 +160,12 @@
throw new IdentityException("Role name cannot be null");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+ LdapContext ctx = (LdapContext)ldapContext.lookup(getContainerDN());
//We store new entry using set of attributes. This should give more flexibility then
//extending user object from ContextDir - configure what objectClass place there
@@ -207,6 +210,17 @@
{
throw new IdentityException("Failed to create role", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return findRoleByName(name);
}
@@ -226,16 +240,28 @@
throw new IdentityException("Cannot obtain DN of role");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext();//.lookup(getContainerDN());
log.debug("removing entry: " + ldapr.getDn());
- ctx.unbind(ldapr.getDn());
+ ldapContext.unbind(ldapr.getDn());
}
catch (Exception e)
{
throw new IdentityException("Failed to remove role: ", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
public int getRolesCount() throws IdentityException
@@ -300,24 +326,34 @@
*/
public List searchRoles(String filter, Object[] filterArgs) throws NamingException, IdentityException
{
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- controls.setReturningObjFlag(true);
- //String filter = getUidAttributeID().concat("=").concat(userName);
- filter = filter.replaceAll("\\\\", "\\\\\\\\");
- log.debug("Search filter: " + filter);
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
- Enumeration results = null;
- if (filterArgs == null)
+ try
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ controls.setReturningObjFlag(true);
+
+ //String filter = getUidAttributeID().concat("=").concat(userName);
+ filter = filter.replaceAll("\\\\", "\\\\\\\\");
+ log.debug("Search filter: " + filter);
+
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(getContainerDN(), filter, controls);
+ }
+ else
+ {
+ results = ldapContext.search(getContainerDN(), filter, filterArgs, controls);
+ }
+ return Tools.toList(results);
}
- else
+ finally
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, filterArgs, controls);
+ ldapContext.close();
}
- return Tools.toList(results);
}
private Map getAttributesToAdd() throws IdentityException
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -39,6 +39,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@@ -155,6 +156,8 @@
Set users = new HashSet();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUsers(): role = " + ldapRole.getDn());
@@ -165,7 +168,7 @@
}
//obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapRole.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapRole.getDn());
//log.debug("Role attributes: " + attrs);
if (attrs == null )
@@ -208,6 +211,17 @@
{
throw new IdentityException("Resolving Role Users failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return users;
@@ -239,6 +253,8 @@
"require the member field to be set). ");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUsers(): role = " + ldapRole.getDn());
@@ -292,17 +308,28 @@
if (users.size() > 0)
{
- getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
}
else
{
- getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapRole.getDn(), DirContext.REMOVE_ATTRIBUTE, attrs);
}
}
catch (NamingException e)
{
throw new IdentityException("Failed to change Role members", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -365,6 +392,7 @@
memberName = ldapUser.getUserName();
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -402,7 +430,7 @@
Attributes newAttrs = new BasicAttributes(true);
//newAttrs.put(getMemberAttributeID(), attr);
newAttrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+ ldapContext.modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
}
else
{
@@ -424,7 +452,7 @@
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute(getMemberAttributeID(), memberName));
// Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, mods);
+ ldapContext.modifyAttributes(roleDN, mods);
}
//and that should be all...
@@ -433,8 +461,20 @@
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
}
public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -38,6 +38,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
@@ -87,6 +88,8 @@
Set roles = new HashSet();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoles(): role = " + ldapUser.getDn());
@@ -97,7 +100,7 @@
}
//obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
//log.debug("User attributes: " + attrs);
if (attrs == null )
@@ -143,6 +146,17 @@
{
throw new IdentityException("Resolving User Roles failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return roles;
@@ -286,6 +300,7 @@
memberOfName = ldapRole.getName();
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
try
{
@@ -318,7 +333,7 @@
//newAttrs.put(getMemberAttributeID(), attr);
newAttrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+ ldapContext.modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
//and mark this role as done
userDNsToAdd.remove(userDN);
@@ -335,7 +350,7 @@
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute(getMemberAttributeID(), memberOfName));
// Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(userDN, mods);
+ ldapContext.modifyAttributes(userDN, mods);
}
//and that should be all...
@@ -344,6 +359,18 @@
{
throw new IdentityException("Failed to assign users", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
}
public void assignRoles(User user, Set roles) throws IdentityException
@@ -376,6 +403,8 @@
throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findRoles(): user = " + ldapUser.getDn());
@@ -410,12 +439,23 @@
}
attrs.put(member);
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ ldapContext.modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
}
catch (NamingException e)
{
throw new IdentityException("Failed to change Role members", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -84,6 +84,8 @@
{
String attributeName = getPasswordAttributeId();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//TODO: maybe perform a schema check if this attribute is allowed for such entry
@@ -93,12 +95,23 @@
attr.add(password);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapu.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapu.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set user password value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -183,6 +196,8 @@
*/
public User findUserByDN(String dn) throws IdentityException, IllegalArgumentException, NoSuchUserException
{
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
log.debug("findUserByDN(): DN = " + dn);
@@ -192,7 +207,7 @@
throw new IdentityException("User dn canot be null");
}
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+ Attributes attrs = ldapContext.getAttributes(dn);
if (attrs == null)
{
@@ -210,6 +225,17 @@
{
throw new IdentityException("User search failed.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return null;
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -37,6 +37,7 @@
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.InitialLdapContext;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -143,10 +144,12 @@
log.debug("Creating user: " + userName);
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+ LdapContext ctx = (LdapContext)ldapContext.lookup(getContainerDN());
//We store new entry using set of attributes. This should give more flexibility then
//extending user object from ContextDir - configure what objectClass place there
@@ -187,6 +190,17 @@
{
throw new IdentityException("Failed to create user", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
User u = findUserByUserName(userName);
@@ -212,17 +226,30 @@
throw new IdentityException("Cannot obtain DN of user");
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- LdapContext ctx = getConnectionContext().createInitialContext();//.lookup(getContainerDN());
log.debug("removing entry: " + ldapu.getDn());
- ctx.unbind(ldapu.getDn());
+ ldapContext.unbind(ldapu.getDn());
}
catch (Exception e)
{
throw new IdentityException("Failed to remove user: ", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
+
//user was successfull removed so fire events
fireUserDestroyedEvent(id, userName);
}
@@ -349,16 +376,25 @@
log.debug("Search filter: " + filter);
- Enumeration results = null;
- if (filterArgs == null)
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
+ try
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
- return Tools.toList(results);
+ Enumeration results = null;
+ if (filterArgs == null)
+ {
+ results = ldapContext.search(getContainerDN(), filter, controls);
+ return Tools.toList(results);
+ }
+ else
+ {
+ results = ldapContext.search(getContainerDN(), filter, filterArgs, controls);
+ return Tools.toList(results);
+ }
}
- else
+ finally
{
- results = getConnectionContext().createInitialContext().search(getContainerDN(), filter, filterArgs, controls);
- return Tools.toList(results);
+ ldapContext.close();
}
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2007-11-21 09:51:36 UTC (rev 9054)
@@ -37,6 +37,7 @@
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.DirContext;
import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
@@ -97,9 +98,11 @@
return null;
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
Attribute attr = attrs.get(attributeName);
@@ -116,6 +119,17 @@
{
throw new IdentityException("Cannot get user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
@@ -188,6 +202,8 @@
return;
}
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
//TODO: maybe perform a schema check if this attribute is allowed for such entry
@@ -197,12 +213,23 @@
attr.add(property);
attrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ ldapContext.modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot set user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
}
@@ -238,13 +265,15 @@
Map propertyMap = new HashMap();
+ InitialLdapContext ldapContext = getConnectionContext().createInitialContext();
+
try
{
Map mappings = resolveAttributesMappingMap();
Set props = mappings.keySet();
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+ Attributes attrs = ldapContext.getAttributes(ldapUser.getDn());
for (Iterator iterator = props.iterator(); iterator.hasNext();)
{
@@ -272,6 +301,17 @@
{
throw new IdentityException("Cannot get user property value.", e);
}
+ finally
+ {
+ try
+ {
+ ldapContext.close();
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to close LDAP connection", e);
+ }
+ }
return Collections.unmodifiableMap(propertyMap);
}
Modified: modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/resources/test/config/standardidentity-config.xml
===================================================================
--- modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/resources/test/config/standardidentity-config.xml 2007-11-20 22:02:54 UTC (rev 9053)
+++ modules/identity/branches/JBP_IDENTITY_BRANCH_1_0_0/identity/src/resources/test/config/standardidentity-config.xml 2007-11-21 09:51:36 UTC (rev 9054)
@@ -59,6 +59,18 @@
<name>jNDIName</name>
<value>java:/portal/LDAPConnectionContext</value>
</option>
+ <option>
+ <name>pooling</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>poolingProtocol</name>
+ <value>plain ssl</value>
+ </option>
+ <option>
+ <name>poolingTimeout</name>
+ <value>300000</value>
+ </option>
</config>
</datasource>
</datasources>
16 years, 7 months
JBoss Portal SVN: r9053 - in branches/presentation: core-presentation/src/main/org/jboss/portal/core/presentation/server/content/portlet and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-20 17:02:54 -0500 (Tue, 20 Nov 2007)
New Revision: 9053
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java
Log:
- basic support for URL encoding
Modified: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-20 21:37:13 UTC (rev 9052)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/MainProcessor.java 2007-11-20 22:02:54 UTC (rev 9053)
@@ -48,6 +48,7 @@
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.protocol.ErrorResponse;
import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.protocol.ServerAction;
import org.jboss.portal.presentation.protocol.ServerResponse;
import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
@@ -56,7 +57,10 @@
import org.jboss.portal.presentation.server.ProcessorRequest;
import org.jboss.portal.presentation.server.ProcessorResponse;
import org.jboss.portal.server.ServerException;
+import org.jboss.portal.web.Body;
+import java.util.Map;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
@@ -168,8 +172,21 @@
PortalObjectId poid = PortalObjectId.parse(id, PortalObjectPath.CANONICAL_FORMAT);
Window window = (Window)portalObjectContainer.getObject(poid);
PortletRequestDecoder decoder = new PortletRequestDecoder();
- decoder.decode(getActivation.getQueryParameters(), null);
+ // Get form parameters if any
+ Map formParameters = null;
+ if (serverAction instanceof PostActivation)
+ {
+ PostActivation post = (PostActivation)serverAction;
+ Body body = post.getBody();
+ if (body instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)body).getParameters();
+ }
+ }
+
+ decoder.decode(getActivation.getQueryParameters(), formParameters);
+
// We assume that for now
UIWindow uiWindow = (UIWindow)presentationContext.getUIContext().getObject(id);
Modified: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java 2007-11-20 21:37:13 UTC (rev 9052)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/content/portlet/PresentationPortletInvocationContext.java 2007-11-20 22:02:54 UTC (rev 9053)
@@ -96,7 +96,8 @@
public String encodeResourceURL(String url) throws IllegalArgumentException
{
- return "todo";
+ // Todo improve that
+ return url;
}
public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-20 21:37:13 UTC (rev 9052)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-20 22:02:54 UTC (rev 9053)
@@ -22,35 +22,35 @@
******************************************************************************/
package org.jboss.portal.presentation.client.controller;
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.jboss.portal.presentation.client.PresentationContext;
-import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
import org.jboss.portal.presentation.impl.PresentationContextImpl;
-import org.jboss.portal.presentation.server.ProcessorRequest;
-import org.jboss.portal.presentation.server.ProcessorResponse;
-import org.jboss.portal.presentation.server.PresentationServer;
-import org.jboss.portal.presentation.protocol.ServerAction;
-import org.jboss.portal.presentation.protocol.ServerResponse;
-import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
-import org.jboss.portal.presentation.protocol.GetActivation;
-import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.model.content.WindowContent;
-
+import org.jboss.portal.presentation.protocol.GetActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
+import org.jboss.portal.presentation.protocol.ServerAction;
+import org.jboss.portal.presentation.protocol.ServerResponse;
+import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.server.PresentationServer;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.impl.ServerInvocationContextImpl;
+import org.jboss.portal.web.WebRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Map;
+
/**
* The UIServer is responsible for generating the output that is sent back to the client based on the Portal state of a particular Portal Request
*
@@ -240,18 +240,19 @@
from = pos + 1;
}
+ // I know but it will go away later when we remove dependency on server module
+ WebRequest webReq = ((ServerInvocationContextImpl)invocation.getContext()).getWebRequest();
+
//
if (target != null)
{
- Map queryParameters = invocationContext.getQueryParameterMap();
- Map bodyParameters = invocationContext.getBodyParameterMap();
- if (bodyParameters != null)
+ if ("GET".equals(webReq.getMethod()))
{
- return new PostActivation(target.getId(), queryParameters, bodyParameters);
+ return new GetActivation(target.getId(), webReq.getQueryParameterMap());
}
- else
+ else if ("POST".equals(webReq.getMethod()))
{
- return new GetActivation(target.getId(), queryParameters);
+ return new PostActivation(target.getId(), webReq.getQueryParameterMap(), webReq.getBody());
}
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java 2007-11-20 21:37:13 UTC (rev 9052)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/protocol/PostActivation.java 2007-11-20 22:02:54 UTC (rev 9053)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.protocol;
-import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.web.Body;
import java.util.Map;
@@ -34,22 +34,22 @@
{
/** . */
- private final Map bodyParameters;
+ private final Body body;
- public PostActivation(String targetId, Map queryParameters, Map bodyParameters)
+ public PostActivation(String targetId, Map queryParameters, Body body)
{
super(targetId, queryParameters);
//
- this.bodyParameters = bodyParameters;
+ this.body = body;
}
/**
*
* @return
*/
- public Map getBodyParameters()
+ public Body getBody()
{
- return bodyParameters;
+ return body;
}
}
16 years, 7 months
JBoss Portal SVN: r9052 - in branches/presentation: presentation/src/main/org/jboss/portal/presentation/impl and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-20 16:37:13 -0500 (Tue, 20 Nov 2007)
New Revision: 9052
Modified:
branches/presentation/core-presentation/build.xml
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
Log:
- fix build
- make PresentationContextImpl use the DefaultServletContainerFactory instance
Modified: branches/presentation/core-presentation/build.xml
===================================================================
--- branches/presentation/core-presentation/build.xml 2007-11-20 21:36:18 UTC (rev 9051)
+++ branches/presentation/core-presentation/build.xml 2007-11-20 21:37:13 UTC (rev 9052)
@@ -87,7 +87,7 @@
<property name="jboss.portal-presentation.lib" value="../presentation/output/lib"/>
<path id="jboss.portal-presentation.classpath">
- <fileset dir="{jboss.portal-presentation.lib}" includes="portal-presentation-lib.jar"/>
+ <pathelement location="../presentation/output/lib/portal-presentation-lib.jar"/>
</path>
<!-- Configure thirdparty libraries -->
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-20 21:36:18 UTC (rev 9051)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-20 21:37:13 UTC (rev 9052)
@@ -90,8 +90,7 @@
*/
public ServletContextDispatcher getDispatcher()
{
- DefaultServletContainerFactory factory = new DefaultServletContainerFactory();
- ServletContainer container = factory.getServletContainer();
+ ServletContainer container = DefaultServletContainerFactory.getInstance().getServletContainer();
return new ServletContextDispatcher(
invocation.getServerContext().getClientRequest(),
invocation.getServerContext().getClientResponse(),
16 years, 7 months
JBoss Portal SVN: r9051 - branches/JBoss_Portal_Branch_2_6/server/src/main/org/jboss/portal/web/jboss.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-20 16:36:18 -0500 (Tue, 20 Nov 2007)
New Revision: 9051
Modified:
branches/JBoss_Portal_Branch_2_6/server/src/main/org/jboss/portal/web/jboss/JBossWebContext.java
Log:
- make JBossWebContext delegate the registration to the DefaultServletContainerFactory so it can be easily located from anywhere else
Modified: branches/JBoss_Portal_Branch_2_6/server/src/main/org/jboss/portal/web/jboss/JBossWebContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/server/src/main/org/jboss/portal/web/jboss/JBossWebContext.java 2007-11-20 21:26:47 UTC (rev 9050)
+++ branches/JBoss_Portal_Branch_2_6/server/src/main/org/jboss/portal/web/jboss/JBossWebContext.java 2007-11-20 21:36:18 UTC (rev 9051)
@@ -25,6 +25,7 @@
import org.jboss.portal.web.RequestDispatchCallback;
import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.ServletContainerFactory;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
import org.jboss.portal.web.command.CommandDispatcher;
import org.jboss.portal.web.spi.ServletContainerContext;
@@ -35,7 +36,8 @@
import java.io.IOException;
/**
- * JBossWeb implementation of the spi.
+ * JBossWeb implementation of the spi. It implements the <code>ServletContainerFactory</code> interface
+ * but it get the returned instance from the DefaultServletContainerFactory instance.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -47,9 +49,8 @@
private final CommandDispatcher dispatcher = new CommandDispatcher();
/** . */
- private final ServletContainer servletContainer = new ServletContainer();
+ private final ServletContainer servletContainer = DefaultServletContainerFactory.getInstance().getServletContainer();
-
public JBossWebContext()
{
servletContainer.register(this);
16 years, 7 months
JBoss Portal SVN: r9050 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-11-20 16:26:47 -0500 (Tue, 20 Nov 2007)
New Revision: 9050
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
Log:
- Updated to use latest version of P3PConstants.
Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2007-11-20 21:02:47 UTC (rev 9049)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java 2007-11-20 21:26:47 UTC (rev 9050)
@@ -23,7 +23,7 @@
package org.jboss.portal.wsrp;
-import org.jboss.portal.common.p3p.P3PConstants;
+import static org.jboss.portal.common.p3p.P3PConstants.*;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.wsrp.core.Contact;
import org.jboss.portal.wsrp.core.EmployerInfo;
@@ -78,68 +78,63 @@
PersonName name = createNameFrom(userInfos);
Calendar bdate = null;
- String bdateAsString = (String)userInfos.get(P3PConstants.INFO_USER_BDATE);
+ String bdateAsString = (String)userInfos.get(INFO_USER_BDATE);
if (bdateAsString != null)
{
bdate = SimpleTypeBindings.unmarshalDateTime(bdateAsString);
}
- EmployerInfo employerInfo = new EmployerInfo((String)userInfos.get(P3PConstants.INFO_USER_EMPLOYER),
- (String)userInfos.get(P3PConstants.INFO_USER_DEPARTMENT),
- (String)userInfos.get(P3PConstants.INFO_USER_JOB_TITLE), null);
+ EmployerInfo employerInfo = new EmployerInfo((String)userInfos.get(INFO_USER_EMPLOYER),
+ (String)userInfos.get(INFO_USER_DEPARTMENT),
+ (String)userInfos.get(INFO_USER_JOB_TITLE), null);
- return new UserProfile(name, bdate, (String)userInfos.get(P3PConstants.INFO_USER_GENDER), employerInfo,
+ return new UserProfile(name, bdate, (String)userInfos.get(INFO_USER_GENDER), employerInfo,
createContactFrom(userInfos, false), createContactFrom(userInfos, true), null);
}
private static PersonName createNameFrom(Map userInfos)
{
return new PersonName(
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_PREFIX),
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_GIVEN),
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_FAMILY),
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_MIDDLE),
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_SUFFIX),
- (String)userInfos.get(P3PConstants.INFO_USER_NAME_NICKNAME), null);
+ (String)userInfos.get(INFO_USER_NAME_PREFIX),
+ (String)userInfos.get(INFO_USER_NAME_GIVEN),
+ (String)userInfos.get(INFO_USER_NAME_FAMILY),
+ (String)userInfos.get(INFO_USER_NAME_MIDDLE),
+ (String)userInfos.get(INFO_USER_NAME_SUFFIX),
+ (String)userInfos.get(INFO_USER_NAME_NICKNAME), null);
}
private static Contact createContactFrom(Map infos, boolean isBusiness)
{
- String key = getHomeOrBusinessPrefix(isBusiness);
+ Online online = new Online((String)infos.get(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness)),
+ (String)infos.get(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness)), null);
- Online online = new Online((String)infos.get(key + P3PConstants.ONLINE_EMAIL),
- (String)infos.get(key + P3PConstants.ONLINE_URI), null);
-
Postal postal = new Postal(
- (String)infos.get(key + P3PConstants.POSTAL_NAME),
- (String)infos.get(key + P3PConstants.POSTAL_STREET),
- (String)infos.get(key + P3PConstants.POSTAL_CITY),
- (String)infos.get(key + P3PConstants.POSTAL_STATEPROV),
- (String)infos.get(key + P3PConstants.POSTAL_POSTALCODE),
- (String)infos.get(key + P3PConstants.POSTAL_COUNTRY),
- (String)infos.get(key + P3PConstants.POSTAL_ORGANIZATION), null);
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.NAME, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.STREET, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.CITY, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.STATEPROV, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.POSTALCODE, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.COUNTRY, isBusiness)),
+ (String)infos.get(getPostalUserInfoKey(PostalInfo.ORGANIZATION, isBusiness)), null);
- Telecom telecom = new Telecom(createTelephoneNumFrom(infos, P3PConstants.TELECOM_TELEPHONE, isBusiness),
- createTelephoneNumFrom(infos, P3PConstants.TELECOM_FAX, isBusiness),
- createTelephoneNumFrom(infos, P3PConstants.TELECOM_MOBILE, isBusiness),
- createTelephoneNumFrom(infos, P3PConstants.TELECOM_PAGER, isBusiness), null);
+ Telecom telecom = new Telecom(createTelephoneNumFrom(infos, TelecomType.TELEPHONE, isBusiness),
+ createTelephoneNumFrom(infos, TelecomType.FAX, isBusiness),
+ createTelephoneNumFrom(infos, TelecomType.MOBILE, isBusiness),
+ createTelephoneNumFrom(infos, TelecomType.PAGER, isBusiness), null);
return new Contact(postal, telecom, online, null);
}
- private static TelephoneNum createTelephoneNumFrom(Map infos, String prefix, boolean isBusiness)
+ private static TelephoneNum createTelephoneNumFrom(Map infos, TelecomType type, boolean isBusiness)
{
- String key = getHomeOrBusinessPrefix(isBusiness) + prefix;
- return new TelephoneNum((String)infos.get(key + P3PConstants.INTCODE),
- (String)infos.get(key + P3PConstants.LOCCODE), (String)infos.get(key + P3PConstants.NUMBER),
- (String)infos.get(key + P3PConstants.EXT), (String)infos.get(key + P3PConstants.COMMENT), null);
+ return new TelephoneNum(
+ (String)infos.get(getTelecomInfoKey(type, TelecomInfo.INTCODE, isBusiness)),
+ (String)infos.get(getTelecomInfoKey(type, TelecomInfo.LOCCODE, isBusiness)),
+ (String)infos.get(getTelecomInfoKey(type, TelecomInfo.NUMBER, isBusiness)),
+ (String)infos.get(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness)),
+ (String)infos.get(getTelecomInfoKey(type, TelecomInfo.COMMENT, isBusiness)), null);
}
- private static String getHomeOrBusinessPrefix(boolean isBusiness)
- {
- return isBusiness ? P3PConstants.INFO_USER_BUSINESS_PREFIX : P3PConstants.INFO_USER_HOME_PREFIX;
- }
-
/**
* Builds a Portal {@link org.jboss.portal.portlet.spi.UserContext} from a WSRP {@link
* org.jboss.portal.wsrp.core.UserContext}.
@@ -167,20 +162,20 @@
Calendar bdate = profile.getBdate();
if (bdate != null)
{
- infos.put(P3PConstants.INFO_USER_BDATE, SimpleTypeBindings.marshalDateTime(bdate));
+ infos.put(INFO_USER_BDATE, SimpleTypeBindings.marshalDateTime(bdate));
}
- infos.put(P3PConstants.INFO_USER_GENDER, profile.getGender());
+ infos.put(INFO_USER_GENDER, profile.getGender());
PersonName name = profile.getName();
if (name != null)
{
- infos.put(P3PConstants.INFO_USER_NAME_FAMILY, name.getFamily());
- infos.put(P3PConstants.INFO_USER_NAME_GIVEN, name.getGiven());
- infos.put(P3PConstants.INFO_USER_NAME_MIDDLE, name.getMiddle());
- infos.put(P3PConstants.INFO_USER_NAME_NICKNAME, name.getNickname());
- infos.put(P3PConstants.INFO_USER_NAME_PREFIX, name.getPrefix());
- infos.put(P3PConstants.INFO_USER_NAME_SUFFIX, name.getSuffix());
+ infos.put(INFO_USER_NAME_FAMILY, name.getFamily());
+ infos.put(INFO_USER_NAME_GIVEN, name.getGiven());
+ infos.put(INFO_USER_NAME_MIDDLE, name.getMiddle());
+ infos.put(INFO_USER_NAME_NICKNAME, name.getNickname());
+ infos.put(INFO_USER_NAME_PREFIX, name.getPrefix());
+ infos.put(INFO_USER_NAME_SUFFIX, name.getSuffix());
}
populateContactInfo(profile.getBusinessInfo(), true);
@@ -190,9 +185,9 @@
EmployerInfo employerInfo = profile.getEmployerInfo();
if (employerInfo != null)
{
- infos.put(P3PConstants.INFO_USER_DEPARTMENT, employerInfo.getDepartment());
- infos.put(P3PConstants.INFO_USER_EMPLOYER, employerInfo.getEmployer());
- infos.put(P3PConstants.INFO_USER_JOB_TITLE, employerInfo.getJobtitle());
+ infos.put(INFO_USER_DEPARTMENT, employerInfo.getDepartment());
+ infos.put(INFO_USER_EMPLOYER, employerInfo.getEmployer());
+ infos.put(INFO_USER_JOB_TITLE, employerInfo.getJobtitle());
}
}
@@ -223,48 +218,45 @@
{
if (contact != null)
{
- String key = getHomeOrBusinessPrefix(isBusiness);
-
Online online = contact.getOnline();
if (online != null)
{
- infos.put(key + P3PConstants.ONLINE_EMAIL, online.getEmail());
- infos.put(key + P3PConstants.ONLINE_URI, online.getUri());
+ infos.put(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness), online.getEmail());
+ infos.put(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness), online.getUri());
}
Postal postal = contact.getPostal();
if (postal != null)
{
- infos.put(key + P3PConstants.POSTAL_CITY, postal.getCity());
- infos.put(key + P3PConstants.POSTAL_COUNTRY, postal.getCountry());
- infos.put(key + P3PConstants.POSTAL_NAME, postal.getName());
- infos.put(key + P3PConstants.POSTAL_ORGANIZATION, postal.getOrganization());
- infos.put(key + P3PConstants.POSTAL_POSTALCODE, postal.getPostalcode());
- infos.put(key + P3PConstants.POSTAL_STATEPROV, postal.getStateprov());
- infos.put(key + P3PConstants.POSTAL_STREET, postal.getStreet());
+ infos.put(getPostalUserInfoKey(PostalInfo.NAME, isBusiness), postal.getName());
+ infos.put(getPostalUserInfoKey(PostalInfo.STREET, isBusiness), postal.getStreet());
+ infos.put(getPostalUserInfoKey(PostalInfo.CITY, isBusiness), postal.getCity());
+ infos.put(getPostalUserInfoKey(PostalInfo.STATEPROV, isBusiness), postal.getStateprov());
+ infos.put(getPostalUserInfoKey(PostalInfo.POSTALCODE, isBusiness), postal.getPostalcode());
+ infos.put(getPostalUserInfoKey(PostalInfo.COUNTRY, isBusiness), postal.getCountry());
+ infos.put(getPostalUserInfoKey(PostalInfo.ORGANIZATION, isBusiness), postal.getOrganization());
}
Telecom telecom = contact.getTelecom();
if (telecom != null)
{
- populateTelephoneInfo(telecom.getFax(), P3PConstants.TELECOM_FAX, isBusiness);
- populateTelephoneInfo(telecom.getMobile(), P3PConstants.TELECOM_MOBILE, isBusiness);
- populateTelephoneInfo(telecom.getPager(), P3PConstants.TELECOM_PAGER, isBusiness);
- populateTelephoneInfo(telecom.getTelephone(), P3PConstants.TELECOM_TELEPHONE, isBusiness);
+ populateTelephoneInfo(telecom.getFax(), TelecomType.FAX, isBusiness);
+ populateTelephoneInfo(telecom.getMobile(), TelecomType.MOBILE, isBusiness);
+ populateTelephoneInfo(telecom.getPager(), TelecomType.PAGER, isBusiness);
+ populateTelephoneInfo(telecom.getTelephone(), TelecomType.TELEPHONE, isBusiness);
}
}
}
- private void populateTelephoneInfo(TelephoneNum telephoneNum, String prefix, boolean isBusiness)
+ private void populateTelephoneInfo(TelephoneNum telephoneNum, TelecomType type, boolean isBusiness)
{
if (telephoneNum != null)
{
- String key = getHomeOrBusinessPrefix(isBusiness) + prefix;
- infos.put(key + P3PConstants.COMMENT, telephoneNum.getComment());
- infos.put(key + P3PConstants.EXT, telephoneNum.getExt());
- infos.put(key + P3PConstants.INTCODE, telephoneNum.getIntcode());
- infos.put(key + P3PConstants.LOCCODE, telephoneNum.getLoccode());
- infos.put(key + P3PConstants.NUMBER, telephoneNum.getNumber());
+ infos.put(getTelecomInfoKey(type, TelecomInfo.INTCODE, isBusiness), telephoneNum.getIntcode());
+ infos.put(getTelecomInfoKey(type, TelecomInfo.LOCCODE, isBusiness), telephoneNum.getLoccode());
+ infos.put(getTelecomInfoKey(type, TelecomInfo.NUMBER, isBusiness), telephoneNum.getNumber());
+ infos.put(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness), telephoneNum.getExt());
+ infos.put(getTelecomInfoKey(type, TelecomInfo.COMMENT, isBusiness), telephoneNum.getComment());
}
}
16 years, 7 months
JBoss Portal SVN: r9049 - modules/common/trunk/common/src/main/java/org/jboss/portal/common/p3p.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-11-20 16:02:47 -0500 (Tue, 20 Nov 2007)
New Revision: 9049
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
Log:
- No need for prefix retrieval to be public.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java 2007-11-20 20:45:50 UTC (rev 9048)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java 2007-11-20 21:02:47 UTC (rev 9049)
@@ -221,7 +221,7 @@
{
}
- public static String getHomeOrBusinessPrefix(boolean isBusiness)
+ private static String getHomeOrBusinessPrefix(boolean isBusiness)
{
return isBusiness ? P3PConstants.INFO_USER_BUSINESS_PREFIX : P3PConstants.INFO_USER_HOME_PREFIX;
}
16 years, 7 months