Skip to content

Commit

Permalink
KEYCLOAK-1447 LinkageError deploying oauth-client-cdi to WildFly 8.2.…
Browse files Browse the repository at this point in the history
…0.Final
  • Loading branch information
stianst committed Jun 15, 2015
1 parent f846645 commit 4c98b04
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 41 deletions.
Expand Up @@ -13,13 +13,13 @@
<includes> <includes>
<include>org/bouncycastle/**</include> <include>org/bouncycastle/**</include>
<include>net/iharder/base64/**</include> <include>net/iharder/base64/**</include>
<include>org/apache/httpcomponents/**</include>
<include>org/keycloak/keycloak-core/**</include> <include>org/keycloak/keycloak-core/**</include>
<include>org/keycloak/keycloak-adapter-core/**</include> <include>org/keycloak/keycloak-adapter-core/**</include>
<include>org/keycloak/keycloak-jboss-adapter-core/**</include> <include>org/keycloak/keycloak-jboss-adapter-core/**</include>
<include>org/keycloak/keycloak-as7-adapter/**</include> <include>org/keycloak/keycloak-as7-adapter/**</include>
<include>org/keycloak/keycloak-as7-subsystem/**</include> <include>org/keycloak/keycloak-as7-subsystem/**</include>
<include>org/keycloak/keycloak-adapter-subsystem/**</include> <include>org/keycloak/keycloak-adapter-subsystem/**</include>
<include>org/keycloak/keycloak-servlet-oauth-client/**</include>
</includes> </includes>
<excludes> <excludes>
<exclude>**/*.war</exclude> <exclude>**/*.war</exclude>
Expand Down
10 changes: 4 additions & 6 deletions distribution/adapters/as7-eap6-adapter/as7-modules/build.xml
Expand Up @@ -38,12 +38,6 @@


<!-- server min dependencies --> <!-- server min dependencies -->


<module-def name="org.apache.httpcomponents" slot="4.3">
<maven-resource group="org.apache.httpcomponents" artifact="httpclient"/>
<maven-resource group="org.apache.httpcomponents" artifact="httpcore"/>
<maven-resource group="org.apache.httpcomponents" artifact="httpmime"/>
</module-def>

<module-def name="org.keycloak.keycloak-core"> <module-def name="org.keycloak.keycloak-core">
<maven-resource group="org.keycloak" artifact="keycloak-core"/> <maven-resource group="org.keycloak" artifact="keycloak-core"/>
</module-def> </module-def>
Expand Down Expand Up @@ -76,6 +70,10 @@
<maven-resource group="org.keycloak" artifact="keycloak-as7-subsystem"/> <maven-resource group="org.keycloak" artifact="keycloak-as7-subsystem"/>
</module-def> </module-def>


<module-def name="org.keycloak.keycloak-servlet-oauth-client">
<maven-resource group="org.keycloak" artifact="keycloak-servlet-oauth-client"/>
</module-def>

</target> </target>


<target name="clean-target"> <target name="clean-target">
Expand Down
8 changes: 2 additions & 6 deletions distribution/adapters/as7-eap6-adapter/as7-modules/pom.xml
Expand Up @@ -42,12 +42,8 @@
<artifactId>keycloak-as7-subsystem</artifactId> <artifactId>keycloak-as7-subsystem</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.keycloak</groupId>
<artifactId>httpmime</artifactId> <artifactId>keycloak-servlet-oauth-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.iharder</groupId> <groupId>net.iharder</groupId>
Expand Down

This file was deleted.

Expand Up @@ -11,7 +11,7 @@
<module name="org.codehaus.jackson.jackson-core-asl"/> <module name="org.codehaus.jackson.jackson-core-asl"/>
<module name="org.codehaus.jackson.jackson-mapper-asl"/> <module name="org.codehaus.jackson.jackson-mapper-asl"/>
<module name="org.codehaus.jackson.jackson-xc"/> <module name="org.codehaus.jackson.jackson-xc"/>
<module name="org.apache.httpcomponents" slot="4.3" /> <module name="org.apache.httpcomponents"/>
<module name="org.jboss.logging"/> <module name="org.jboss.logging"/>
<module name="org.keycloak.keycloak-core"/> <module name="org.keycloak.keycloak-core"/>
<module name="net.iharder.base64"/> <module name="net.iharder.base64"/>
Expand Down
Expand Up @@ -12,7 +12,7 @@
<module name="org.codehaus.jackson.jackson-core-asl"/> <module name="org.codehaus.jackson.jackson-core-asl"/>
<module name="org.codehaus.jackson.jackson-mapper-asl"/> <module name="org.codehaus.jackson.jackson-mapper-asl"/>
<module name="org.codehaus.jackson.jackson-xc"/> <module name="org.codehaus.jackson.jackson-xc"/>
<module name="org.apache.httpcomponents" slot="4.3" /> <module name="org.apache.httpcomponents"/>
<module name="javax.servlet.api"/> <module name="javax.servlet.api"/>
<module name="org.jboss.logging"/> <module name="org.jboss.logging"/>
<module name="org.jboss.as.security"/> <module name="org.jboss.as.security"/>
Expand Down
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="org.keycloak.keycloak-servlet-oauth-client">
<resources>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api"/>
<module name="org.jboss.logging"/>
<module name="org.picketbox"/>
<module name="org.apache.httpcomponents"/>
<module name="org.keycloak.keycloak-adapter-core"/>
<module name="org.keycloak.keycloak-core"/>
</dependencies>

</module>
Expand Up @@ -13,13 +13,13 @@
<includes> <includes>
<include>org/bouncycastle/**</include> <include>org/bouncycastle/**</include>
<include>net/iharder/base64/**</include> <include>net/iharder/base64/**</include>
<include>org/apache/httpcomponents/**</include>
<include>org/keycloak/keycloak-core/**</include> <include>org/keycloak/keycloak-core/**</include>
<include>org/keycloak/keycloak-adapter-core/**</include> <include>org/keycloak/keycloak-adapter-core/**</include>
<include>org/keycloak/keycloak-jboss-adapter-core/**</include> <include>org/keycloak/keycloak-jboss-adapter-core/**</include>
<include>org/keycloak/keycloak-as7-adapter/**</include> <include>org/keycloak/keycloak-as7-adapter/**</include>
<include>org/keycloak/keycloak-as7-subsystem/**</include> <include>org/keycloak/keycloak-as7-subsystem/**</include>
<include>org/keycloak/keycloak-adapter-subsystem/**</include> <include>org/keycloak/keycloak-adapter-subsystem/**</include>
<include>org/keycloak/keycloak-servlet-oauth-client/**</include>
</includes> </includes>
<excludes> <excludes>
<exclude>**/*.war</exclude> <exclude>**/*.war</exclude>
Expand Down
Expand Up @@ -20,6 +20,7 @@
<include>org/keycloak/keycloak-wildfly-adapter/**</include> <include>org/keycloak/keycloak-wildfly-adapter/**</include>
<include>org/keycloak/keycloak-wf8-subsystem/**</include> <include>org/keycloak/keycloak-wf8-subsystem/**</include>
<include>org/keycloak/keycloak-adapter-subsystem/**</include> <include>org/keycloak/keycloak-adapter-subsystem/**</include>
<include>org/keycloak/keycloak-servlet-oauth-client/**</include>
</includes> </includes>
<excludes> <excludes>
<exclude>**/*.war</exclude> <exclude>**/*.war</exclude>
Expand Down
4 changes: 4 additions & 0 deletions distribution/adapters/wf8-adapter/wf8-modules/build.xml
Expand Up @@ -69,6 +69,10 @@
<maven-resource group="org.keycloak" artifact="keycloak-wf8-subsystem"/> <maven-resource group="org.keycloak" artifact="keycloak-wf8-subsystem"/>
</module-def> </module-def>


<module-def name="org.keycloak.keycloak-servlet-oauth-client">
<maven-resource group="org.keycloak" artifact="keycloak-servlet-oauth-client"/>
</module-def>

<module-def name="org.apache.httpcomponents" slot="4.3"> <module-def name="org.apache.httpcomponents" slot="4.3">
<maven-resource group="org.apache.httpcomponents" artifact="httpclient"/> <maven-resource group="org.apache.httpcomponents" artifact="httpclient"/>
<maven-resource group="org.apache.httpcomponents" artifact="httpcore"/> <maven-resource group="org.apache.httpcomponents" artifact="httpcore"/>
Expand Down
4 changes: 4 additions & 0 deletions distribution/adapters/wf8-adapter/wf8-modules/pom.xml
Expand Up @@ -41,6 +41,10 @@
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-wf8-subsystem</artifactId> <artifactId>keycloak-wf8-subsystem</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-servlet-oauth-client</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId> <artifactId>httpmime</artifactId>
Expand Down
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="org.keycloak.keycloak-servlet-oauth-client">
<resources>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api"/>
<module name="org.jboss.logging"/>
<module name="org.picketbox"/>
<module name="org.apache.httpcomponents" slot="4.3"/>
<module name="org.keycloak.keycloak-adapter-core"/>
<module name="org.keycloak.keycloak-core"/>
</dependencies>

</module>
Expand Up @@ -19,6 +19,7 @@
<include>org/keycloak/keycloak-wildfly-adapter/**</include> <include>org/keycloak/keycloak-wildfly-adapter/**</include>
<include>org/keycloak/keycloak-wf9-subsystem/**</include> <include>org/keycloak/keycloak-wf9-subsystem/**</include>
<include>org/keycloak/keycloak-adapter-subsystem/**</include> <include>org/keycloak/keycloak-adapter-subsystem/**</include>
<include>org/keycloak/keycloak-servlet-oauth-client/**</include>
</includes> </includes>
<excludes> <excludes>
<exclude>**/*.war</exclude> <exclude>**/*.war</exclude>
Expand Down
4 changes: 4 additions & 0 deletions distribution/adapters/wf9-adapter/wf9-modules/build.xml
Expand Up @@ -69,6 +69,10 @@
<maven-resource group="org.keycloak" artifact="keycloak-wf9-subsystem"/> <maven-resource group="org.keycloak" artifact="keycloak-wf9-subsystem"/>
</module-def> </module-def>


<module-def name="org.keycloak.keycloak-servlet-oauth-client">
<maven-resource group="org.keycloak" artifact="keycloak-servlet-oauth-client"/>
</module-def>

</target> </target>


<target name="clean-target"> <target name="clean-target">
Expand Down
4 changes: 4 additions & 0 deletions distribution/adapters/wf9-adapter/wf9-modules/pom.xml
Expand Up @@ -41,6 +41,10 @@
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-wf9-subsystem</artifactId> <artifactId>keycloak-wf9-subsystem</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-servlet-oauth-client</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId> <artifactId>httpmime</artifactId>
Expand Down
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.1" name="org.keycloak.keycloak-servlet-oauth-client">
<resources>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api"/>
<module name="org.jboss.logging"/>
<module name="org.picketbox"/>
<module name="org.apache.httpcomponents"/>
<module name="org.keycloak.keycloak-adapter-core"/>
<module name="org.keycloak.keycloak-core"/>
</dependencies>

</module>
1 change: 1 addition & 0 deletions examples/demo-template/third-party-cdi/pom.xml
Expand Up @@ -52,6 +52,7 @@
<dependency> <dependency>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
<artifactId>keycloak-servlet-oauth-client</artifactId> <artifactId>keycloak-servlet-oauth-client</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
Expand Down
Expand Up @@ -4,6 +4,7 @@
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.keycloak.servlet.ServletOAuthClient; import org.keycloak.servlet.ServletOAuthClient;
import org.keycloak.util.JsonSerialization; import org.keycloak.util.JsonSerialization;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void sendProductsRequest() {
} }


protected List<String> sendRequestToDBApplication(String dbUri) { protected List<String> sendRequestToDBApplication(String dbUri) {
HttpClient client = oauthClient.getClient(); HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(dbUri); HttpGet get = new HttpGet(dbUri);
try { try {


Expand Down
Expand Up @@ -4,6 +4,7 @@
<!-- the Demo code uses classes in these modules. These are optional to import if you are not using <!-- the Demo code uses classes in these modules. These are optional to import if you are not using
Apache Http Client or the HttpClientBuilder that comes with the adapter core --> Apache Http Client or the HttpClientBuilder that comes with the adapter core -->
<module name="org.apache.httpcomponents"/> <module name="org.apache.httpcomponents"/>
<module name="org.keycloak.keycloak-servlet-oauth-client"/>
</dependencies> </dependencies>
</deployment> </deployment>
</jboss-deployment-structure> </jboss-deployment-structure>
Expand Up @@ -4,6 +4,7 @@
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.keycloak.adapters.ServerRequest; import org.keycloak.adapters.ServerRequest;
import org.keycloak.representations.AccessTokenResponse; import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.servlet.ServletOAuthClient; import org.keycloak.servlet.ServletOAuthClient;
Expand Down Expand Up @@ -76,7 +77,7 @@ public static List<String> getProducts(HttpServletRequest request, String access
// and obtain the ServletOAuthClient. I actually suggest downloading the ServletOAuthClient code // and obtain the ServletOAuthClient. I actually suggest downloading the ServletOAuthClient code
// and take a look how it works. You can also take a look at third-party-cdi example // and take a look how it works. You can also take a look at third-party-cdi example
ServletOAuthClient oAuthClient = (ServletOAuthClient) request.getServletContext().getAttribute(ServletOAuthClient.class.getName()); ServletOAuthClient oAuthClient = (ServletOAuthClient) request.getServletContext().getAttribute(ServletOAuthClient.class.getName());
HttpClient client = oAuthClient.getClient(); HttpClient client = new DefaultHttpClient();


HttpGet get = new HttpGet(getBaseUrl(oAuthClient, request) + "/database/products"); HttpGet get = new HttpGet(getBaseUrl(oAuthClient, request) + "/database/products");
get.addHeader("Authorization", "Bearer " + accessToken); get.addHeader("Authorization", "Bearer " + accessToken);
Expand Down
Expand Up @@ -3,10 +3,12 @@
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.keycloak.AbstractOAuthClient; import org.keycloak.AbstractOAuthClient;
import org.keycloak.OAuth2Constants; import org.keycloak.OAuth2Constants;
import org.keycloak.adapters.HttpClientBuilder;
import org.keycloak.adapters.ServerRequest; import org.keycloak.adapters.ServerRequest;
import org.keycloak.jose.jws.JWSInput; import org.keycloak.jose.jws.JWSInput;
import org.keycloak.representations.AccessTokenResponse; import org.keycloak.representations.AccessTokenResponse;
import org.keycloak.representations.IDToken; import org.keycloak.representations.IDToken;
import org.keycloak.representations.adapters.config.AdapterConfig;
import org.keycloak.util.KeycloakUriBuilder; import org.keycloak.util.KeycloakUriBuilder;
import org.keycloak.util.UriUtils; import org.keycloak.util.UriUtils;


Expand All @@ -22,8 +24,10 @@
*/ */
public class ServletOAuthClient extends AbstractOAuthClient { public class ServletOAuthClient extends AbstractOAuthClient {
protected HttpClient client; protected HttpClient client;
protected AdapterConfig adapterConfig;


public void start() { public void start() {
client = new HttpClientBuilder().build(adapterConfig);
} }


/** /**
Expand All @@ -32,13 +36,6 @@ public void start() {
public void stop() { public void stop() {
client.getConnectionManager().shutdown(); client.getConnectionManager().shutdown();
} }
public HttpClient getClient() {
return client;
}

public void setClient(HttpClient client) {
this.client = client;
}


private AccessTokenResponse resolveBearerToken(HttpServletRequest request, String redirectUri, String code) throws IOException, ServerRequest.HttpFailure { private AccessTokenResponse resolveBearerToken(HttpServletRequest request, String redirectUri, String code) throws IOException, ServerRequest.HttpFailure {
// Don't send sessionId in oauth clients for now // Don't send sessionId in oauth clients for now
Expand Down Expand Up @@ -171,4 +168,7 @@ private String getUrl(HttpServletRequest request, String url, boolean isBrowserR
} }
} }


public void setAdapterConfig(AdapterConfig adapterConfig) {
this.adapterConfig = adapterConfig;
}
} }
Expand Up @@ -42,8 +42,7 @@ public static void build(InputStream is, ServletOAuthClient oauthClient) {




public static void build(AdapterConfig adapterConfig, ServletOAuthClient oauthClient) { public static void build(AdapterConfig adapterConfig, ServletOAuthClient oauthClient) {
HttpClient client = new HttpClientBuilder().build(adapterConfig); oauthClient.setAdapterConfig(adapterConfig);
oauthClient.setClient(client);
oauthClient.setClientId(adapterConfig.getResource()); oauthClient.setClientId(adapterConfig.getResource());
oauthClient.setPublicClient(adapterConfig.isPublicClient()); oauthClient.setPublicClient(adapterConfig.isPublicClient());
oauthClient.setCredentials(adapterConfig.getCredentials()); oauthClient.setCredentials(adapterConfig.getCredentials());
Expand Down

0 comments on commit 4c98b04

Please sign in to comment.