Skip to content

Commit

Permalink
Update User Acct Mgmt
Browse files Browse the repository at this point in the history
Update for when User Mgmt Session Key not valid
  • Loading branch information
danjasuw committed Jul 22, 2019
1 parent ec061d6 commit accabaa
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.yeastrc.xlink.www.constants.StrutsGlobalForwardNames;

import org.yeastrc.xlink.www.exceptions.ProxlWebappInternalErrorException;
import org.yeastrc.xlink.www.user_mgmt_webapp_access.UserMgmtCentralWebappWebserviceAccess;
import org.yeastrc.xlink.www.user_mgmt_webapp_access.UserMgmtSessionKeyAliveWebserviceRequest;
import org.yeastrc.xlink.www.user_mgmt_webapp_access.UserMgmtSessionKeyAliveWebserviceResponse;
import org.yeastrc.xlink.www.user_session_management.UserSession;
import org.yeastrc.xlink.www.user_session_management.UserSessionManager;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId_Result;
import org.yeastrc.xlink.www.access_control.access_control_main.GetWebSessionAuthAccessLevelForProjectIds_And_NO_ProjectId;
import org.yeastrc.xlink.www.web_utils.GetPageHeaderData;
Expand Down Expand Up @@ -44,6 +48,27 @@ public ActionForward execute( ActionMapping mapping,
// No User session
return mapping.findForward( StrutsGlobalForwardNames.NO_USER_SESSION );
}
{
UserMgmtSessionKeyAliveWebserviceRequest userMgmtSessionKeyAliveWebserviceRequest = new UserMgmtSessionKeyAliveWebserviceRequest();
userMgmtSessionKeyAliveWebserviceRequest.setSessionKey( userSession.getUserMgmtSessionKey() );

UserMgmtSessionKeyAliveWebserviceResponse userMgmtSessionKeyAliveWebserviceResponse =
UserMgmtCentralWebappWebserviceAccess.getInstance().sessionKeyAlive(userMgmtSessionKeyAliveWebserviceRequest);
if ( userMgmtSessionKeyAliveWebserviceResponse.isSessionKeyNotValid() ) {

// Session Key not valid in User Mgmt. Force User to log back in to create new session in User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Send to login page
return mapping.findForward( StrutsGlobalForwardNames.NO_USER_SESSION );
}

if ( ! userMgmtSessionKeyAliveWebserviceResponse.isSuccess() ) {
throw new ProxlWebappInternalErrorException( "Response from User Mgmt Not Success" );
}
}
GetPageHeaderData.getInstance().getPageHeaderDataWithoutProjectId( request );

UserDataForPage userDataForPage = new UserDataForPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,23 @@ public AccountMaintResult changeFirstNameService(
UserMgmtCentralWebappWebserviceAccess.getInstance().
manageUserData( userMgmtManageAccountRequest );
if ( ! userMgmtManageAccountResponse.isSuccess() ) {

accountMaintResult.setStatus(false);

if ( userMgmtManageAccountResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}
return accountMaintResult; // EARLY RETURN
}

Expand Down Expand Up @@ -172,6 +188,21 @@ public AccountMaintResult changeLastNameService(
UserMgmtCentralWebappWebserviceAccess.getInstance().
manageUserData( userMgmtManageAccountRequest );
if ( ! userMgmtManageAccountResponse.isSuccess() ) {

if ( userMgmtManageAccountResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}
accountMaintResult.setStatus(false);
return accountMaintResult; // EARLY RETURN
}
Expand Down Expand Up @@ -257,6 +288,21 @@ public AccountMaintResult changeOrganizationService(
UserMgmtCentralWebappWebserviceAccess.getInstance().
manageUserData( userMgmtManageAccountRequest );
if ( ! userMgmtManageAccountResponse.isSuccess() ) {

if ( userMgmtManageAccountResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}
accountMaintResult.setStatus(false);
return accountMaintResult; // EARLY RETURN
}
Expand Down Expand Up @@ -342,6 +388,21 @@ public AccountMaintResult changeEmailService(
UserMgmtCentralWebappWebserviceAccess.getInstance().
manageUserData( userMgmtManageAccountRequest );
if ( ! userMgmtManageAccountResponse.isSuccess() ) {

if ( userMgmtManageAccountResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}
accountMaintResult.setStatus(false);
if ( userMgmtManageAccountResponse.isDuplicateEmail() ) {
accountMaintResult.setValueAlreadyExists(true);
Expand Down Expand Up @@ -422,6 +483,21 @@ public AccountMaintResult changeUsernameService(
UserMgmtCentralWebappWebserviceAccess.getInstance().
manageUserData( userMgmtManageAccountRequest );
if ( ! userMgmtManageAccountResponse.isSuccess() ) {

if ( userMgmtManageAccountResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}
accountMaintResult.setStatus(false);
if ( userMgmtManageAccountResponse.isDuplicateUsername() ) {
accountMaintResult.setValueAlreadyExists(true);
Expand Down Expand Up @@ -526,6 +602,22 @@ public AccountMaintResult changePasswordService(
UserMgmtCentralWebappWebserviceAccess.getInstance().changePassword( userMgmtChangePasswordRequest );

if ( ! userMgmtChangePasswordResponse.isSuccess() ) {

if ( userMgmtChangePasswordResponse.isSessionKeyNotValid() ) {

// No User session In User Mgmt

// Invalidate session
UserSessionManager.getSinglesonInstance().invalidateUserSession( request );

// Return HTTP status so JS reloads page and user logs back in, creating new session in User Mgmt
throw new WebApplicationException(
Response.status( WebServiceErrorMessageConstants.NO_SESSION_STATUS_CODE ) // Send HTTP code
.entity( WebServiceErrorMessageConstants.NO_SESSION_TEXT ) // This string will be passed to the client
.build()
);
}

accountMaintResult.setStatus(false);
if ( userMgmtChangePasswordResponse.isSessionKeyNotValid() ) {
// No User session
Expand Down Expand Up @@ -597,7 +689,6 @@ public boolean isStatus() {
public void setStatus(boolean status) {
this.status = status;
}

}

}

0 comments on commit accabaa

Please sign in to comment.