Search in sources :

Example 56 with ClientScopeModel

use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.

the class SamlProtocolFactory method createDefaultClientScopesImpl.

@Override
protected void createDefaultClientScopesImpl(RealmModel newRealm) {
    ClientScopeModel roleListScope = newRealm.addClientScope(SCOPE_ROLE_LIST);
    roleListScope.setDescription("SAML role list");
    roleListScope.setDisplayOnConsentScreen(true);
    roleListScope.setConsentScreenText(ROLE_LIST_CONSENT_TEXT);
    roleListScope.setProtocol(getId());
    roleListScope.addProtocolMapper(builtins.get("role list"));
    newRealm.addDefaultClientScope(roleListScope, true);
}
Also used : ClientScopeModel(org.keycloak.models.ClientScopeModel)

Example 57 with ClientScopeModel

use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.

the class UPConfigUtils method validateScopes.

private static void validateScopes(Set<String> scopes, String propertyName, String attributeName, List<String> errors, KeycloakSession session) {
    if (scopes == null) {
        return;
    }
    for (String scope : scopes) {
        RealmModel realm = session.getContext().getRealm();
        Stream<ClientScopeModel> realmScopes = realm.getClientScopesStream();
        if (!realmScopes.anyMatch(cs -> cs.getName().equals(scope))) {
            errors.add(new StringBuilder("'").append(propertyName).append("' configuration for attribute '").append(attributeName).append("' contains unsupported scope '").append(scope).append("'").toString());
        }
    }
}
Also used : RealmModel(org.keycloak.models.RealmModel) ClientScopeModel(org.keycloak.models.ClientScopeModel) RealmModel(org.keycloak.models.RealmModel) ValidatorConfig(org.keycloak.validate.ValidatorConfig) ValidationResult(org.keycloak.validate.ValidationResult) Set(java.util.Set) KeycloakSession(org.keycloak.models.KeycloakSession) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) JsonSerialization(org.keycloak.util.JsonSerialization) List(java.util.List) Validators(org.keycloak.validate.Validators) ObjectUtil.isBlank(org.keycloak.common.util.ObjectUtil.isBlank) Stream(java.util.stream.Stream) Charset(java.nio.charset.Charset) Map(java.util.Map) UserProfileContext(org.keycloak.userprofile.UserProfileContext) StreamUtil(org.keycloak.common.util.StreamUtil) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) InputStream(java.io.InputStream) ClientScopeModel(org.keycloak.models.ClientScopeModel)

Example 58 with ClientScopeModel

use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.

the class HardcodedClientStorageProvider method getClientScopes.

@Override
public Map<String, ClientScopeModel> getClientScopes(RealmModel realm, ClientModel client, boolean defaultScope) {
    if (defaultScope) {
        ClientScopeModel rolesScope = KeycloakModelUtils.getClientScopeByName(realm, OIDCLoginProtocolFactory.ROLES_SCOPE);
        ClientScopeModel webOriginsScope = KeycloakModelUtils.getClientScopeByName(realm, OIDCLoginProtocolFactory.WEB_ORIGINS_SCOPE);
        return Arrays.asList(rolesScope, webOriginsScope).stream().collect(Collectors.toMap(ClientScopeModel::getName, clientScope -> clientScope));
    } else {
        ClientScopeModel offlineScope = KeycloakModelUtils.getClientScopeByName(realm, "offline_access");
        return Collections.singletonMap("offline_access", offlineScope);
    }
}
Also used : ClientModel(org.keycloak.models.ClientModel) ClientStorageProviderModel(org.keycloak.storage.client.ClientStorageProviderModel) ClientStorageProvider(org.keycloak.storage.client.ClientStorageProvider) Arrays(java.util.Arrays) ClientScopeModel(org.keycloak.models.ClientScopeModel) RealmModel(org.keycloak.models.RealmModel) ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel) KeycloakModelUtils(org.keycloak.models.utils.KeycloakModelUtils) Logger(org.jboss.logging.Logger) ClientLookupProvider(org.keycloak.storage.client.ClientLookupProvider) KeycloakSession(org.keycloak.models.KeycloakSession) Set(java.util.Set) RoleModel(org.keycloak.models.RoleModel) Collectors(java.util.stream.Collectors) StorageId(org.keycloak.storage.StorageId) HashSet(java.util.HashSet) AbstractReadOnlyClientStorageAdapter(org.keycloak.storage.client.AbstractReadOnlyClientStorageAdapter) Stream(java.util.stream.Stream) Map(java.util.Map) OIDCLoginProtocolFactory(org.keycloak.protocol.oidc.OIDCLoginProtocolFactory) Collections(java.util.Collections) ClientScopeModel(org.keycloak.models.ClientScopeModel)

Aggregations

ClientScopeModel (org.keycloak.models.ClientScopeModel)58 ClientModel (org.keycloak.models.ClientModel)22 RealmModel (org.keycloak.models.RealmModel)18 KeycloakSession (org.keycloak.models.KeycloakSession)17 UserConsentModel (org.keycloak.models.UserConsentModel)14 HashMap (java.util.HashMap)11 Map (java.util.Map)9 UserModel (org.keycloak.models.UserModel)9 HashSet (java.util.HashSet)8 Test (org.junit.Test)8 RoleModel (org.keycloak.models.RoleModel)8 MultivaluedHashMap (org.keycloak.common.util.MultivaluedHashMap)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 NotFoundException (javax.ws.rs.NotFoundException)6 ArtifactBindingUtils.computeArtifactBindingIdentifierString (org.keycloak.protocol.saml.util.ArtifactBindingUtils.computeArtifactBindingIdentifierString)6 ModelTest (org.keycloak.testsuite.arquillian.annotation.ModelTest)6 IOException (java.io.IOException)5 Path (javax.ws.rs.Path)5 NoCache (org.jboss.resteasy.annotations.cache.NoCache)5