Search in sources :

Example 26 with MultivaluedHashMap

use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.

the class CredentialModelBackwardsCompatibilityTest method testCredentialModelConfigMap.

@Test
public void testCredentialModelConfigMap() {
    MultivaluedHashMap<String, String> map = new MultivaluedHashMap<>();
    map.add("key1", "val11");
    map.add("key1", "val12");
    map.add("key2", "val21");
    CredentialModel credential = new CredentialModel();
    Assert.assertNull(credential.getConfig());
    credential.setConfig(map);
    MultivaluedHashMap<String, String> loadedMap = credential.getConfig();
    Assert.assertEquals(map, loadedMap);
}
Also used : MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) CredentialModel(org.keycloak.credential.CredentialModel) PasswordCredentialModel(org.keycloak.models.credential.PasswordCredentialModel) OTPCredentialModel(org.keycloak.models.credential.OTPCredentialModel) Test(org.junit.Test)

Example 27 with MultivaluedHashMap

use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.

the class JpaUserFederatedStorageProvider method getAttributes.

@Override
public MultivaluedHashMap<String, String> getAttributes(RealmModel realm, String userId) {
    TypedQuery<FederatedUserAttributeEntity> query = em.createNamedQuery("getFederatedAttributesByUser", FederatedUserAttributeEntity.class);
    List<FederatedUserAttributeEntity> list = query.setParameter("userId", userId).setParameter("realmId", realm.getId()).getResultList();
    MultivaluedHashMap<String, String> result = new MultivaluedHashMap<>();
    for (FederatedUserAttributeEntity entity : list) {
        result.add(entity.getName(), entity.getValue());
    }
    return result;
}
Also used : MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) FederatedUserAttributeEntity(org.keycloak.storage.jpa.entity.FederatedUserAttributeEntity)

Example 28 with MultivaluedHashMap

use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.

the class UserAdapter method getAttributes.

@Override
public Map<String, List<String>> getAttributes() {
    MultivaluedHashMap<String, String> result = new MultivaluedHashMap<>();
    for (UserAttributeEntity attr : user.getAttributes()) {
        result.add(attr.getName(), attr.getValue());
    }
    result.add(UserModel.FIRST_NAME, user.getFirstName());
    result.add(UserModel.LAST_NAME, user.getLastName());
    result.add(UserModel.EMAIL, user.getEmail());
    result.add(UserModel.USERNAME, user.getUsername());
    return result;
}
Also used : MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) UserAttributeEntity(org.keycloak.models.jpa.entities.UserAttributeEntity)

Example 29 with MultivaluedHashMap

use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.

the class AbstractGeneratedRsaKeyProviderFactory method createFallbackKeys.

@Override
public boolean createFallbackKeys(KeycloakSession session, KeyUse keyUse, String algorithm) {
    if (isValidKeyUse(keyUse) && isSupportedRsaAlgorithm(algorithm)) {
        RealmModel realm = session.getContext().getRealm();
        ComponentModel generated = new ComponentModel();
        generated.setName("fallback-" + algorithm);
        generated.setParentId(realm.getId());
        generated.setProviderId(getId());
        generated.setProviderType(KeyProvider.class.getName());
        MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
        config.putSingle(Attributes.PRIORITY_KEY, "-100");
        config.putSingle(Attributes.ALGORITHM_KEY, algorithm);
        generated.setConfig(config);
        realm.addComponentModel(generated);
        return true;
    } else {
        return false;
    }
}
Also used : RealmModel(org.keycloak.models.RealmModel) MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) ComponentModel(org.keycloak.component.ComponentModel)

Example 30 with MultivaluedHashMap

use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.

the class GeneratedAesKeyProviderFactory method createFallbackKeys.

@Override
public boolean createFallbackKeys(KeycloakSession session, KeyUse keyUse, String algorithm) {
    if (keyUse.equals(KeyUse.ENC) && algorithm.equals(Algorithm.AES)) {
        RealmModel realm = session.getContext().getRealm();
        ComponentModel generated = new ComponentModel();
        generated.setName("fallback-" + algorithm);
        generated.setParentId(realm.getId());
        generated.setProviderId(ID);
        generated.setProviderType(KeyProvider.class.getName());
        MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
        config.putSingle(Attributes.PRIORITY_KEY, "-100");
        generated.setConfig(config);
        realm.addComponentModel(generated);
        return true;
    } else {
        return false;
    }
}
Also used : RealmModel(org.keycloak.models.RealmModel) MultivaluedHashMap(org.keycloak.common.util.MultivaluedHashMap) ComponentModel(org.keycloak.component.ComponentModel)

Aggregations

MultivaluedHashMap (org.keycloak.common.util.MultivaluedHashMap)44 ComponentModel (org.keycloak.component.ComponentModel)15 List (java.util.List)9 LinkedList (java.util.LinkedList)8 Map (java.util.Map)8 KeyProvider (org.keycloak.keys.KeyProvider)8 RealmModel (org.keycloak.models.RealmModel)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ComponentExportRepresentation (org.keycloak.representations.idm.ComponentExportRepresentation)6 IOException (java.io.IOException)5 HttpSession (javax.servlet.http.HttpSession)5 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)5 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)5 RoleModel (org.keycloak.models.RoleModel)4 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 ClientModel (org.keycloak.models.ClientModel)3 ClientScopeModel (org.keycloak.models.ClientScopeModel)3 BufferedReader (java.io.BufferedReader)2