Java Code Examples for org.keycloak.provider.ProviderConfigProperty#isSecret()
The following examples show how to use
org.keycloak.provider.ProviderConfigProperty#isSecret() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StripSecretsUtils.java From keycloak with Apache License 2.0 | 6 votes |
public static ComponentRepresentation strip(KeycloakSession session, ComponentRepresentation rep) { Map<String, ProviderConfigProperty> configProperties = ComponentUtil.getComponentConfigProperties(session, rep); if (rep.getConfig() == null) { return rep; } Iterator<Map.Entry<String, List<String>>> itr = rep.getConfig().entrySet().iterator(); while (itr.hasNext()) { Map.Entry<String, List<String>> next = itr.next(); ProviderConfigProperty configProperty = configProperties.get(next.getKey()); if (configProperty != null) { if (configProperty.isSecret()) { if (next.getValue() == null || next.getValue().isEmpty()) { next.setValue(Collections.singletonList(ComponentRepresentation.SECRET_VALUE)); } else { next.setValue(next.getValue().stream().map(StripSecretsUtils::maskNonVaultValue).collect(Collectors.toList())); } } } else { itr.remove(); } } return rep; }
Example 2
Source File: StripSecretsUtils.java From keycloak with Apache License 2.0 | 5 votes |
public static ComponentExportRepresentation strip(KeycloakSession session, String providerType, ComponentExportRepresentation rep) { Map<String, ProviderConfigProperty> configProperties = ComponentUtil.getComponentConfigProperties(session, providerType, rep.getProviderId()); if (rep.getConfig() == null) { return rep; } Iterator<Map.Entry<String, List<String>>> itr = rep.getConfig().entrySet().iterator(); while (itr.hasNext()) { Map.Entry<String, List<String>> next = itr.next(); ProviderConfigProperty configProperty = configProperties.get(next.getKey()); if (configProperty != null) { if (configProperty.isSecret()) { if (next.getValue() == null || next.getValue().isEmpty()) { next.setValue(Collections.singletonList(ComponentRepresentation.SECRET_VALUE)); } else { next.setValue(next.getValue().stream().map(StripSecretsUtils::maskNonVaultValue).collect(Collectors.toList())); } } } else { itr.remove(); } } MultivaluedHashMap<String, ComponentExportRepresentation> sub = rep.getSubComponents(); for (Map.Entry<String, List<ComponentExportRepresentation>> ent: sub.entrySet()) { for (ComponentExportRepresentation c: ent.getValue()) { strip(session, ent.getKey(), c); } } return rep; }