KEYCLOAK-814 Admin Client Example
This commit is contained in:
parent
0f8c073354
commit
1797f7e704
8 changed files with 137 additions and 0 deletions
|
@ -50,6 +50,14 @@
|
||||||
<exclude name="**/subsystem-config.xml"/>
|
<exclude name="**/subsystem-config.xml"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
|
<copy todir="target/examples/admin-client" overwrite="true">
|
||||||
|
<fileset dir="../../examples/admin-client">
|
||||||
|
<exclude name="**/target/**"/>
|
||||||
|
<exclude name="**/*.iml"/>
|
||||||
|
<exclude name="**/*.unconfigured"/>
|
||||||
|
<exclude name="**/subsystem-config.xml"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
<copy todir="target/examples/themes" overwrite="true">
|
<copy todir="target/examples/themes" overwrite="true">
|
||||||
<fileset dir="../../examples/themes">
|
<fileset dir="../../examples/themes">
|
||||||
<exclude name="**/target/**"/>
|
<exclude name="**/target/**"/>
|
||||||
|
|
37
examples/admin-client/example-realm.json
Executable file
37
examples/admin-client/example-realm.json
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"realm": "example",
|
||||||
|
"enabled": true,
|
||||||
|
"sslRequired": "external",
|
||||||
|
"registrationAllowed": true,
|
||||||
|
"passwordCredentialGrantAllowed": true,
|
||||||
|
"privateKey": "MIICXAIBAAKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQABAoGAfmO8gVhyBxdqlxmIuglbz8bcjQbhXJLR2EoS8ngTXmN1bo2L90M0mUKSdc7qF10LgETBzqL8jYlQIbt+e6TH8fcEpKCjUlyq0Mf/vVbfZSNaVycY13nTzo27iPyWQHK5NLuJzn1xvxxrUeXI6A2WFpGEBLbHjwpx5WQG9A+2scECQQDvdn9NE75HPTVPxBqsEd2z10TKkl9CZxu10Qby3iQQmWLEJ9LNmy3acvKrE3gMiYNWb6xHPKiIqOR1as7L24aTAkEAtyvQOlCvr5kAjVqrEKXalj0Tzewjweuxc0pskvArTI2Oo070h65GpoIKLc9jf+UA69cRtquwP93aZKtW06U8dQJAF2Y44ks/mK5+eyDqik3koCI08qaC8HYq2wVl7G2QkJ6sbAaILtcvD92ToOvyGyeE0flvmDZxMYlvaZnaQ0lcSQJBAKZU6umJi3/xeEbkJqMfeLclD27XGEFoPeNrmdx0q10Azp4NfJAY+Z8KRyQCR2BEG+oNitBOZ+YXF9KCpH3cdmECQHEigJhYg+ykOvr1aiZUMFT72HU0jnmQe2FVekuG+LJUt2Tm7GtMjTFoGpf0JwrVuZN39fOYAlo+nTixgeW7X8Y=",
|
||||||
|
"publicKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
|
||||||
|
"requiredCredentials": [ "password" ],
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"username": "examples-admin-client",
|
||||||
|
"enabled": true,
|
||||||
|
"credentials": [
|
||||||
|
{
|
||||||
|
"type": "password",
|
||||||
|
"value": "password"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"applicationRoles": {
|
||||||
|
"realm-management": [ "realm-admin" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"applications": [
|
||||||
|
{
|
||||||
|
"name": "examples-admin-client",
|
||||||
|
"enabled": true,
|
||||||
|
"fullScopeAllowed": true,
|
||||||
|
"baseUrl": "/examples-admin-client",
|
||||||
|
"redirectUris": [
|
||||||
|
"/examples-admin-client/*"
|
||||||
|
],
|
||||||
|
"secret": "password"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
33
examples/admin-client/pom.xml
Normal file
33
examples/admin-client/pom.xml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>keycloak-parent</artifactId>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<version>1.1.0-Alpha1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<name>Keycloak Examples - Admin Client</name>
|
||||||
|
<artifactId>examples-admin-client</artifactId>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
Keycloak Admin Client Example
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-admin-client</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
10
examples/admin-client/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
Executable file
10
examples/admin-client/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
<jboss-deployment-structure>
|
||||||
|
<deployment>
|
||||||
|
<dependencies>
|
||||||
|
<module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
|
||||||
|
</dependencies>
|
||||||
|
<exclusions>
|
||||||
|
<module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
|
||||||
|
</exclusions>
|
||||||
|
</deployment>
|
||||||
|
</jboss-deployment-structure>
|
9
examples/admin-client/src/main/webapp/WEB-INF/web.xml
Executable file
9
examples/admin-client/src/main/webapp/WEB-INF/web.xml
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||||
|
version="3.0">
|
||||||
|
|
||||||
|
<module-name>examples-admin-client</module-name>
|
||||||
|
|
||||||
|
</web-app>
|
33
examples/admin-client/src/main/webapp/index.jsp
Normal file
33
examples/admin-client/src/main/webapp/index.jsp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<%@ page import="org.keycloak.admin.client.Keycloak" %>
|
||||||
|
<%@ page import="org.keycloak.admin.client.resource.ApplicationsResource" %>
|
||||||
|
<%@ page import="org.keycloak.representations.idm.ApplicationRepresentation" %>
|
||||||
|
<%@ page import="org.keycloak.util.UriUtils" %>
|
||||||
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
|
||||||
|
<%@ page session="false" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Applications</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%
|
||||||
|
String authServer = UriUtils.getOrigin(request.getRequestURL().toString()) + "/auth";
|
||||||
|
|
||||||
|
Keycloak keycloak = Keycloak.getInstance(authServer, "example", "examples-admin-client", "password", "examples-admin-client", "password");
|
||||||
|
ApplicationsResource applications = keycloak.realm("example").applications();
|
||||||
|
|
||||||
|
out.println("<h1>Applications</h1>");
|
||||||
|
out.println("<ul>");
|
||||||
|
for (ApplicationRepresentation app : applications.findAll()) {
|
||||||
|
out.println("\t<li>");
|
||||||
|
if (app.getBaseUrl() != null) {
|
||||||
|
out.println("\t\t<a href=\"" + app.getBaseUrl() + "\">" + app.getName() + "</a>");
|
||||||
|
} else {
|
||||||
|
out.println("\t\t" + app.getName());
|
||||||
|
}
|
||||||
|
out.println("</li>");
|
||||||
|
}
|
||||||
|
out.println("</ul>");
|
||||||
|
%>
|
||||||
|
<br><br>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -25,6 +25,7 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<modules>
|
<modules>
|
||||||
|
<module>admin-client</module>
|
||||||
<module>cors</module>
|
<module>cors</module>
|
||||||
<module>demo-template</module>
|
<module>demo-template</module>
|
||||||
<module>providers</module>
|
<module>providers</module>
|
||||||
|
|
|
@ -23,31 +23,37 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
<artifactId>jackson-mapper-asl</artifactId>
|
<artifactId>jackson-mapper-asl</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>${keycloak.apache.httpcomponents.version}</version>
|
<version>${keycloak.apache.httpcomponents.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>jaxrs-api</artifactId>
|
<artifactId>jaxrs-api</artifactId>
|
||||||
<version>${resteasy.version.latest}</version>
|
<version>${resteasy.version.latest}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>resteasy-jaxrs</artifactId>
|
<artifactId>resteasy-jaxrs</artifactId>
|
||||||
<version>${resteasy.version.latest}</version>
|
<version>${resteasy.version.latest}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>resteasy-client</artifactId>
|
<artifactId>resteasy-client</artifactId>
|
||||||
<version>${resteasy.version.latest}</version>
|
<version>${resteasy.version.latest}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>resteasy-jackson-provider</artifactId>
|
<artifactId>resteasy-jackson-provider</artifactId>
|
||||||
<version>${resteasy.version.latest}</version>
|
<version>${resteasy.version.latest}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue