use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.
the class ResourceAdminManager method logoutClientSessions.
protected Response logoutClientSessions(RealmModel realm, ClientModel resource, List<AuthenticatedClientSessionModel> clientSessions) {
String managementUrl = getManagementUrl(session, resource);
if (managementUrl != null) {
// Key is host, value is list of http sessions for this host
MultivaluedHashMap<String, String> adapterSessionIds = null;
List<String> userSessions = new LinkedList<>();
if (clientSessions != null && clientSessions.size() > 0) {
adapterSessionIds = new MultivaluedHashMap<String, String>();
for (AuthenticatedClientSessionModel clientSession : clientSessions) {
String adapterSessionId = clientSession.getNote(AdapterConstants.CLIENT_SESSION_STATE);
if (adapterSessionId != null) {
String host = clientSession.getNote(AdapterConstants.CLIENT_SESSION_HOST);
adapterSessionIds.add(host, adapterSessionId);
}
if (clientSession.getUserSession() != null)
userSessions.add(clientSession.getUserSession().getId());
}
}
if (adapterSessionIds == null || adapterSessionIds.isEmpty()) {
logger.debugv("Can't logout {0}: no logged adapter sessions", resource.getClientId());
return null;
}
if (managementUrl.contains(CLIENT_SESSION_HOST_PROPERTY)) {
// Send logout separately to each host (needed for single-sign-out in cluster for non-distributable apps - KEYCLOAK-748)
for (Map.Entry<String, List<String>> entry : adapterSessionIds.entrySet()) {
String host = entry.getKey();
List<String> sessionIds = entry.getValue();
String currentHostMgmtUrl = managementUrl.replace(CLIENT_SESSION_HOST_PROPERTY, host);
sendLogoutRequest(realm, resource, sessionIds, userSessions, 0, currentHostMgmtUrl);
}
return Response.ok().build();
} else {
// Send single logout request
List<String> allSessionIds = new ArrayList<String>();
for (List<String> currentIds : adapterSessionIds.values()) {
allSessionIds.addAll(currentIds);
}
return sendLogoutRequest(realm, resource, allSessionIds, userSessions, 0, managementUrl);
}
} else {
logger.debugv("Can't logout {0}: no management url", resource.getClientId());
return null;
}
}
use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.
the class LDAPMappersComparatorTest method testCompareWithSAMAccountNameUsername.
@Test
public void testCompareWithSAMAccountNameUsername() {
MultivaluedHashMap<String, String> cfg = new MultivaluedHashMap<>();
cfg.add(LDAPConstants.USERNAME_LDAP_ATTRIBUTE, LDAPConstants.SAM_ACCOUNT_NAME);
LDAPMappersComparator ldapMappersComparator = new LDAPMappersComparator(new LDAPConfig(cfg));
List<ComponentModel> mappers = getMappers();
Collections.sort(mappers, ldapMappersComparator.sortAsc());
assertOrder(mappers, "sAMAccountName", "username-cn", "first name", "full name");
Collections.sort(mappers, ldapMappersComparator.sortDesc());
assertOrder(mappers, "full name", "first name", "username-cn", "sAMAccountName");
}
use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.
the class SSSDTest method createUserFederation.
@Before
public void createUserFederation() {
ComponentRepresentation userFederation = new ComponentRepresentation();
MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
userFederation.setConfig(config);
userFederation.setName(DISPLAY_NAME);
userFederation.getConfig().putSingle("priority", "0");
userFederation.setProviderType(UserStorageProvider.class.getName());
userFederation.setProviderId(PROVIDER_NAME);
Response response = adminClient.realm(REALM_NAME).components().add(userFederation);
SSSDFederationID = ApiUtil.getCreatedId(response);
response.close();
}
use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.
the class ComponentInvalidationClusterTest method createTestEntityRepresentation.
@Override
protected ComponentRepresentation createTestEntityRepresentation() {
ComponentRepresentation comp = new ComponentRepresentation();
MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
comp.setName("comp_" + RandomStringUtils.randomAlphabetic(5));
comp.setProviderId(TestAmphibianProviderFactoryImpl.PROVIDER_ID);
comp.setProviderType(TestAmphibianProvider.class.getName());
config.putSingle("secret", "Secret");
config.putSingle("required", "required-value");
config.putSingle("number", "2");
config.put("val1", Arrays.asList(new String[] { "val1 value" }));
config.put("val2", Arrays.asList(new String[] { "val2 value" }));
comp.setConfig(config);
return comp;
}
use of org.keycloak.common.util.MultivaluedHashMap in project keycloak by keycloak.
the class DefaultKeyProviders method createRsaEncKeyProvider.
private static void createRsaEncKeyProvider(String name, RealmModel realm) {
ComponentModel generated = new ComponentModel();
generated.setName(name);
generated.setParentId(realm.getId());
generated.setProviderId("rsa-enc-generated");
generated.setProviderType(KeyProvider.class.getName());
MultivaluedHashMap<String, String> config = new MultivaluedHashMap<>();
config.putSingle("priority", "100");
config.putSingle("keyUse", KeyUse.ENC.name());
config.putSingle("algorithm", JWEConstants.RSA_OAEP);
generated.setConfig(config);
realm.addComponentModel(generated);
}
Aggregations