Search in sources :

Example 11 with ProviderConfigProperty

use of org.keycloak.provider.ProviderConfigProperty in project keycloak by keycloak.

the class NameIdMapperHelper method setConfigProperties.

public static void setConfigProperties(List<ProviderConfigProperty> configProperties) {
    ProviderConfigProperty property = new ProviderConfigProperty();
    property.setName(NameIdMapperHelper.MAPPER_NAMEID_FORMAT);
    property.setLabel(NameIdMapperHelper.MAPPER_NAMEID_FORMAT_LABEL);
    property.setHelpText(NameIdMapperHelper.MAPPER_NAMEID_FORMAT_HELP_TEXT);
    List<String> types = new ArrayList<String>();
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_X509SUBJECTNAME.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_WINDOWS_DOMAIN_NAME.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_KERBEROS.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_ENTITY.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get());
    types.add(JBossSAMLURIConstants.NAMEID_FORMAT_TRANSIENT.get());
    property.setType(ProviderConfigProperty.LIST_TYPE);
    property.setOptions(types);
    configProperties.add(property);
}
Also used : ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) ArrayList(java.util.ArrayList)

Example 12 with ProviderConfigProperty

use of org.keycloak.provider.ProviderConfigProperty in project keycloak by keycloak.

the class StripSecretsUtils method strip.

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;
}
Also used : ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) List(java.util.List) Map(java.util.Map) MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap)

Example 13 with ProviderConfigProperty

use of org.keycloak.provider.ProviderConfigProperty in project keycloak by keycloak.

the class ComponentUtil method getComponentConfigProperties.

public static Map<String, ProviderConfigProperty> getComponentConfigProperties(KeycloakSession session, String providerType, String providerId) {
    try {
        ComponentFactory componentFactory = getComponentFactory(session, providerType, providerId);
        List<ProviderConfigProperty> l = componentFactory.getConfigProperties();
        Map<String, ProviderConfigProperty> properties = new HashMap<>();
        for (ProviderConfigProperty p : l) {
            properties.put(p.getName(), p);
        }
        List<ProviderConfigProperty> common = componentFactory.getCommonProviderConfigProperties();
        for (ProviderConfigProperty p : common) {
            properties.put(p.getName(), p);
        }
        return properties;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : HashMap(java.util.HashMap) ComponentFactory(org.keycloak.component.ComponentFactory) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty)

Example 14 with ProviderConfigProperty

use of org.keycloak.provider.ProviderConfigProperty in project keycloak by keycloak.

the class SetUserAttributeAuthenticatorFactory method getConfigProperties.

@Override
public List<ProviderConfigProperty> getConfigProperties() {
    ProviderConfigProperty attributeName = new ProviderConfigProperty();
    attributeName.setType(ProviderConfigProperty.STRING_TYPE);
    attributeName.setName(CONF_ATTR_NAME);
    attributeName.setLabel("Attribute name");
    attributeName.setHelpText("Name of the user attribute to set");
    ProviderConfigProperty attributeValue = new ProviderConfigProperty();
    attributeValue.setType(ProviderConfigProperty.STRING_TYPE);
    attributeValue.setName(CONF_ATTR_VALUE);
    attributeValue.setLabel("Attribute value");
    attributeValue.setHelpText("Value to set in the user attribute");
    return Arrays.asList(attributeName, attributeValue);
}
Also used : ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty)

Example 15 with ProviderConfigProperty

use of org.keycloak.provider.ProviderConfigProperty in project keycloak by keycloak.

the class ClientRegistrationPolicyResource method getProviders.

/**
 * Base path for retrieve providers with the configProperties properly filled
 *
 * @return
 */
@Path("providers")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Stream<ComponentTypeRepresentation> getProviders() {
    return session.getKeycloakSessionFactory().getProviderFactoriesStream(ClientRegistrationPolicy.class).map((ProviderFactory factory) -> {
        ClientRegistrationPolicyFactory clientRegFactory = (ClientRegistrationPolicyFactory) factory;
        List<ProviderConfigProperty> configProps = clientRegFactory.getConfigProperties(session);
        ComponentTypeRepresentation rep = new ComponentTypeRepresentation();
        rep.setId(clientRegFactory.getId());
        rep.setHelpText(clientRegFactory.getHelpText());
        rep.setProperties(ModelToRepresentation.toRepresentation(configProps));
        return rep;
    });
}
Also used : ClientRegistrationPolicy(org.keycloak.services.clientregistration.policy.ClientRegistrationPolicy) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) ProviderFactory(org.keycloak.provider.ProviderFactory) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) ClientRegistrationPolicyFactory(org.keycloak.services.clientregistration.policy.ClientRegistrationPolicyFactory) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)30 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 ComponentFactory (org.keycloak.component.ComponentFactory)3 ComponentTypeRepresentation (org.keycloak.representations.idm.ComponentTypeRepresentation)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 NoCache (org.jboss.resteasy.annotations.cache.NoCache)2 MultivaluedHashMap (org.keycloak.common.util.MultivaluedHashMap)2 ConfigPropertyRepresentation (org.keycloak.representations.idm.ConfigPropertyRepresentation)2 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 NotFoundException (javax.ws.rs.NotFoundException)1 ConfigurableAuthenticatorFactory (org.keycloak.authentication.ConfigurableAuthenticatorFactory)1 SubComponentFactory (org.keycloak.component.SubComponentFactory)1 ConfiguredProvider (org.keycloak.provider.ConfiguredProvider)1