[exo-jcr-commits] exo-jcr SVN: r209 - in core/trunk/component/security/core/src/main/java/org/exoplatform/services/security: jaas and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Oct 5 06:25:40 EDT 2009
Author: nfilotto
Date: 2009-10-05 06:25:39 -0400 (Mon, 05 Oct 2009)
New Revision: 209
Added:
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/AbstractLoginModule.java
Modified:
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/j2ee/JbossLoginModule.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/DefaultLoginModule.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/IdentitySetLoginModule.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/SharedStateLoginModule.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/ConversationStateListener.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/JAASConversationStateListener.java
core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java
Log:
EXOJCR-166: Support separated ear delivery
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/j2ee/JbossLoginModule.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/j2ee/JbossLoginModule.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/j2ee/JbossLoginModule.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -119,7 +119,7 @@
//
List allPrincipals =
(List)jbossServer.invoke(securityManagerName, "getAuthenticationCachePrincipals",
- new Object[]{"exo-domain"}, new String[]{String.class.getName()});
+ new Object[]{realmName}, new String[]{String.class.getName()});
// Make a copy to avoid some concurrent mods
allPrincipals = new ArrayList(allPrincipals);
@@ -139,7 +139,7 @@
// Perform invalidation
if (key != null)
{
- jbossServer.invoke(securityManagerName, "flushAuthenticationCache", new Object[]{"exo-domain", key},
+ jbossServer.invoke(securityManagerName, "flushAuthenticationCache", new Object[]{realmName, key},
new String[]{String.class.getName(), Principal.class.getName()});
log.debug("Performed JBoss security manager cache eviction for user " + userName + " with principal "
+ key);
Added: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/AbstractLoginModule.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/AbstractLoginModule.java (rev 0)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/AbstractLoginModule.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.security.jaas;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.services.log.Log;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * This class is the root class of all the LoginModules that require an ExoContainer
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto at exoplatform.com
+ * 20 aot 2009
+ */
+public abstract class AbstractLoginModule implements LoginModule
+{
+
+ /**
+ * The name of the option to use in order to specify the name of the portal container
+ */
+ private static final String OPTION_PORTAL_CONTAINER_NAME = "portalContainerName";
+
+ /**
+ * The name of the option to use in order to specify the name of the realm
+ */
+ private static final String OPTION_REALM_NAME = "realmName";
+
+ /**
+ * The name of the portal container.
+ */
+ private String portalContainerName;
+
+ /**
+ * The name of the realm.
+ */
+ protected String realmName;
+
+ /**
+ * @see {@link Subject} .
+ */
+ protected Subject subject;
+
+ /**
+ * @see {@link CallbackHandler}
+ */
+ protected CallbackHandler callbackHandler;
+
+ /**
+ * Shared state.
+ */
+ @SuppressWarnings("unchecked")
+ protected Map sharedState;
+
+ /**
+ * Shared state.
+ */
+ @SuppressWarnings("unchecked")
+ protected Map options;
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public final void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
+ {
+ this.subject = subject;
+ this.callbackHandler = callbackHandler;
+ this.sharedState = sharedState;
+ this.options = options;
+ this.portalContainerName = getPortalContainerName(options);
+ this.realmName = getRealmName(options);
+ }
+
+ /**
+ * Allows sub-classes to do something after the initialization
+ */
+ protected void afterInitialize()
+ {
+ }
+
+ /**
+ * @return actual ExoContainer instance.
+ */
+ protected ExoContainer getContainer() throws Exception
+ {
+ // TODO set correct current container
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ if (container instanceof RootContainer)
+ {
+ container = RootContainer.getInstance().getPortalContainer(portalContainerName);
+ }
+ return container;
+ }
+
+ @SuppressWarnings("unchecked")
+ private String getPortalContainerName(Map options)
+ {
+ if (options != null)
+ {
+ String optionValue = (String)options.get(OPTION_PORTAL_CONTAINER_NAME);
+ if (optionValue != null && optionValue.length() > 0)
+ {
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().debug("The " + this.getClass() + " will use the portal container " + optionValue);
+ }
+ return optionValue;
+ }
+ }
+ return PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME;
+ }
+
+ @SuppressWarnings("unchecked")
+ private String getRealmName(Map options)
+ {
+ if (options != null)
+ {
+ String optionValue = (String)options.get(OPTION_REALM_NAME);
+ if (optionValue != null && optionValue.length() > 0)
+ {
+ if (getLogger().isDebugEnabled())
+ {
+ getLogger().debug("The " + this.getClass() + " will use the realm " + optionValue);
+ }
+ return optionValue;
+ }
+ }
+ return PortalContainer.DEFAULT_REALM_NAME;
+ }
+
+ /**
+ * Returns the Logger corresponding to the Login module
+ */
+ protected abstract Log getLogger();
+}
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/DefaultLoginModule.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/DefaultLoginModule.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/DefaultLoginModule.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -18,9 +18,6 @@
*/
package org.exoplatform.services.security.jaas;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.RootContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.Authenticator;
@@ -30,15 +27,10 @@
import org.exoplatform.services.security.PasswordCredential;
import org.exoplatform.services.security.UsernameCredential;
-import java.util.Map;
-
-import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
/**
* Created by The eXo Platform SAS .
@@ -47,58 +39,26 @@
* @version $Id: $
*/
-public class DefaultLoginModule implements LoginModule
+public class DefaultLoginModule extends AbstractLoginModule
{
/**
- * The name of the option to use in order to specify the name of the portal
- * container
- */
- private static final String OPTION_PORTAL_CONTAINER_NAME = "portalContainerName";
-
- /**
- * The default name of the portal container
- */
- private static final String DEFAULT_PORTAL_CONTAINER_NAME = "portal";
-
- /**
* Logger.
*/
protected Log log = ExoLogger.getLogger("core.DefaultLoginModule");
/**
- * @see {@link Subject} .
- */
- protected Subject subject;
-
- /**
- * @see {@link CallbackHandler}
- */
- private CallbackHandler callbackHandler;
-
- /**
* encapsulates user's principals such as name, groups, etc .
*/
protected Identity identity;
/**
- * Shared state.
+ * Is allowed for one user login again if he already login.
+ * If must set in LM options.
*/
- @SuppressWarnings("unchecked")
- protected Map sharedState;
+ protected boolean singleLogin;
/**
- * The name of the portal container.
- */
- private String portalContainerName;
-
- /**
- * Is allowed for one user login again if he already login. If must set in LM
- * options.
- */
- protected boolean singleLogin = false;
-
- /**
* Default constructor.
*/
public DefaultLoginModule()
@@ -106,21 +66,12 @@
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
+ public void afterInitialize()
{
- this.subject = subject;
- this.callbackHandler = callbackHandler;
- this.sharedState = sharedState;
- this.portalContainerName = getPortalContainerName(options);
-
String sl = (String)options.get("singleLogin");
- if (sl != null && (sl.equalsIgnoreCase("yes") || sl.equalsIgnoreCase("true")))
- {
- this.singleLogin = true;
- }
+ this.singleLogin = (sl != null && (sl.equalsIgnoreCase("yes") || sl.equalsIgnoreCase("true")));
}
/**
@@ -228,38 +179,11 @@
}
/**
- * @return actual ExoContainer instance.
+ * {@inheritDoc}
*/
- protected ExoContainer getContainer()
+ @Override
+ protected Log getLogger()
{
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof RootContainer)
- {
- container = RootContainer.getInstance().getPortalContainer(portalContainerName);
- }
- return container;
+ return log;
}
-
- /**
- * Return portal container name if it provide with options,
- * DEFAULT_PORTAL_CONTAINER_NAME otherwise.
- *
- * @param options
- * @return
- */
- @SuppressWarnings("unchecked")
- private String getPortalContainerName(Map options)
- {
- if (options != null)
- {
- String optionValue = (String)options.get(OPTION_PORTAL_CONTAINER_NAME);
- if (optionValue != null && optionValue.length() > 0)
- {
- if (log.isDebugEnabled())
- log.debug("The DefaultLoginModule will use the portal container " + optionValue);
- return optionValue;
- }
- }
- return DEFAULT_PORTAL_CONTAINER_NAME;
- }
}
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/IdentitySetLoginModule.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/IdentitySetLoginModule.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/IdentitySetLoginModule.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -18,9 +18,6 @@
*/
package org.exoplatform.services.security.jaas;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.RootContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.Authenticator;
@@ -32,7 +29,6 @@
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
/**
* This LoginModule should be used after customer LoginModule, which makes
@@ -44,47 +40,21 @@
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public class IdentitySetLoginModule implements LoginModule
+public class IdentitySetLoginModule extends AbstractLoginModule
{
/**
- * The name of the option to use in order to specify the name of the portal container
- */
- private static final String OPTION_PORTAL_CONTAINER_NAME = "portalContainerName";
-
- /**
- * The default name of the portal container
- */
- private static final String DEFAULT_PORTAL_CONTAINER_NAME = "portal";
-
- /**
* Login.
*/
protected Log log = ExoLogger.getLogger("core.IdentitySetLoginModule");
/**
- * @see {@link Subject} .
- */
- protected Subject subject;
-
- /**
- * Shared state.
- */
- @SuppressWarnings("unchecked")
- protected Map sharedState;
-
- /**
* Is allowed for one user login again if he already login. If must set in LM
* options.
*/
- protected boolean singleLogin = false;
+ protected boolean singleLogin;
/**
- * The name of the portal container.
- */
- private String portalContainerName;
-
- /**
* {@inheritDoc}
*/
public boolean abort() throws LoginException
@@ -138,23 +108,15 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
+ public void afterInitialize()
{
if (log.isDebugEnabled())
{
log.debug("in initialize");
}
- this.subject = subject;
- this.sharedState = sharedState;
- this.portalContainerName = getPortalContainerName(options);
-
String sl = (String)options.get("singleLogin");
- if (sl != null && (sl.equalsIgnoreCase("yes") || sl.equalsIgnoreCase("true")))
- {
- this.singleLogin = true;
- }
+ this.singleLogin = (sl != null && (sl.equalsIgnoreCase("yes") || sl.equalsIgnoreCase("true")));
}
/**
@@ -182,32 +144,11 @@
}
/**
- * @return actual ExoContainer instance.
+ * {@inheritDoc}
*/
- protected ExoContainer getContainer() throws Exception
+ @Override
+ protected Log getLogger()
{
- // TODO set correct current container
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof RootContainer)
- {
- container = RootContainer.getInstance().getPortalContainer(portalContainerName);
- }
- return container;
+ return log;
}
-
- @SuppressWarnings("unchecked")
- private String getPortalContainerName(Map options)
- {
- if (options != null)
- {
- String optionValue = (String)options.get(OPTION_PORTAL_CONTAINER_NAME);
- if (optionValue != null && optionValue.length() > 0)
- {
- if (log.isDebugEnabled())
- log.debug("The IdentitySetLoginModule will use the portal container " + optionValue);
- return optionValue;
- }
- }
- return DEFAULT_PORTAL_CONTAINER_NAME;
- }
}
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/SharedStateLoginModule.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/SharedStateLoginModule.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/jaas/SharedStateLoginModule.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -18,9 +18,6 @@
*/
package org.exoplatform.services.security.jaas;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.RootContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.Authenticator;
@@ -29,53 +26,21 @@
import org.exoplatform.services.security.PasswordCredential;
import org.exoplatform.services.security.UsernameCredential;
-import java.util.Map;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
/**
* @author <a href="mailto:andrew00x at gmail.com">Andrey Parfonov</a>
* @version $Id: $
*/
-public final class SharedStateLoginModule implements LoginModule
+public final class SharedStateLoginModule extends AbstractLoginModule
{
/**
- * The name of the option to use in order to specify the name of the portal
- * container
- */
- private static final String OPTION_PORTAL_CONTAINER_NAME = "portalContainerName";
-
- /**
- * The default name of the portal container
- */
- private static final String DEFAULT_PORTAL_CONTAINER_NAME = "portal";
-
- /**
* Logger.
*/
private static final Log LOG = ExoLogger.getLogger(SharedStateLoginModule.class.getName());
/**
- * The name of the portal container.
- */
- private String portalContainerName;
-
- /**
- * Shared state.
- */
- @SuppressWarnings("unchecked")
- private Map sharedState;
-
- /**
- * Subject.
- */
- private Subject subject;
-
- /**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@@ -143,16 +108,12 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
+ public void afterInitialize()
{
if (LOG.isDebugEnabled())
{
LOG.debug("in initialize");
}
- this.sharedState = sharedState;
- this.portalContainerName = getPortalContainerName(options);
- this.subject = subject;
}
/**
@@ -168,38 +129,11 @@
}
/**
- * @return actual ExoContainer instance.
+ * {@inheritDoc}
*/
- protected ExoContainer getContainer() throws Exception
+ @Override
+ protected Log getLogger()
{
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof RootContainer)
- {
- container = RootContainer.getInstance().getPortalContainer(portalContainerName);
- }
- return container;
+ return LOG;
}
-
- /**
- * Return portal container name if it provide with options,
- * DEFAULT_PORTAL_CONTAINER_NAME otherwise.
- *
- * @param options
- * @return
- */
- @SuppressWarnings("unchecked")
- private String getPortalContainerName(Map options)
- {
- if (options != null)
- {
- String optionValue = (String)options.get(OPTION_PORTAL_CONTAINER_NAME);
- if (optionValue != null && optionValue.length() > 0)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("The IdentitySetLoginModule will use the portal container " + optionValue);
- return optionValue;
- }
- }
- return DEFAULT_PORTAL_CONTAINER_NAME;
- }
}
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/ConversationStateListener.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/ConversationStateListener.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/ConversationStateListener.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -19,8 +19,7 @@
package org.exoplatform.services.security.web;
import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.RootContainer;
+import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationRegistry;
@@ -73,39 +72,12 @@
}
/**
- * @return actual ExoContainer instance.
- * @deprecated use {@link #getContainer(ServletContext)} instead
- */
- protected ExoContainer getContainer()
- {
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof RootContainer)
- {
- container = RootContainer.getInstance().getPortalContainer("portal");
- }
- return container;
- }
-
- /**
* @param sctx {@link ServletContext}
* @return actual ExoContainer instance
*/
protected ExoContainer getContainer(ServletContext sctx)
{
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- if (container instanceof RootContainer)
- {
- String containerName = null;
- // check attribute in servlet context first
- if (sctx.getAttribute(SetCurrentIdentityFilter.PORTAL_CONTAINER_NAME) != null)
- containerName = (String)sctx.getAttribute(SetCurrentIdentityFilter.PORTAL_CONTAINER_NAME);
-
- // if not set then use default name.
- if (containerName == null)
- containerName = "portal";
- container = RootContainer.getInstance().getPortalContainer(containerName);
- }
- return container;
+ return PortalContainer.getInstance(sctx);
}
}
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/JAASConversationStateListener.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/JAASConversationStateListener.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/JAASConversationStateListener.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.security.web;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.security.ConversationRegistry;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.security.StateKey;
@@ -44,9 +46,9 @@
StateKey stateKey = new HttpSessionStateKey(httpSession);
try
{
+ ExoContainer container = getContainer(httpSession.getServletContext());
ConversationRegistry conversationRegistry =
- (ConversationRegistry)getContainer(httpSession.getServletContext()).getComponentInstanceOfType(
- ConversationRegistry.class);
+ (ConversationRegistry)container.getComponentInstanceOfType(ConversationRegistry.class);
ConversationState conversationState = conversationRegistry.unregister(stateKey);
@@ -57,7 +59,10 @@
if (conversationState.getAttribute(ConversationState.SUBJECT) != null)
{
Subject subject = (Subject)conversationState.getAttribute(ConversationState.SUBJECT);
- LoginContext ctx = new LoginContext("exo-domain", subject);
+ String realmName =
+ container instanceof PortalContainer ? ((PortalContainer)container).getRealmName()
+ : PortalContainer.DEFAULT_REALM_NAME;
+ LoginContext ctx = new LoginContext(realmName, subject);
ctx.logout();
}
else
Modified: core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java
===================================================================
--- core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java 2009-10-05 10:22:02 UTC (rev 208)
+++ core/trunk/component/security/core/src/main/java/org/exoplatform/services/security/web/SetCurrentIdentityFilter.java 2009-10-05 10:25:39 UTC (rev 209)
@@ -20,6 +20,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.web.AbstractFilter;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationRegistry;
@@ -30,9 +31,7 @@
import java.io.IOException;
-import javax.servlet.Filter;
import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@@ -47,53 +46,15 @@
* @version $Id: SimpleSessionFactoryInitializedFilter.java 7163 2006-07-19
* 07:30:39Z peterit $
*/
-public class SetCurrentIdentityFilter implements Filter
+public class SetCurrentIdentityFilter extends AbstractFilter
{
/**
- * Under this name can be set portal container name, as filter
- * <tt>init-param</tt> or application <tt>context-param</tt>. If both of
- * parameters not set then application context-name used as container name.
- */
- public static final String PORTAL_CONTAINER_NAME = "portalContainerName";
-
- /**
* Logger.
*/
private static Log log = ExoLogger.getLogger("core.security.SetCurrentIdentityFilter");
/**
- * Portal Container name.
- */
- private String portalContainerName;
-
- /**
- * {@inheritDoc}
- */
- public void init(FilterConfig config) throws ServletException
- {
- // It is not possible to use application context name everywhere cause to
- // problem with access to resources (CSS). Try to find container name in
- // filter 'init-param' or in application 'context-param'. And only if both of
- // parameters are not specified then use application context name.
-
- // Check filter init-param first
- portalContainerName = config.getInitParameter(PORTAL_CONTAINER_NAME);
-
- // check application context-param
- if (portalContainerName == null)
- portalContainerName = config.getServletContext().getInitParameter(PORTAL_CONTAINER_NAME);
-
- // if nothing set then use application context name, 'display-name' in
- // web.xml
- if (portalContainerName == null)
- portalContainerName = config.getServletContext().getServletContextName();
-
- // save container name as attribute
- config.getServletContext().setAttribute(PORTAL_CONTAINER_NAME, portalContainerName);
- }
-
- /**
* Set current {@link ConversationState}, if it is not registered yet then
* create new one and register in {@link ConversationRegistry}. {@inheritDoc}
*/
@@ -102,17 +63,8 @@
{
HttpServletRequest httpRequest = (HttpServletRequest)request;
- ExoContainer container = ExoContainerContext.getContainerByName(portalContainerName);
- if (container == null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Container " + portalContainerName + " not found.");
- }
+ ExoContainer container = getContainer();
- container = ExoContainerContext.getTopContainer();
- }
-
try
{
ExoContainerContext.setCurrentContainer(container);
More information about the exo-jcr-commits
mailing list