Search in sources :

Example 1 with ServerInfoRepresentation

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;
}
Also used : ServerInfoRepresentation(org.keycloak.representations.info.ServerInfoRepresentation) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 2 with ServerInfoRepresentation

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));
}
Also used : ServerInfoRepresentation(org.keycloak.representations.info.ServerInfoRepresentation)

Example 3 with ServerInfoRepresentation

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));
    }
}
Also used : ClientPoliciesRepresentation(org.keycloak.representations.idm.ClientPoliciesRepresentation) ServerInfoRepresentation(org.keycloak.representations.info.ServerInfoRepresentation)

Example 4 with ServerInfoRepresentation

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);
}
Also used : ConfiguredProvider(org.keycloak.provider.ConfiguredProvider) ComponentTypeRepresentation(org.keycloak.representations.idm.ComponentTypeRepresentation) Theme(org.keycloak.theme.Theme) PasswordPolicyTypeRepresentation(org.keycloak.representations.idm.PasswordPolicyTypeRepresentation) Arrays(java.util.Arrays) ResourceType(org.keycloak.events.admin.ResourceType) Produces(javax.ws.rs.Produces) ClientInstallationRepresentation(org.keycloak.representations.info.ClientInstallationRepresentation) MediaType(javax.ws.rs.core.MediaType) Map(java.util.Map) Spi(org.keycloak.provider.Spi) ThemeInfoRepresentation(org.keycloak.representations.info.ThemeInfoRepresentation) ProtocolMapper(org.keycloak.protocol.ProtocolMapper) Context(javax.ws.rs.core.Context) Collectors(java.util.stream.Collectors) ProtocolMapperRepresentation(org.keycloak.representations.idm.ProtocolMapperRepresentation) SocialIdentityProvider(org.keycloak.broker.social.SocialIdentityProvider) ModelToRepresentation(org.keycloak.models.utils.ModelToRepresentation) ClientInstallationProvider(org.keycloak.protocol.ClientInstallationProvider) List(java.util.List) Stream(java.util.stream.Stream) ComponentFactory(org.keycloak.component.ComponentFactory) WebApplicationException(javax.ws.rs.WebApplicationException) MemoryInfoRepresentation(org.keycloak.representations.info.MemoryInfoRepresentation) LoginProtocol(org.keycloak.protocol.LoginProtocol) SystemInfoRepresentation(org.keycloak.representations.info.SystemInfoRepresentation) OperationType(org.keycloak.events.admin.OperationType) IdentityProviderFactory(org.keycloak.broker.provider.IdentityProviderFactory) Profile(org.keycloak.common.Profile) GET(javax.ws.rs.GET) ProviderConfigProperty(org.keycloak.provider.ProviderConfigProperty) HashMap(java.util.HashMap) LoginProtocolFactory(org.keycloak.protocol.LoginProtocolFactory) ProfileInfoRepresentation(org.keycloak.representations.info.ProfileInfoRepresentation) LinkedHashMap(java.util.LinkedHashMap) PasswordPolicyProviderFactory(org.keycloak.policy.PasswordPolicyProviderFactory) LinkedList(java.util.LinkedList) IdentityProvider(org.keycloak.broker.provider.IdentityProvider) ProviderFactory(org.keycloak.provider.ProviderFactory) PasswordPolicyProvider(org.keycloak.policy.PasswordPolicyProvider) KeycloakSession(org.keycloak.models.KeycloakSession) EventType(org.keycloak.events.EventType) IOException(java.io.IOException) ServerInfoRepresentation(org.keycloak.representations.info.ServerInfoRepresentation) NoCache(org.jboss.resteasy.annotations.cache.NoCache) ProtocolMapperTypeRepresentation(org.keycloak.representations.idm.ProtocolMapperTypeRepresentation) ServerInfoAwareProviderFactory(org.keycloak.provider.ServerInfoAwareProviderFactory) ProviderRepresentation(org.keycloak.representations.info.ProviderRepresentation) Comparator(java.util.Comparator) Collections(java.util.Collections) SpiInfoRepresentation(org.keycloak.representations.info.SpiInfoRepresentation) PasswordPolicyTypeRepresentation(org.keycloak.representations.idm.PasswordPolicyTypeRepresentation) PasswordPolicyProviderFactory(org.keycloak.policy.PasswordPolicyProviderFactory) PasswordPolicyProvider(org.keycloak.policy.PasswordPolicyProvider)

Example 5 with ServerInfoRepresentation

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());
}
Also used : ServerInfoRepresentation(org.keycloak.representations.info.ServerInfoRepresentation) ProviderRepresentation(org.keycloak.representations.info.ProviderRepresentation) AbstractKeycloakTest(org.keycloak.testsuite.AbstractKeycloakTest) Test(org.junit.Test)

Aggregations

ServerInfoRepresentation (org.keycloak.representations.info.ServerInfoRepresentation)5 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 NoCache (org.jboss.resteasy.annotations.cache.NoCache)2 ProviderRepresentation (org.keycloak.representations.info.ProviderRepresentation)2 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Context (javax.ws.rs.core.Context)1 MediaType (javax.ws.rs.core.MediaType)1 Test (org.junit.Test)1