mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
. Fix to external access URLs to correctly navigate to specified NodeRef and setup Breadcrumb component etc.
. Tidy up of web-client authentication code git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2231 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -253,10 +253,11 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
|||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
// invalidate ticket
|
// invalidate ticket and clear the Security context for this thread
|
||||||
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
|
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
|
||||||
AuthenticationService authService = (AuthenticationService)ctx.getBean("authenticationService");
|
AuthenticationService authService = (AuthenticationService)ctx.getBean("authenticationService");
|
||||||
authService.invalidateTicket(user.getTicket());
|
authService.invalidateTicket(user.getTicket());
|
||||||
|
authService.clearCurrentSecurityContext();
|
||||||
event.getSession().removeAttribute(AuthenticationHelper.AUTHENTICATION_USER);
|
event.getSession().removeAttribute(AuthenticationHelper.AUTHENTICATION_USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,10 @@ public class ExternalAccessServlet extends HttpServlet
|
|||||||
// TODO: the browse bean should accept a full NodeRef - not just an ID
|
// TODO: the browse bean should accept a full NodeRef - not just an ID
|
||||||
browseBean.setupContentAction(nodeRef.getId(), true);
|
browseBean.setupContentAction(nodeRef.getId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// perform the appropriate JSF navigation outcome
|
||||||
|
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||||
|
navigationHandler.handleNavigation(fc, null, outcome);
|
||||||
}
|
}
|
||||||
else if (OUTCOME_SPACEDETAILS.equals(outcome))
|
else if (OUTCOME_SPACEDETAILS.equals(outcome))
|
||||||
{
|
{
|
||||||
@@ -149,6 +153,10 @@ public class ExternalAccessServlet extends HttpServlet
|
|||||||
// TODO: the browse bean should accept a full NodeRef - not just an ID
|
// TODO: the browse bean should accept a full NodeRef - not just an ID
|
||||||
browseBean.setupSpaceAction(nodeRef.getId(), true);
|
browseBean.setupSpaceAction(nodeRef.getId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// perform the appropriate JSF navigation outcome
|
||||||
|
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
||||||
|
navigationHandler.handleNavigation(fc, null, outcome);
|
||||||
}
|
}
|
||||||
else if (OUTCOME_BROWSE.equals(outcome))
|
else if (OUTCOME_BROWSE.equals(outcome))
|
||||||
{
|
{
|
||||||
@@ -162,28 +170,21 @@ public class ExternalAccessServlet extends HttpServlet
|
|||||||
StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]);
|
StoreRef storeRef = new StoreRef(args[0+offset], args[1+offset]);
|
||||||
nodeRef = new NodeRef(storeRef, args[2+offset]);
|
nodeRef = new NodeRef(storeRef, args[2+offset]);
|
||||||
|
|
||||||
// setup the ref as current Id in the global navigation bean
|
// this call sets up the current node Id, and updates or initialises the
|
||||||
NavigationBean navigator = (NavigationBean)ServletHelper.getManagedBean(fc, "NavigationBean");
|
// breadcrumb component with the selected node as appropriate.
|
||||||
navigator.setCurrentNodeId(nodeRef.getId());
|
browseBean.updateUILocation(nodeRef);
|
||||||
|
browseBean.contextUpdated();
|
||||||
|
|
||||||
//
|
|
||||||
// TODO: handle this code
|
|
||||||
/*
|
|
||||||
// check for view mode first argument
|
// check for view mode first argument
|
||||||
if (args[0].equals(ARG_TEMPLATE))
|
if (args[0].equals(ARG_TEMPLATE))
|
||||||
{
|
{
|
||||||
browseBean.setDashboardView(true);
|
browseBean.setDashboardView(true);
|
||||||
// the above call will auto-navigate to the correct outcome - so we don't!
|
|
||||||
//externalOutcome = null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform the appropriate JSF navigation outcome
|
// the above calls setup the NavigationHandler automatically
|
||||||
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
|
}
|
||||||
navigationHandler.handleNavigation(fc, null, outcome);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// perform the forward to the page processed by the Faces servlet
|
// perform the forward to the page processed by the Faces servlet
|
||||||
String viewId = fc.getViewRoot().getViewId();
|
String viewId = fc.getViewRoot().getViewId();
|
||||||
|
@@ -1257,7 +1257,7 @@ public class BrowseBean implements IContextListener
|
|||||||
*
|
*
|
||||||
* @param ref NodeRef of the selected space
|
* @param ref NodeRef of the selected space
|
||||||
*/
|
*/
|
||||||
/*package*/ void updateUILocation(NodeRef ref)
|
public void updateUILocation(NodeRef ref)
|
||||||
{
|
{
|
||||||
// get the current breadcrumb location and append a new handler to it
|
// get the current breadcrumb location and append a new handler to it
|
||||||
// our handler know the ID of the selected node and the display label for it
|
// our handler know the ID of the selected node and the display label for it
|
||||||
|
@@ -351,7 +351,9 @@ public class LoginBean
|
|||||||
|
|
||||||
boolean alfrescoAuth = (session.get(LOGIN_EXTERNAL_AUTH) == null);
|
boolean alfrescoAuth = (session.get(LOGIN_EXTERNAL_AUTH) == null);
|
||||||
|
|
||||||
// invalidate Session for this user
|
// Invalidate Session for this user.
|
||||||
|
// This causes the sessionDestroyed() event to be processed by ContextListener
|
||||||
|
// which is responsible for invalidating the ticket and clearing the security context
|
||||||
if (Application.inPortalServer() == false)
|
if (Application.inPortalServer() == false)
|
||||||
{
|
{
|
||||||
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
||||||
@@ -363,13 +365,6 @@ public class LoginBean
|
|||||||
request.getPortletSession().invalidate();
|
request.getPortletSession().invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalidate User ticket
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
this.authenticationService.invalidateTicket(user.getTicket());
|
|
||||||
this.authenticationService.clearCurrentSecurityContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request that the username cookie state is removed - this is not
|
// Request that the username cookie state is removed - this is not
|
||||||
// possible from JSF - so instead we setup a session variable
|
// possible from JSF - so instead we setup a session variable
|
||||||
// which will be detected by the login.jsp/Portlet as appropriate.
|
// which will be detected by the login.jsp/Portlet as appropriate.
|
||||||
|
@@ -389,17 +389,24 @@ public class NavigationBean
|
|||||||
{
|
{
|
||||||
if (this.location == null)
|
if (this.location == null)
|
||||||
{
|
{
|
||||||
// init the location from the User object for the first time
|
// set the current node to the users Home Space Id if one has not already been set
|
||||||
User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
|
NodeRef homeSpaceRef;
|
||||||
|
|
||||||
NodeRef homeSpaceRef = new NodeRef(Repository.getStoreRef(), user.getHomeSpaceId());
|
|
||||||
String homeSpaceName = Repository.getNameForNode(this.nodeService, homeSpaceRef);
|
|
||||||
|
|
||||||
// set the current node to the users Home Space Id
|
|
||||||
setCurrentNodeId(user.getHomeSpaceId());
|
|
||||||
|
|
||||||
// setup the breadcrumb with the same location
|
|
||||||
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
|
List<IBreadcrumbHandler> elements = new ArrayList<IBreadcrumbHandler>(1);
|
||||||
|
if (getCurrentNodeId() == null)
|
||||||
|
{
|
||||||
|
User user = Application.getCurrentUser(FacesContext.getCurrentInstance());
|
||||||
|
homeSpaceRef = new NodeRef(Repository.getStoreRef(), user.getHomeSpaceId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
homeSpaceRef = new NodeRef(Repository.getStoreRef(), getCurrentNodeId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// set initial node ID
|
||||||
|
setCurrentNodeId(homeSpaceRef.getId());
|
||||||
|
|
||||||
|
// setup the breadcrumb with the same initial location
|
||||||
|
String homeSpaceName = Repository.getNameForNode(this.nodeService, homeSpaceRef);
|
||||||
elements.add(new NavigationBreadcrumbHandler(homeSpaceRef, homeSpaceName));
|
elements.add(new NavigationBreadcrumbHandler(homeSpaceRef, homeSpaceName));
|
||||||
setLocation(elements);
|
setLocation(elements);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user