Skip to content

Commit

Permalink
IdCachedServicesImpl dirty cache on create (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximthomas authored Mar 1, 2024
1 parent 9f36cd6 commit 2d73a7f
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ private void dirtyCache(String dn) {
idRepoExists.invalidate(key);
idRepoActive.invalidate(key);
invalidateMembersAndMemberships(key);

}

private void invalidateMembersAndMemberships(String key) {
Expand Down Expand Up @@ -651,7 +650,7 @@ public Map getAttributes(SSOToken token, IdType type, String name,
}

public void setActiveStatus(SSOToken token, IdType type, String name,
String amOrgName, String amsdkDN, boolean active) throws SSOException,
String amOrgName, String amsdkDN, boolean active) throws SSOException,
IdRepoException {
super.setActiveStatus(token, type, name, amOrgName, amsdkDN, active);
AMIdentity id = new AMIdentity(token, name, type, amOrgName, amsdkDN);
Expand Down Expand Up @@ -696,8 +695,16 @@ public void modifyMemberShip(SSOToken token, IdType type, String name, Set membe
}
}

@Override
public AMIdentity create(SSOToken token, IdType type, String name, Map attrMap, String amOrgName) throws IdRepoException, SSOException {
AMIdentity id = super.create(token, type, name, attrMap, amOrgName);
final String key=id.getUniversalId().toLowerCase();
dirtyCache(key);
return id;
}

public void delete(SSOToken token, IdType type, String name,
String orgName, String amsdkDN) throws IdRepoException,
String orgName, String amsdkDN) throws IdRepoException,
SSOException {
// Call parent to delete the entry
super.delete(token, type, name, orgName, amsdkDN);
Expand Down Expand Up @@ -760,8 +767,10 @@ public IdSearchResults search(SSOToken token, IdType type, IdSearchControl ctrl,
AMIdentity uvid = new AMIdentity(token, pattern, type, orgName, null);
String universalID = uvid.getUniversalId().toLowerCase();
IdCacheBlock cb = idRepoCache.getIfPresent(universalID);
if ((cb != null) && !cb.hasExpiredAndUpdated() && cb.isExists() &&
(ctrl.getSearchModifierMap() == null)) {
if ((cb != null)
&& !cb.hasExpiredAndUpdated()
&& cb.isExists()
&& ctrl.getSearchModifierMap() == null) {
// Check if search is for a specific identity
// Search is for a specific user, look in the cache
Map attributes;
Expand Down Expand Up @@ -790,9 +799,7 @@ public IdSearchResults search(SSOToken token, IdType type, IdSearchControl ctrl,
throw (ide);
}
}
}else {
final AMIdentity tokenId = IdUtils.getIdentity(token);
final String principalDN = IdUtils.getUniversalId(tokenId);
} else {
final IdSearchResults res=super.search(token, type, ctrl, orgName, crestQuery);
try {
for (AMIdentity idm : (Set<AMIdentity>)res.getSearchResults()) {
Expand Down

0 comments on commit 2d73a7f

Please sign in to comment.