use of org.keycloak.representations.info.ServerInfoRepresentation in project keycloak by keycloak.
the class ServerInfoAdminResource method getInfo.
/**
* Get themes, social providers, auth providers, and event listeners available on this server
*
* @return
*/
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public ServerInfoRepresentation getInfo() {
ServerInfoRepresentation info = new ServerInfoRepresentation();
info.setSystemInfo(SystemInfoRepresentation.create(session.getKeycloakSessionFactory().getServerStartupTimestamp()));
info.setMemoryInfo(MemoryInfoRepresentation.create());
info.setProfileInfo(ProfileInfoRepresentation.create());
setSocialProviders(info);
setIdentityProviders(info);
setThemes(info);
setProviders(info);
setProtocolMapperTypes(info);
setBuiltinProtocolMappers(info);
setClientInstallations(info);
setPasswordPolicies(info);
info.setEnums(ENUMS);
return info;
}
use of org.keycloak.representations.info.ServerInfoRepresentation in project keycloak by keycloak.
the class WebAuthnFeatureTest method testWebAuthnAvailability.
private void testWebAuthnAvailability(boolean expectedAvailability) {
ServerInfoRepresentation serverInfo = adminClient.serverInfo().getInfo();
Set<String> authenticatorProviderIds = serverInfo.getProviders().get(AuthenticatorSpi.SPI_NAME).getProviders().keySet();
Assert.assertEquals(expectedAvailability, authenticatorProviderIds.contains(WebAuthnAuthenticatorFactory.PROVIDER_ID));
}
use of org.keycloak.representations.info.ServerInfoRepresentation in project keycloak by keycloak.
the class ClientPoliciesFeatureTest method checkIfFeatureWorks.
// Check if the feature really works
private void checkIfFeatureWorks(boolean shouldWork) {
try {
ClientPoliciesRepresentation clientPolicies = testRealm().clientPoliciesPoliciesResource().getPolicies();
Assert.assertTrue(clientPolicies.getPolicies().isEmpty());
if (!shouldWork)
fail("Feature is available, but at this moment should be disabled");
} catch (Exception e) {
if (shouldWork) {
e.printStackTrace();
fail("Feature is not available");
}
}
ServerInfoRepresentation serverInfo = adminClient.serverInfo().getInfo();
Set<String> executorProviderIds = serverInfo.getProviders().get(ClientPolicyExecutorSpi.SPI_NAME).getProviders().keySet();
Set<String> conditionProviderIds = serverInfo.getProviders().get(ClientPolicyConditionSpi.SPI_NAME).getProviders().keySet();
if (shouldWork) {
Assert.assertTrue(executorProviderIds.contains(SecureResponseTypeExecutorFactory.PROVIDER_ID));
Assert.assertTrue(conditionProviderIds.contains(ClientUpdaterContextConditionFactory.PROVIDER_ID));
} else {
Assert.assertFalse(executorProviderIds.contains(SecureResponseTypeExecutorFactory.PROVIDER_ID));
Assert.assertFalse(conditionProviderIds.contains(ClientUpdaterContextConditionFactory.PROVIDER_ID));
}
}
use of org.keycloak.representations.info.ServerInfoRepresentation in project keycloak by keycloak.
the class ServerInfoAdminResource method setPasswordPolicies.
private void setPasswordPolicies(ServerInfoRepresentation info) {
List<PasswordPolicyTypeRepresentation> passwordPolicyTypes = session.getKeycloakSessionFactory().getProviderFactoriesStream(PasswordPolicyProvider.class).map(PasswordPolicyProviderFactory.class::cast).map(factory -> {
PasswordPolicyTypeRepresentation rep = new PasswordPolicyTypeRepresentation();
rep.setId(factory.getId());
rep.setDisplayName(factory.getDisplayName());
rep.setConfigType(factory.getConfigType());
rep.setDefaultValue(factory.getDefaultConfigValue());
rep.setMultipleSupported(factory.isMultiplSupported());
return rep;
}).collect(Collectors.toList());
info.setPasswordPolicies(passwordPolicyTypes);
}
use of org.keycloak.representations.info.ServerInfoRepresentation in project keycloak by keycloak.
the class ServerInfoTest method testServerInfo.
@Test
public void testServerInfo() {
ServerInfoRepresentation info = adminClient.serverInfo().getInfo();
assertNotNull(info);
assertNotNull(info.getProviders());
assertNotNull(info.getProviders().get("realm"));
assertNotNull(info.getProviders().get("user"));
assertNotNull(info.getProviders().get("authenticator"));
assertNotNull(info.getThemes());
assertNotNull(info.getThemes().get("account"));
assertNotNull(info.getThemes().get("admin"));
assertNotNull(info.getThemes().get("email"));
assertNotNull(info.getThemes().get("login"));
assertNotNull(info.getThemes().get("welcome"));
assertNotNull(info.getEnums());
assertNotNull(info.getMemoryInfo());
assertNotNull(info.getSystemInfo());
assertEquals(Version.VERSION, info.getSystemInfo().getVersion());
assertNotNull(info.getSystemInfo().getServerTime());
assertNotNull(info.getSystemInfo().getUptime());
Map<String, ProviderRepresentation> jpaProviders = info.getProviders().get("connectionsJpa").getProviders();
ProviderRepresentation jpaProvider = jpaProviders.values().iterator().next();
log.infof("JPA Connections provider info: %s", jpaProvider.getOperationalInfo());
}
Aggregations