Skip to content

Commit 8289866

Browse files
committed
UY-1517 always set some name for an IdP
even when there is no english name defined
1 parent f19ddec commit 8289866

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

saml/src/main/java/pl/edu/icm/unity/saml/metadata/cfg/MetadataToSPConfigConverter.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.Collections;
1717
import java.util.HashMap;
1818
import java.util.HashSet;
19+
import java.util.LinkedHashMap;
1920
import java.util.List;
2021
import java.util.Map;
2122
import java.util.Set;
@@ -270,8 +271,8 @@ private boolean evaluateFilterCondition(String condition, Serializable compiledC
270271
log.trace("Condition evaluated for IDP of entity {} is evaluated to null value, assuming false.", entityId);
271272
return false;
272273
}
273-
log.trace("Condition \"{}\" evaluated for IDP of entity {} is evaluated to {}", condition, entityId, result.booleanValue());
274-
return result.booleanValue();
274+
log.trace("Condition \"{}\" evaluated for IDP of entity {} is evaluated to {}", condition, entityId, result);
275+
return result;
275276
}
276277

277278

@@ -450,8 +451,7 @@ private static String getCertificateKey(X509Certificate cert, String entityId, S
450451
{
451452
String dn = X500NameUtils.getComparableForm(cert.getSubjectX500Principal().getName());
452453
String serial = cert.getSerialNumber().toString();
453-
String key = prefix + DigestUtils.md5Hex(entityId) + "#" + DigestUtils.md5Hex(dn) + "#" + serial;
454-
return key;
454+
return prefix + DigestUtils.md5Hex(entityId) + "#" + DigestUtils.md5Hex(dn) + "#" + serial;
455455
}
456456

457457

@@ -490,13 +490,20 @@ private I18nString getLocalizedNamesAsI18nString(UIInfoType uiInfo,
490490
ret.addAllValues(localizedNames);
491491
if (localizedNames.containsKey(""))
492492
ret.setDefaultValue(localizedNames.get(""));
493+
else if (!localizedNames.isEmpty())
494+
ret.setDefaultValue(localizedNames.values().iterator().next());
495+
else
496+
{
497+
ret.setDefaultValue("Unnamed Identity Provider");
498+
log.warn("IdP {} has no name set", idpDesc.getID());
499+
}
493500
return ret;
494501
}
495502

496503
private Map<String, String> getLocalizedNames(UIInfoType uiInfo,
497504
SSODescriptorType idpDesc, EntityDescriptorType mainDescriptor)
498505
{
499-
Map<String, String> ret = new HashMap<>();
506+
Map<String, String> ret = new LinkedHashMap<>();
500507
OrganizationType mainOrg = mainDescriptor.getOrganization();
501508
if (mainOrg != null)
502509
{
@@ -521,7 +528,7 @@ private static I18nString getLocalizedLogosAsI18nString(UIInfoType uiInfo)
521528
I18nString ret = new I18nString();
522529
Map<String, LogoType> asMap = getLocalizedLogos(uiInfo);
523530
ret.addAllValues(asMap.entrySet().stream()
524-
.collect(Collectors.toMap(entry -> entry.getKey(),
531+
.collect(Collectors.toMap(Map.Entry::getKey,
525532
entry -> entry.getValue().getStringValue())));
526533
if (asMap.containsKey(""))
527534
ret.setDefaultValue(asMap.get("").getStringValue());

0 commit comments

Comments
 (0)