forked from gatein/gatein-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added backup/restore of attributes to be cross-context aware. Removed…
… SessionInvalidatorInterceptor from PC stack. Allow impersonation for disabled users. Conflicts: pom.xml webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
- Loading branch information
Showing
8 changed files
with
194 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
.../web/security/src/main/java/org/gatein/web/security/impersonation/ImpersonationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* JBoss, a division of Red Hat | ||
* Copyright 2014, Red Hat Middleware, LLC, and individual | ||
* contributors as indicated by the @authors tag. See the | ||
* copyright.txt in the distribution for a full listing of | ||
* individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.gatein.web.security.impersonation; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLEncoder; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Marek Posolda</a> | ||
*/ | ||
public class ImpersonationUtils { | ||
|
||
/** | ||
* Create URL for redirection to impersonationServlet to start impersonation session | ||
* | ||
* @param portalContextPath context-path of portal (assumption is that ImpersonationServlet is available on this path too) | ||
* @param usernameToImpersonate username to impersonate | ||
* @param returnImpersonationUri URI, where should be request redirected from ImpersonationServlet after finish of Impersonation workflow | ||
* @return uri to send to impersonationServlet including all parameters | ||
*/ | ||
public static String createStartImpersonationURL(String portalContextPath, String usernameToImpersonate, String returnImpersonationUri) { | ||
String impersonationServletUri = portalContextPath + ImpersonationServlet.IMPERSONATE_URL_SUFIX; | ||
|
||
try { | ||
return new StringBuilder(impersonationServletUri) | ||
.append("?") | ||
.append(ImpersonationServlet.PARAM_ACTION) | ||
.append("=") | ||
.append(ImpersonationServlet.PARAM_ACTION_START_IMPERSONATION) | ||
.append("&") | ||
.append(ImpersonationServlet.PARAM_USERNAME) | ||
.append("=") | ||
.append(URLEncoder.encode(usernameToImpersonate, "UTF-8")) | ||
.append("&") | ||
.append(ImpersonationServlet.PARAM_RETURN_IMPERSONATION_URI) | ||
.append("=") | ||
.append(URLEncoder.encode(returnImpersonationUri, "UTF-8")) | ||
.toString(); | ||
} catch (UnsupportedEncodingException uee) { | ||
throw new RuntimeException(uee); | ||
} | ||
} | ||
|
||
/** | ||
* Create URL for redirection to impersonationServlet to stop impersonation session | ||
* | ||
* @param portalContextPath context-path of portal (assumption is that ImpersonationServlet is available on this path too) | ||
* @return uri to send to impersonationServlet including all parameters | ||
*/ | ||
public static String createFinishImpersonationURL(String portalContextPath) { | ||
// Redirect to ImpersonationServlet and trigger stop of Impersonation session | ||
String impersonationServletUri = portalContextPath + ImpersonationServlet.IMPERSONATE_URL_SUFIX; | ||
|
||
return new StringBuilder(impersonationServletUri) | ||
.append("?") | ||
.append(ImpersonationServlet.PARAM_ACTION) | ||
.append("=") | ||
.append(ImpersonationServlet.PARAM_ACTION_STOP_IMPERSONATION) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
|
||
package org.exoplatform.organization.webui.component; | ||
|
||
import java.net.URLEncoder; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
@@ -56,7 +55,7 @@ | |
import org.exoplatform.webui.form.UIFormInputSet; | ||
import org.exoplatform.webui.form.UIFormSelectBox; | ||
import org.exoplatform.webui.form.UIFormStringInput; | ||
import org.gatein.web.security.impersonation.ImpersonationServlet; | ||
import org.gatein.web.security.impersonation.ImpersonationUtils; | ||
|
||
/** | ||
* Created by The eXo Platform SARL Author : chungnv [email protected] Jun 23, 2006 10:07:15 AM | ||
|
@@ -310,7 +309,7 @@ public void execute(Event<UIListUsers> event) throws Exception { | |
String userName = event.getRequestContext().getRequestParameter(OBJECTID); | ||
|
||
OrganizationService service = uiListUsers.getApplicationComponent(OrganizationService.class); | ||
User userToImpersonate = service.getUserHandler().findUserByName(userName); | ||
User userToImpersonate = service.getUserHandler().findUserByName(userName, UserStatus.BOTH); | ||
if (userToImpersonate == null) { | ||
UIApplication uiApplication = event.getRequestContext().getUIApplication(); | ||
uiApplication.addMessage(new ApplicationMessage("UIListUsers.msg.user-is-deleted", null, | ||
|
@@ -327,32 +326,15 @@ public void execute(Event<UIListUsers> event) throws Exception { | |
return; | ||
} | ||
|
||
// Redirect to finish login with new user | ||
// Redirect to impersonation servlet | ||
PortalRequestContext portalRequestContext = Util.getPortalRequestContext(); | ||
SiteKey siteKey = portalRequestContext.getSiteKey(); | ||
NodeURL currentNodeURL = portalRequestContext.createURL(NodeURL.TYPE); | ||
currentNodeURL.setResource(new NavigationResource(siteKey, portalRequestContext.getNodePath())); | ||
|
||
String redirectURL = portalRequestContext.getRequestContextPath() + ImpersonationServlet.IMPERSONATE_URL_SUFIX; | ||
|
||
// Attach params | ||
redirectURL = new StringBuilder(redirectURL) | ||
.append("?") | ||
.append(ImpersonationServlet.PARAM_ACTION) | ||
.append("=") | ||
.append(ImpersonationServlet.PARAM_ACTION_START_IMPERSONATION) | ||
.append("&") | ||
.append(ImpersonationServlet.PARAM_USERNAME) | ||
.append("=") | ||
.append(URLEncoder.encode(userName, "UTF-8")) | ||
.append("&") | ||
.append(ImpersonationServlet.PARAM_RETURN_IMPERSONATION_URI) | ||
.append("=") | ||
.append(URLEncoder.encode(currentNodeURL.toString(), "UTF-8")) | ||
.toString(); | ||
String impersonationRedirectURL = ImpersonationUtils.createStartImpersonationURL(portalRequestContext.getRequestContextPath(), userName, currentNodeURL.toString()); | ||
|
||
// Redirect to impersonation servlet | ||
portalRequestContext.getJavascriptManager().addJavascript("window.location = '" + redirectURL + "';"); | ||
portalRequestContext.getJavascriptManager().addJavascript("window.location = '" + impersonationRedirectURL + "';"); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.