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

Issue #19785: When calling isValidGroup on a federated SAF registry w… #19786

Merged
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 IBM Corporation and others.
* Copyright (c) 2012, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -222,7 +222,7 @@ private void setMapping() {
*
* @return
*/

@SuppressWarnings("unchecked")
public void initialize(Map<String, Object> configProps) throws WIMException {
try {
reposId = (String) configProps.get(KEY_ID);
Expand Down Expand Up @@ -287,7 +287,7 @@ public void initialize(Map<String, Object> configProps) throws WIMException {
* should have only 1 baseEntry
*
* @param configProps Map containing the configuration information
* for the baseEntries.
* for the baseEntries.
* @throws WIMException Exception is thrown if no baseEntry is set.
*/
private void setBaseEntry(Map<String, Object> configProps) throws WIMException {
Expand Down Expand Up @@ -340,7 +340,7 @@ private void setCustomProperties(List<Map<String, String>> propList) throws WIME
* @param configProps map containing the configuration information.
*
* @throws WIMException throw when there is not a mapping for a user
* or not a mapping for a group.
* or not a mapping for a group.
*/
private void setConfigEntityMapping(Map<String, Object> configProps) throws WIMException {
List<String> entityTypes = getSupportedEntityTypes();
Expand Down Expand Up @@ -384,11 +384,11 @@ private List<String> getSupportedEntityTypes() {
* Get the information about Users and Groups from the underlying User Registry
*
* @param root Input object containing set identifiers of objects to be fetched,
* and optionally control objects.
* and optionally control objects.
*
* @throws WIMException improper control objects are in the input datagraph,
* invalid properties are in a propertyControl object,or the underlying
* user registry throws an exception.
* invalid properties are in a propertyControl object,or the underlying
* user registry throws an exception.
*
* @return A Root object containing the required Person(s) or Group(s)
*
Expand Down Expand Up @@ -520,7 +520,7 @@ public String buildRDN(String value) {
* Get the attributes requested for the entity.
*
* @param controlObject the control object containing the attributes.
* @param type the type of object the attributes are requested for. Group or Person.
* @param type the type of object the attributes are requested for. Group or Person.
*/
private List<String> getAttributes(PropertyControl control, String type) throws WIMException {
List<String> attrList = new ArrayList<String>(10);
Expand Down Expand Up @@ -708,7 +708,7 @@ private String[] getEntityTypeFromUniqueName(String secName, List<String> entity
}
} else {
if (entityType.contains(personAccountType) || noSpecificEntityType) {
List<String> resultList = searchUsers(secName, 1).getList();
List<String> resultList = searchUsers(secName, 1).getList();

if (resultList.size() > 0) {
typeList.add(personAccountType);
Expand Down Expand Up @@ -1278,26 +1278,6 @@ public Root update(Root root) throws WIMException {
WIMMessageHelper.generateMsgParms(reposId)));
}

/**
* @param returnRoot
*/
private boolean isURBridgeResult(Root returnRoot) {
// Check if there is a valid response
if (returnRoot != null && !returnRoot.getEntities().isEmpty()) {
// Determine if the return object to check if the context was set.
List<Context> contexts = returnRoot.getContexts();
for (Context context : contexts) {
String key = context.getKey();

if (key != null && SchemaConstantsInternal.IS_URBRIDGE_RESULT.equals(key)) {
if ("true".equalsIgnoreCase((String) context.getValue()))
return true;
}
}
}
return false;
}

/**
* Is the entity in this realm?
*
Expand All @@ -1309,29 +1289,35 @@ public boolean isEntityInRealm(String uniqueName) {

if (isSafRegistry()) {
try {
return userRegistry.isValidUser(uniqueName);
if (userRegistry.isValidUser(uniqueName)) {
return true;
}
} catch (Exception e) {
/* Ignore. */
}

try {
return userRegistry.isValidGroup(uniqueName);
if (userRegistry.isValidGroup(uniqueName)) {
return true;
}
} catch (Exception e) {
/* Ignore. */
}
} else {
try {
SearchResult result = userRegistry.getUsers(uniqueName, 1);
if (result != null && result.getList().size() > 0)
if (result != null && result.getList().size() > 0) {
return true;
}
} catch (Exception e) {
/* Ignore. */
}

try {
SearchResult result = userRegistry.getGroups(uniqueName, 1);
if (result != null && result.getList().size() > 0)
if (result != null && result.getList().size() > 0) {
return true;
}
} catch (Exception e) {
/* Ignore. */
}
Expand Down