Repository navigation
stuff #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
stuff #8
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <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/maven-v4_0_0.xsd"> | ||
| <parent> | ||
| <artifactId>keycloak-parent</artifactId> | ||
| <groupId>org.keycloak</groupId> | ||
| <version>1.0-alpha-1</version> | ||
| <relativePath>../../../pom.xml</relativePath> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>org.keycloak.example.as7.demo</groupId> | ||
| <artifactId>customer-portal-example</artifactId> | ||
| <packaging>war</packaging> | ||
| <name>Customer Portal - Secured via Valve</name> | ||
| <description/> | ||
|
|
||
| <repositories> | ||
| <repository> | ||
| <id>jboss</id> | ||
| <name>jboss repo</name> | ||
| <url>http://repository.jboss.org/nexus/content/groups/public/</url> | ||
| </repository> | ||
| </repositories> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.1</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>javax.servlet</groupId> | ||
| <artifactId>servlet-api</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jboss.resteasy</groupId> | ||
| <artifactId>resteasy-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.keycloak</groupId> | ||
| <artifactId>keycloak-core</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.keycloak</groupId> | ||
| <artifactId>keycloak-as7-adapter</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <finalName>customer-portal</finalName> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.jboss.as.plugins</groupId> | ||
| <artifactId>jboss-as-maven-plugin</artifactId> | ||
| <version>7.4.Final</version> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-deploy-plugin</artifactId> | ||
| <configuration> | ||
| <skip>true</skip> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>1.6</source> | ||
| <target>1.6</target> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
36 changes: 36 additions & 0 deletions
36
...o/customer-app/src/main/java/org/jboss/resteasy/example/oauth/CustomerDatabaseClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.jboss.resteasy.example.oauth; | ||
|
|
||
| import org.jboss.resteasy.client.jaxrs.ResteasyClient; | ||
| import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; | ||
| import org.keycloak.SkeletonKeySession; | ||
|
|
||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.ws.rs.core.GenericType; | ||
| import javax.ws.rs.core.HttpHeaders; | ||
| import javax.ws.rs.core.Response; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
| * @version $Revision: 1 $ | ||
| */ | ||
| public class CustomerDatabaseClient | ||
| { | ||
| public static List<String> getCustomers(HttpServletRequest request) | ||
| { | ||
| SkeletonKeySession session = (SkeletonKeySession)request.getAttribute(SkeletonKeySession.class.getName()); | ||
| ResteasyClient client = new ResteasyClientBuilder() | ||
| .trustStore(session.getMetadata().getTruststore()) | ||
| .hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy.ANY).build(); | ||
| try | ||
| { | ||
| Response response = client.target("http://localhost:8080/database/customers").request() | ||
| .header(HttpHeaders.AUTHORIZATION, "Bearer " + session.getToken()).get(); | ||
| return response.readEntity(new GenericType<List<String>>(){}); | ||
| } | ||
| finally | ||
| { | ||
| client.close(); | ||
| } | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
examples/as7-eap-demo/customer-app/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <jboss-deployment-structure> | ||
| <deployment> | ||
| <!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute --> | ||
| <dependencies> | ||
| <module name="org.bouncycastle"/> | ||
| <module name="org.jboss.resteasy.resteasy-jaxrs" services="import"/> | ||
| <module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/> | ||
| <module name="org.jboss.resteasy.jose-jwt" /> | ||
| </dependencies> | ||
| </deployment> | ||
| </jboss-deployment-structure> |
5 changes: 5 additions & 0 deletions
5
examples/as7-eap-demo/customer-app/src/main/webapp/WEB-INF/jboss-web.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <jboss-web> | ||
| <valve> | ||
| <class-name>org.keycloak.adapters.as7.OAuthManagedResourceValve</class-name> | ||
| </valve> | ||
| </jboss-web> |
11 changes: 11 additions & 0 deletions
11
examples/as7-eap-demo/customer-app/src/main/webapp/WEB-INF/resteasy-oauth.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "realm" : "demo", | ||
| "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB", | ||
| "auth-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/auth/request", | ||
| "code-url" : "http://localhost:8080/auth-server/rest/realms/demo/tokens/access/codes", | ||
| "ssl-not-required" : true, | ||
| "client-id" : "customer-portal", | ||
| "client-credentials" : { | ||
| "password" : "password" | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
examples/as7-eap-demo/customer-app/src/main/webapp/WEB-INF/web.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?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"> | ||
| <security-constraint> | ||
| <web-resource-collection> | ||
| <web-resource-name>Admins</web-resource-name> | ||
| <url-pattern>/admin/*</url-pattern> | ||
| </web-resource-collection> | ||
| <auth-constraint> | ||
| <role-name>admin</role-name> | ||
| </auth-constraint> | ||
| </security-constraint> | ||
| <security-constraint> | ||
| <web-resource-collection> | ||
| <web-resource-name>Customers</web-resource-name> | ||
| <url-pattern>/customers/*</url-pattern> | ||
| </web-resource-collection> | ||
| <auth-constraint> | ||
| <role-name>user</role-name> | ||
| </auth-constraint> | ||
| </security-constraint> | ||
|
|
||
| <!-- | ||
| <security-constraint> | ||
| <web-resource-collection> | ||
| <url-pattern>/*</url-pattern> | ||
| </web-resource-collection> | ||
| <user-data-constraint> | ||
| <transport-guarantee>CONFIDENTIAL</transport-guarantee> | ||
| </user-data-constraint> | ||
| </security-constraint> --> | ||
|
|
||
| <login-config> | ||
| <auth-method>BASIC</auth-method> | ||
| <realm-name>commerce</realm-name> | ||
| </login-config> | ||
|
|
||
| <security-role> | ||
| <role-name>admin</role-name> | ||
| </security-role> | ||
| <security-role> | ||
| <role-name>user</role-name> | ||
| </security-role> | ||
| </web-app> |
11 changes: 11 additions & 0 deletions
11
examples/as7-eap-demo/customer-app/src/main/webapp/admin/admin.jsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
| pageEncoding="ISO-8859-1"%> | ||
| <html> | ||
| <head> | ||
| <title>Customer Admin Iterface</title> | ||
| </head> | ||
| <body bgcolor="#E3F6CE"> | ||
| <h1>Customer Admin Interface</h1> | ||
| User <b><%=request.getUserPrincipal().getName()%></b> made this request. | ||
| </body> | ||
| </html> |
23 changes: 23 additions & 0 deletions
23
examples/as7-eap-demo/customer-app/src/main/webapp/customers/view.jsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
| pageEncoding="ISO-8859-1"%> | ||
| <html> | ||
| <head> | ||
| <title>Customer View Page</title> | ||
| </head> | ||
| <body bgcolor="#E3F6CE"> | ||
| <p>Goto: <a href="https://localhost:8443/product-portal">products</a> | <a href="https://localhost:8443/auth-server/j_oauth_logout">logout</a></p> | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
| User <b><%=request.getUserPrincipal().getName()%></b> made this request. | ||
| <h2>Customer Listing</h2> | ||
| <% | ||
| java.util.List<String> list = org.jboss.resteasy.example.oauth.CustomerDatabaseClient.getCustomers(request); | ||
| for (String cust : list) | ||
| { | ||
| out.print("<p>"); | ||
| out.print(cust); | ||
| out.println("</p>"); | ||
|
|
||
| } | ||
| %> | ||
| <br><br> | ||
| </body> | ||
| </html> | ||
14 changes: 14 additions & 0 deletions
14
examples/as7-eap-demo/customer-app/src/main/webapp/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
| "http://www.w3.org/TR/html4/loose.dtd"> | ||
| <html> | ||
| <head> | ||
| <title></title> | ||
| </head> | ||
| <body bgcolor="#E3F6CE"> | ||
| <h1>Customer Portal</h1> | ||
|
|
||
| <p><a href="customers/view.jsp">Customer Listing</a></p> | ||
| <p><a href="admin/admin.html">Customer Admin Interface</a></p> | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
|
|
||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <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/maven-v4_0_0.xsd"> | ||
| <parent> | ||
| <artifactId>keycloak-parent</artifactId> | ||
| <groupId>org.keycloak</groupId> | ||
| <version>1.0-alpha-1</version> | ||
| <relativePath>../../../pom.xml</relativePath> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <groupId>org.keycloak.example.as7.demo</groupId> | ||
| <artifactId>database-service</artifactId> | ||
| <packaging>war</packaging> | ||
| <name>JAX-RS Database Service Using OAuth Bearer Tokens</name> | ||
| <description/> | ||
| <url>http://maven.apache.org</url> | ||
|
|
||
| <repositories> | ||
| <repository> | ||
| <id>jboss</id> | ||
| <name>jboss repo</name> | ||
| <url>http://repository.jboss.org/nexus/content/groups/public/</url> | ||
| </repository> | ||
| </repositories> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <version>4.1</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jboss.resteasy</groupId> | ||
| <artifactId>resteasy-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
| <groupId>org.jboss.resteasy</groupId> | ||
| <artifactId>resteasy-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.keycloak</groupId> | ||
| <artifactId>keycloak-core</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.keycloak</groupId> | ||
| <artifactId>keycloak-as7-adapter</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <finalName>database</finalName> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.jboss.as.plugins</groupId> | ||
| <artifactId>jboss-as-maven-plugin</artifactId> | ||
| <version>7.4.Final</version> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>1.6</source> | ||
| <target>1.6</target> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
26 changes: 26 additions & 0 deletions
26
...demo/database-service/src/main/java/org/jboss/resteasy/example/oauth/CustomerService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package org.jboss.resteasy.example.oauth; | ||
|
|
||
| import javax.ws.rs.GET; | ||
| import javax.ws.rs.Path; | ||
| import javax.ws.rs.Produces; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
| * @version $Revision: 1 $ | ||
| */ | ||
| @Path("customers") | ||
| public class CustomerService | ||
| { | ||
| @GET | ||
| @Produces("application/json") | ||
| public List<String> getCustomers() | ||
| { | ||
| ArrayList<String> rtn = new ArrayList<String>(); | ||
| rtn.add("Bill Burke"); | ||
| rtn.add("Ron Sigal"); | ||
| rtn.add("Weinan Li"); | ||
| return rtn; | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
...demo/database-service/src/main/java/org/jboss/resteasy/example/oauth/DataApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package org.jboss.resteasy.example.oauth; | ||
|
|
||
| import javax.ws.rs.ApplicationPath; | ||
| import javax.ws.rs.core.Application; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
| * @version $Revision: 1 $ | ||
| */ | ||
| @ApplicationPath("/") | ||
| public class DataApplication extends Application | ||
| { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.