Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deactivate users #7629

Merged
merged 52 commits into from Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1f48426
docs for disable/delete/anon, need to move to user admin section
djbrooke Feb 5, 2021
2af33fd
draft code review feedback
djbrooke Feb 5, 2021
ecaaa9b
removing anon and documentation for remove roles API
djbrooke Feb 5, 2021
1c5d632
user merge and delete cleanup, get traces #4475 #7575
pdurbin Feb 5, 2021
ab50ea9
Merge branch 'develop' into 4475-delete-user-api
djbrooke Feb 10, 2021
eafdc73
updates from draft code review
djbrooke Feb 10, 2021
a3b51d7
adding links from user administration
djbrooke Feb 10, 2021
c85691b
updates from more review
djbrooke Feb 11, 2021
bb03310
Update native-api.rst
djbrooke Feb 17, 2021
e9845c0
Update native-api.rst
djbrooke Feb 18, 2021
51022aa
disable users #2419 #4475
pdurbin Feb 18, 2021
5458d9d
Merge branch 'develop' into 2419-4475-7575-disable-users #4475
pdurbin Feb 18, 2021
291945a
Merge branch '4475-delete-user-api' into 2419-4475-7575-disable-users…
pdurbin Feb 18, 2021
0f2e74b
tweaks to API guide, docs for traces, removeRoles #4475
pdurbin Feb 18, 2021
96fc087
add release note #2419 #4475
pdurbin Feb 19, 2021
a9a368b
implement rule on merging disabled accounts #2419 #4475
pdurbin Feb 19, 2021
8a7ed7b
add new test classes: DeleteUsersIT and DisableUsersIT #2419 #4475
pdurbin Feb 19, 2021
ef1061e
disabled users cannot use the API #2419 #4475
pdurbin Feb 19, 2021
fa33eee
cleanup
pdurbin Feb 19, 2021
e73c43b
rename sql update script #2419 #4475
pdurbin Feb 23, 2021
8f08f7b
disabled users should never get notifications #2419 #4475
pdurbin Feb 26, 2021
23b8bf6
use default methods for isDisabled on User #2419 #4475
pdurbin Mar 2, 2021
d6e1173
run disable user command without superuser API token #2419 #4475
pdurbin Mar 2, 2021
6e61841
remove password reset data with cascade #7575
pdurbin Mar 3, 2021
8afbf5e
remove oauth2tokendata with a cascade #2419 #4475
pdurbin Mar 3, 2021
610e9ca
merge configureSessionTimeout into setUser #2419 #4475
pdurbin Mar 4, 2021
4599d86
Merge branch 'develop' into 2419-4475-7575-disable-users #2419 #4475
pdurbin Mar 4, 2021
28579e2
rename SQL script #2419 #4475
pdurbin Mar 4, 2021
ddc4f3a
rebrand "disable users" as "deactivate users" #2419 #4475
pdurbin Mar 11, 2021
abb8be0
remove API token from deactivate user examples (not needed) #2419 #4475
pdurbin Mar 12, 2021
3713104
fix error handing for revoke all roles (bubble up msg) #2419 #4475
pdurbin Mar 12, 2021
c2b7b0a
add "deactivated" to user dashboard, list-users API #2419 #4475
pdurbin Mar 12, 2021
3e59e70
in session, ensure user hasn't been deleted or deactivated #2419 #4475
pdurbin Mar 15, 2021
4f81fbd
prevent accounts from being merged into themselves #2419 #4475
pdurbin Mar 16, 2021
9fdaf41
fix "merge into self" test #2419 #4475
pdurbin Mar 16, 2021
fbded77
prevent deactivated accounts from being converted to OAuth #2419 #4475
pdurbin Mar 16, 2021
fdc9cbe
prevent deactivated accounts from being converted to Shib #2419 #4475
pdurbin Mar 16, 2021
1e985b6
Merge branch 'develop' into 2419-4475-7575-disable-users #2419 #4475
pdurbin Mar 17, 2021
0efee28
exclude deactivated users from role assignment autocomplete #2419 #4475
pdurbin Mar 17, 2021
4b2ac96
cleanup, add shib/oauth convert to list for admins #2419 #4475
pdurbin Mar 17, 2021
d0191c3
more efficient check for disabled or deleted users #2419 #4475
pdurbin Mar 18, 2021
530dab3
move logic up (earlier) #2419 #4475
pdurbin Mar 22, 2021
df32ec0
change "non-deactivated" to "active" #2419 #4475
pdurbin Mar 22, 2021
5edfa7a
Merge branch 'develop' into 2419-4475-7575-disable-users #2419 #4475
pdurbin Mar 23, 2021
d00d0ec
rename SQL script #2419 #4475
pdurbin Mar 23, 2021
81274c9
Update DataversePage.java
scolapasta Mar 24, 2021
569136f
prevent user table, user-list API from blowing up #2419 #4475
pdurbin Mar 25, 2021
1f11785
Merge branch 'develop' into 2419-4475-7575-disable-users #2419 #4475
pdurbin Mar 25, 2021
c326af4
deactivated users cannot become superusers #2419 #4475
pdurbin Mar 25, 2021
239151a
Merge branch 'develop' into 2419-4475-7575-disable-users
sekmiller Mar 26, 2021
36f25bb
#2419 retest session user on save
sekmiller Mar 26, 2021
274f150
#2419 update update query
sekmiller Mar 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf/docker-aio/run-test-suite.sh
Expand Up @@ -8,4 +8,4 @@ fi

# Please note the "dataverse.test.baseurl" is set to run for "all-in-one" Docker environment.
# TODO: Rather than hard-coding the list of "IT" classes here, add a profile to pom.xml.
source maven/maven.sh && mvn test -Dtest=DataversesIT,DatasetsIT,SwordIT,AdminIT,BuiltinUsersIT,UsersIT,UtilIT,ConfirmEmailIT,FileMetadataIT,FilesIT,SearchIT,InReviewWorkflowIT,HarvestingServerIT,MoveIT,MakeDataCountApiIT,FileTypeDetectionIT,EditDDIIT,ExternalToolsIT,AccessIT,DuplicateFilesIT,DownloadFilesIT,LinkIT -Ddataverse.test.baseurl=$dvurl
source maven/maven.sh && mvn test -Dtest=DataversesIT,DatasetsIT,SwordIT,AdminIT,BuiltinUsersIT,UsersIT,UtilIT,ConfirmEmailIT,FileMetadataIT,FilesIT,SearchIT,InReviewWorkflowIT,HarvestingServerIT,MoveIT,MakeDataCountApiIT,FileTypeDetectionIT,EditDDIIT,ExternalToolsIT,AccessIT,DuplicateFilesIT,DownloadFilesIT,LinkIT,DeleteUsersIT,DeactivateUsersIT -Ddataverse.test.baseurl=$dvurl
5 changes: 5 additions & 0 deletions doc/release-notes/2419-4475-7575-disable-users.md
@@ -0,0 +1,5 @@
## Release Highlights

### Deactivate Users API, Get User Traces API, Revoke Roles API

A new API has been added to deactivate users to prevent them from logging in or otherwise being active in the system. Deactivating a user is an alternative to deleting a user, especially when the latter is not possible due to the amount of interaction the user has had with the system. In order to learn more about a user before deleting, deactivating, or merging, a new "get user traces" API is available that will show objects created, roles, group memberships, and more. Finally, the "remove all roles" button available in the superuser dashboard is now also available via API.
10 changes: 10 additions & 0 deletions doc/sphinx-guides/source/admin/user-administration.rst
Expand Up @@ -44,6 +44,16 @@ Change User Identifier

See :ref:`change-identifier-label`

Delete a User
-------------

See :ref:`delete-a-user`

Deactivate a User
-----------------

See :ref:`deactivate-a-user`

Confirm Email
-------------

Expand Down
107 changes: 103 additions & 4 deletions doc/sphinx-guides/source/api/native-api.rst
Expand Up @@ -3147,6 +3147,8 @@ Example: ``curl -H "X-Dataverse-key: $API_TOKEN" -X POST http://demo.dataverse.o

This action moves account data from jsmith2 into the account jsmith and deletes the account of jsmith2.

Note: User accounts can only be merged if they are either both active or both deactivated. See :ref:`deactivate a user<deactivate-a-user>`.

.. _change-identifier-label:

Change User Identifier
Expand All @@ -3166,7 +3168,9 @@ Make User a SuperUser
Toggles superuser mode on the ``AuthenticatedUser`` whose ``identifier`` (without the ``@`` sign) is passed. ::

POST http://$SERVER/api/admin/superuser/$identifier


.. _delete-a-user:

Delete a User
~~~~~~~~~~~~~

Expand All @@ -3178,9 +3182,104 @@ Deletes an ``AuthenticatedUser`` whose ``id`` is passed. ::

DELETE http://$SERVER/api/admin/authenticatedUsers/id/$id

Note: If the user has performed certain actions such as creating or contributing to a Dataset or downloading a file they cannot be deleted.


Note: If the user has performed certain actions such as creating or contributing to a Dataset or downloading a file they cannot be deleted. To see where in the database these actions are stored you can use the :ref:`show-user-traces-api` API. If a user cannot be deleted for this reason, you can choose to :ref:`deactivate a user<deactivate-a-user>`.

.. _deactivate-a-user:

Deactivate a User
~~~~~~~~~~~~~~~~~

Deactivates a user. A superuser API token is not required but the command will operate using the first superuser it finds.

.. note:: See :ref:`curl-examples-and-environment-variables` if you are unfamiliar with the use of export below.

.. code-block:: bash

export SERVER_URL=http://localhost:8080
export USERNAME=jdoe

curl -X POST $SERVER_URL/api/admin/authenticatedUsers/$USERNAME/deactivate

The fully expanded example above (without environment variables) looks like this:

.. code-block:: bash

curl -X POST http://localhost:8080/api/admin/authenticatedUsers/jdoe/deactivate

The database ID of the user can be passed instead of the username.

.. code-block:: bash

export SERVER_URL=http://localhost:8080
export USERID=42

curl -X POST $SERVER_URL/api/admin/authenticatedUsers/id/$USERID/deactivate

Note: A primary purpose of most Dataverse installations is to serve an archive. In the archival space, there are best practices around the tracking of data access and the tracking of modifications to data and metadata. In support of these key workflows, a simple mechanism to delete users that have performed edit or access actions in the system is not provided. Providing a Deactivate User endpoint for users who have taken certain actions in the system alongside a Delete User endpoint to remove users that haven't taken certain actions in the system is by design.

This is an irreversible action. There is no option to undeactivate a user.

Deactivating a user with this endpoint will:

- Deactivate the user's ability to log in to the Dataverse installation. A message will be shown, stating that the account has been deactivated. The user will not able to create a new account with the same email address, ORCID, Shibboleth, or other login type.
- Deactivate the user's ability to use the API
- Remove the user's access from all Dataverse collections, datasets and files
- Prevent a user from being assigned any roles
- Cancel any pending file access requests generated by the user
- Remove the user from all groups
- No longer have notifications generated or sent by the Dataverse installation
- Prevent the account from being converted into an OAuth or Shibboleth account.
- Prevent the user from becoming a superuser.

Deactivating a user with this endpoint will keep:

- The user's contributions to datasets, including dataset creation, file uploads, and publishing.
- The user's access history to datafiles in the Dataverse installation, including guestbook records.
- The user's account information (specifically name, email, affiliation, and position)

.. _show-user-traces-api:

Show User Traces
~~~~~~~~~~~~~~~~

Show the traces that the user has left in the system, such as datasets created, guestbooks filled out, etc. This can be useful for understanding why a user cannot be deleted. A superuser API token is required.

.. note:: See :ref:`curl-examples-and-environment-variables` if you are unfamiliar with the use of export below.

.. code-block:: bash

export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export USERNAME=jdoe

curl -H "X-Dataverse-key:$API_TOKEN" -X GET $SERVER_URL/api/users/$USERNAME/traces

The fully expanded example above (without environment variables) looks like this:

.. code-block:: bash

curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X GET https://demo.dataverse.org/api/users/jdoe/traces

Remove All Roles from a User
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Removes all roles from the user. This is equivalent of clicking the "Remove All Roles" button in the superuser dashboard. Note that you can preview the roles that will be removed with the :ref:`show-user-traces-api` API. A superuser API token is required.

.. note:: See :ref:`curl-examples-and-environment-variables` if you are unfamiliar with the use of export below.

.. code-block:: bash

export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export SERVER_URL=https://demo.dataverse.org
export USERNAME=jdoe

curl -H "X-Dataverse-key:$API_TOKEN" -X POST $SERVER_URL/api/users/$USERNAME/removeRoles

The fully expanded example above (without environment variables) looks like this:

.. code-block:: bash

curl -H X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -X POST http://localhost:8080/api/users/jdoe/removeRoles

List Role Assignments of a Role Assignee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/developers/remote-users.rst
Expand Up @@ -10,7 +10,7 @@ Shibboleth and OAuth

If you are working on anything related to users, please keep in mind that your changes will likely affect Shibboleth and OAuth users. For some background on user accounts in the Dataverse Software, see :ref:`auth-modes` section of Configuration in the Installation Guide.

Rather than setting up Shibboleth on your laptop, developers are advised to simply add a value to their database to enable Shibboleth "dev mode" like this:
Rather than setting up Shibboleth on your laptop, developers are advised to add the Shibboleth auth provider (see "Add the Shibboleth Authentication Provider to Your Dataverse Installation" at :doc:`/installation/shibboleth`) and add a value to their database to enable Shibboleth "dev mode" like this:

``curl http://localhost:8080/api/admin/settings/:DebugShibAccountType -X PUT -d RANDOM``

Expand Down
4 changes: 4 additions & 0 deletions doc/sphinx-guides/source/user/account.rst
Expand Up @@ -99,6 +99,8 @@ If you already have a Dataverse installation account associated with the Usernam
#. Enter your current password for your Dataverse installation account and click "Convert Account".
#. Now you have finished converting your Dataverse installation account to use your institutional log in.

Note that you cannot go through this conversion process if your Dataverse installation account associated with the Username/Email log in option has been deactivated.

Convert your Dataverse installation account away from your Institutional Log In
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -132,6 +134,8 @@ If you already have a Dataverse installation account associated with the Usernam
#. Enter your username and password for your Dataverse installation account and click "Convert Account".
#. Now you have finished converting your Dataverse installation account to use ORCID for log in.

Note that you cannot go through this conversion process if your Dataverse installation account associated with the Username/Email log in option has been deactivated.

Convert your Dataverse installation account away from ORCID for log in
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Expand Up @@ -57,6 +57,10 @@
@NamedQueries({
@NamedQuery( name="DataFile.removeFromDatasetVersion",
query="DELETE FROM FileMetadata f WHERE f.datasetVersion.id=:versionId and f.dataFile.id=:fileId"),
@NamedQuery(name = "DataFile.findByCreatorId",
scolapasta marked this conversation as resolved.
Show resolved Hide resolved
query = "SELECT o FROM DataFile o WHERE o.creator.id=:creatorId"),
@NamedQuery(name = "DataFile.findByReleaseUserId",
query = "SELECT o FROM DataFile o WHERE o.releaseUser.id=:releaseUserId"),
@NamedQuery(name="DataFile.findDataFileByIdProtocolAuth",
query="SELECT s FROM DataFile s WHERE s.identifier=:identifier AND s.protocol=:protocol AND s.authority=:authority"),
@NamedQuery(name="DataFile.findDataFileThatReplacedId",
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataFileServiceBean.java
Expand Up @@ -155,7 +155,15 @@ public DataFile find(Object pk) {
public DataFile findByGlobalId(String globalId) {
return (DataFile) dvObjectService.findByGlobalId(globalId, DataFile.DATAFILE_DTYPE_STRING);
}


public List<DataFile> findByCreatorId(Long creatorId) {
return em.createNamedQuery("DataFile.findByCreatorId").setParameter("creatorId", creatorId).getResultList();
}

public List<DataFile> findByReleaseUserId(Long releaseUserId) {
return em.createNamedQuery("DataFile.findByReleaseUserId").setParameter("releaseUserId", releaseUserId).getResultList();
}

public DataFile findReplacementFile(Long previousFileId){
Query query = em.createQuery("select object(o) from DataFile as o where o.previousDataFileId = :previousFileId");
query.setParameter("previousFileId", previousFileId);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Expand Up @@ -53,6 +53,10 @@
query = "SELECT o.id FROM Dataset o WHERE o.owner.id=:ownerId"),
@NamedQuery(name = "Dataset.findByOwnerId",
query = "SELECT o FROM Dataset o WHERE o.owner.id=:ownerId"),
@NamedQuery(name = "Dataset.findByCreatorId",
query = "SELECT o FROM Dataset o WHERE o.creator.id=:creatorId"),
@NamedQuery(name = "Dataset.findByReleaseUserId",
query = "SELECT o FROM Dataset o WHERE o.releaseUser.id=:releaseUserId"),
})

/*
Expand Down
Expand Up @@ -150,6 +150,14 @@ private List<Long> findIdsByOwnerId(Long ownerId, boolean onlyPublished) {
}
}

public List<Dataset> findByCreatorId(Long creatorId) {
return em.createNamedQuery("Dataset.findByCreatorId").setParameter("creatorId", creatorId).getResultList();
}

public List<Dataset> findByReleaseUserId(Long releaseUserId) {
return em.createNamedQuery("Dataset.findByReleaseUserId").setParameter("releaseUserId", releaseUserId).getResultList();
}

public List<Dataset> filterByPidQuery(String filterQuery) {
// finds only exact matches
Dataset ds = findByGlobalId(filterQuery);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataverse.java
Expand Up @@ -50,6 +50,8 @@
@NamedQuery(name = "Dataverse.findRoot", query = "SELECT d FROM Dataverse d where d.owner.id=null"),
@NamedQuery(name = "Dataverse.findByAlias", query="SELECT dv FROM Dataverse dv WHERE LOWER(dv.alias)=:alias"),
@NamedQuery(name = "Dataverse.findByOwnerId", query="select object(o) from Dataverse as o where o.owner.id =:ownerId order by o.name"),
@NamedQuery(name = "Dataverse.findByCreatorId", query="select object(o) from Dataverse as o where o.creator.id =:creatorId order by o.name"),
@NamedQuery(name = "Dataverse.findByReleaseUserId", query="select object(o) from Dataverse as o where o.releaseUser.id =:releaseUserId order by o.name"),
@NamedQuery(name = "Dataverse.filterByAlias", query="SELECT dv FROM Dataverse dv WHERE LOWER(dv.alias) LIKE :alias order by dv.alias"),
@NamedQuery(name = "Dataverse.filterByAliasNameAffiliation", query="SELECT dv FROM Dataverse dv WHERE (LOWER(dv.alias) LIKE :alias) OR (LOWER(dv.name) LIKE :name) OR (LOWER(dv.affiliation) LIKE :affiliation) order by dv.alias"),
@NamedQuery(name = "Dataverse.filterByName", query="SELECT dv FROM Dataverse dv WHERE LOWER(dv.name) LIKE :name order by dv.alias")
Expand Down
Expand Up @@ -173,6 +173,14 @@ public List<Long> findDataverseIdsForIndexing(boolean skipIndexed) {

}

public List<Dataverse> findByCreatorId(Long creatorId) {
return em.createNamedQuery("Dataverse.findByCreatorId").setParameter("creatorId", creatorId).getResultList();
}

public List<Dataverse> findByReleaseUserId(Long releaseUserId) {
return em.createNamedQuery("Dataverse.findByReleaseUserId").setParameter("releaseUserId", releaseUserId).getResultList();
}

public List<Dataverse> findByOwnerId(Long ownerId) {
return em.createNamedQuery("Dataverse.findByOwnerId").setParameter("ownerId", ownerId).getResultList();
}
Expand Down
66 changes: 53 additions & 13 deletions src/main/java/edu/harvard/iq/dataverse/DataverseSession.java
Expand Up @@ -4,9 +4,12 @@
import edu.harvard.iq.dataverse.PermissionServiceBean.StaticPermissionQuery;
import edu.harvard.iq.dataverse.actionlogging.ActionLogRecord;
import edu.harvard.iq.dataverse.actionlogging.ActionLogServiceBean;
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.authorization.users.GuestUser;
import edu.harvard.iq.dataverse.authorization.users.User;
import edu.harvard.iq.dataverse.util.BundleUtil;
import edu.harvard.iq.dataverse.util.JsfHelper;
import edu.harvard.iq.dataverse.util.SessionUtil;
import edu.harvard.iq.dataverse.util.SystemConfig;
import java.io.IOException;
Expand Down Expand Up @@ -54,7 +57,10 @@ public class DataverseSession implements Serializable{

@EJB
BannerMessageServiceBean bannerMessageService;


@EJB
AuthenticationServiceBean authenticationService;

private static final Logger logger = Logger.getLogger(DataverseSession.class.getCanonicalName());

private boolean statusDismissed = false;
Expand Down Expand Up @@ -84,26 +90,70 @@ public void setDismissedMessages(List<BannerMessage> dismissedMessages) {
private Boolean debug;

public User getUser() {
return getUser(false);
}

/**
* For performance reasons, we only lookup the authenticated user again (to
* check if it has been deleted or deactivated, for example) when we have
* to.
*
* @param lookupAuthenticatedUserAgain A boolean to indicate if we should go
* to the database again to lookup the user to get the latest values that
* may have been updated outside the session.
*/
public User getUser(boolean lookupAuthenticatedUserAgain) {
if ( user == null ) {
user = GuestUser.get();
}

if (lookupAuthenticatedUserAgain && user instanceof AuthenticatedUser) {
AuthenticatedUser auFromSession = (AuthenticatedUser) user;
AuthenticatedUser auFreshLookup = authenticationService.findByID(auFromSession.getId());
if (auFreshLookup == null) {
logger.fine("getUser found user no longer exists (was deleted). Returning GuestUser.");
user = GuestUser.get();
} else {
if (auFreshLookup.isDeactivated()) {
logger.fine("getUser found user is deactivated. Returning GuestUser.");
user = GuestUser.get();
}
}
}
return user;
}

/**
* Sets the user and configures the session timeout.
*/
public void setUser(User aUser) {

// We check for deactivated status here in "setUser" to ensure a common user
// experience across Builtin, Shib, OAuth, and OIDC users.
// If we want a different user experience for Builtin users, we can
// modify getUpdateAuthenticatedUser in AuthenticationServiceBean
// (and probably other places).
if (aUser instanceof AuthenticatedUser && aUser.isDeactivated()) {
logger.info("Login attempt by deactivated user " + aUser.getIdentifier() + ".");
JsfHelper.addErrorMessage(BundleUtil.getStringFromBundle("deactivated.error"));
return;
}
FacesContext context = FacesContext.getCurrentInstance();
// Log the login/logout and Change the session id if we're using the UI and have
// a session, versus an API call with no session - (i.e. /admin/submitToArchive()
// which sets the user in the session to pass it through to the underlying command)
// TODO: reformat to remove tabs etc.
if(context != null) {
logSvc.log(
new ActionLogRecord(ActionLogRecord.ActionType.SessionManagement,(aUser==null) ? "logout" : "login")
.setUserIdentifier((aUser!=null) ? aUser.getIdentifier() : (user!=null ? user.getIdentifier() : "") ));

//#3254 - change session id when user changes
SessionUtil.changeSessionId((HttpServletRequest) context.getExternalContext().getRequest());
HttpSession httpSession = (HttpSession) context.getExternalContext().getSession(false);
if (httpSession != null) {
// Configure session timeout.
logger.fine("jsession: " + httpSession.getId() + " setting the lifespan of the session to " + systemConfig.getLoginSessionTimeout() + " minutes");
httpSession.setMaxInactiveInterval(systemConfig.getLoginSessionTimeout() * 60); // session timeout, in seconds
}
}
this.user = aUser;
}
Expand Down Expand Up @@ -208,15 +258,5 @@ public void dismissMessage(BannerMessage message){
}

}

public void configureSessionTimeout() {
HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);

if (httpSession != null) {
logger.fine("jsession: "+httpSession.getId()+" setting the lifespan of the session to " + systemConfig.getLoginSessionTimeout() + " minutes");
httpSession.setMaxInactiveInterval(systemConfig.getLoginSessionTimeout() * 60); // session timeout, in seconds
}

}

}