Skip to content

Commit

Permalink
Fixing IDENTITY-4498
Browse files Browse the repository at this point in the history
  • Loading branch information
IsuraD committed Apr 11, 2016
1 parent fed258d commit 5a8df64
Showing 1 changed file with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,19 @@ public boolean doPostAuthenticate(String userName, boolean authenticated,
if (!isEnable()) {
return true;
}
if(!userStoreManager.isReadOnly() && authenticated){
userStoreManager.setUserClaimValue(userName, IdentityMgtConstants.LAST_LOGIN_TIME, Long.toString(System
.currentTimeMillis()), null);

if (!userStoreManager.isReadOnly() && authenticated) {
String domainName = userStoreManager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
String usernameWithDomain = UserCoreUtil.addDomainToName(userName, domainName);
boolean isUserExistInCurrentDomain = userStoreManager.isExistingUser(usernameWithDomain);
if (isUserExistInCurrentDomain) {
Map<String, String> userClaims = new HashMap<>();
userClaims.put(IdentityMgtConstants.LAST_LOGIN_TIME, Long.toString(System
.currentTimeMillis()));
userStoreManager.setUserClaimValues(userName, userClaims, null);
}
}

// Top level try and finally blocks are used to unset thread local variables
try {
if (!IdentityUtil.threadLocalProperties.get().containsKey(DO_POST_AUTHENTICATE)) {
Expand Down Expand Up @@ -703,8 +712,15 @@ public boolean doPostUpdateCredentialByAdmin(String userName, Object credential,
return true;
}
if (!userStoreManager.isReadOnly()) {
userStoreManager.setUserClaimValue(userName, IdentityMgtConstants.LAST_PASSWORD_UPDATE_TIME, Long
.toString(System.currentTimeMillis()), null);
String domainName = userStoreManager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
String usernameWithDomain = UserCoreUtil.addDomainToName(userName, domainName);
boolean isUserExistInCurrentDomain = userStoreManager.isExistingUser(usernameWithDomain);
if (isUserExistInCurrentDomain) {
Map<String, String> userClaims = new HashMap<>();
userClaims.put(IdentityMgtConstants.LAST_PASSWORD_UPDATE_TIME, Long
.toString(System.currentTimeMillis()));
userStoreManager.setUserClaimValues(userName, userClaims, null);
}
}
return true;

Expand Down Expand Up @@ -1003,8 +1019,15 @@ public boolean doPostUpdateCredential(String userName, Object credential, UserSt
return true;
}
if (!userStoreManager.isReadOnly()) {
userStoreManager.setUserClaimValue(userName, IdentityMgtConstants.LAST_PASSWORD_UPDATE_TIME, Long
.toString(System.currentTimeMillis()), null);
String domainName = userStoreManager.getRealmConfiguration().getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
String usernameWithDomain = UserCoreUtil.addDomainToName(userName, domainName);
boolean isUserExistInCurrentDomain = userStoreManager.isExistingUser(usernameWithDomain);
if (isUserExistInCurrentDomain) {
Map<String, String> userClaims = new HashMap<>();
userClaims.put(IdentityMgtConstants.LAST_PASSWORD_UPDATE_TIME, Long
.toString(System.currentTimeMillis()));
userStoreManager.setUserClaimValues(userName, userClaims, null);
}
}
return true;

Expand Down

0 comments on commit 5a8df64

Please sign in to comment.