My webserver prevents access to the system if the user is not logged in, but some users may have more than one profile and the system only allows users to log in choosing one of them, i.e., a user may be a regular user with some permissions and this same user may logout and login again with admin permissions and have access to everything.
When this situation occurs I redirect the user to an action that forces the user to choose his/her profile, but the server no longer knows the action that the user tried to access. I'm able to retrieve this information through ActionInvocation like below:
public String initFeature() {
final ActionInvocation invocation = ServletActionContext.getActionContext(BaseAction.getRequest())
.getActionInvocation();
final Object action = invocation.getAction();
if (!this.isUserFullyLogged() && !(action instanceof ProfileSelectionAction)) {
final Boolean isPendingProfileSelection = (Boolean) this
.retrieveSessionAttribute(Constants.PENDING_PROFILE_SELECTION);
if (isPendingProfileSelection != null && isPendingProfileSelection.booleanValue()) {
this.saveSessionAttribute("action", action);
this.saveSessionAttribute("namespace", invocation.getProxy().getNamespace());
return Constants.PROFILE_SELECTION;
}
return Action.LOGIN;
}
return Action.SUCCESS;
}
When the system reaches to the profile selection action I have the action and namespace that the user have tried to access and was forbid but I don't know what I have to do to redirect the system to this namespace and action because I only have done it using action result of the struts.xml file so far.