Merge pull request #1042 from mposolda/master

KEYCLOAK-1043 Fix fuse packaging due to bouncycastle update. Improve cam...
This commit is contained in:
Marek Posolda 2015-03-13 11:18:33 +01:00
commit fbfe552b54
8 changed files with 53 additions and 24 deletions

View file

@ -4,7 +4,8 @@
<feature name="keycloak-adapter-core" version="${project.version}" resolver="(obr)">
<details>The keycloak adapter core stuff</details>
<bundle dependency="true">mvn:org.keycloak/keycloak-osgi-thirdparty/${project.version}</bundle>
<bundle dependency="true">mvn:org.bouncycastle/bcprov-jdk16/${bouncycastle.version}</bundle>
<bundle dependency="true">mvn:org.bouncycastle/bcprov-jdk15on/${bouncycastle.crypto.version}</bundle>
<bundle dependency="true">mvn:org.bouncycastle/bcpkix-jdk15on/${bouncycastle.crypto.version}</bundle>
<bundle dependency="true">mvn:org.codehaus.jackson/jackson-core-asl/${jackson.version}</bundle>
<bundle dependency="true">mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson.version}</bundle>
<bundle dependency="true">mvn:org.codehaus.jackson/jackson-xc/${jackson.version}</bundle>

View file

@ -31,7 +31,8 @@ Base steps
----------
* Run external instance of Keycloak server on WildFly 8 or JBoss EAP 6.3 . Fuse demo suppose that server is running on [http://localhost:8080/auth](http://localhost:8080/auth)
* Import realm `demo` from the file testrealm.json on `examples/fuse/testrealm.json` .
* Import realm `demo` from the file testrealm.json on `examples/fuse/testrealm.json` . See [here](../demo-template/README.md#step-3-import-the-test-realm)
the details on how to import the realm
* Then build examples, which is needed so the feature repository is added to your local maven repo:
```

View file

@ -30,6 +30,11 @@
</properties>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>

View file

@ -1,15 +0,0 @@
package org.keycloak.example;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class CamelHelloBean {
public String hello() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return "Hello admin! It's " + sdf.format(new Date());
}
}

View file

@ -0,0 +1,40 @@
package org.keycloak.example;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.security.sasl.Sasl;
import javax.servlet.http.HttpServletRequest;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.ietf.jgss.GSSCredential;
import org.keycloak.KeycloakPrincipal;
import org.keycloak.constants.KerberosConstants;
import org.keycloak.representations.AccessToken;
import org.keycloak.util.KerberosSerializationUtils;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class CamelHelloProcessor implements Processor {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void process(Exchange exchange) throws Exception {
HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
KeycloakPrincipal keycloakPrincipal = (KeycloakPrincipal) req.getUserPrincipal();
AccessToken accessToken = keycloakPrincipal.getKeycloakSecurityContext().getToken();
String username = accessToken.getPreferredUsername();
// send a html response with fullName from LDAP
exchange.getOut().setBody("<html><body>Hello " + username + "! It's " + sdf.format(new Date()) + "</body></html>");
}
}

View file

@ -49,18 +49,15 @@
<property name="handler" ref="securityHandler" />
</bean>
<bean id="helloBean" class="org.keycloak.example.CamelHelloBean" />
<bean id="helloProcessor" class="org.keycloak.example.CamelHelloProcessor" />
<camelContext id="blueprintContext"
trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="httpBridge">
<from uri="jetty:http://0.0.0.0:8383/admin-camel-endpoint?handlers=sessionHandler&amp;matchOnUriPrefix=true" />
<setBody>
<method ref="helloBean" method="hello"/>
</setBody>
<process ref="helloProcessor" />
<log message="The message from camel endpoint contains ${body}"/>
<to uri="mock:result"/>
</route>
</camelContext>

View file

@ -30,7 +30,7 @@ public class CamelClient {
try {
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() != 200) {
return "There was a failure processing request. You either didn't configure Keycloak properly or you don't have enought permission? Status code is "
return "There was a failure processing request. You either didn't configure Keycloak properly or you don't have admin permission? Status code is "
+ response.getStatusLine().getStatusCode();
}
HttpEntity entity = response.getEntity();

View file

@ -8,7 +8,7 @@
<title>Camel page</title>
</head>
<body bgcolor="#E3F6CE">
<p>You will receive info from camel endpoint. Endpoint is accessible just for admin user</p>
<p>You will receive info from camel endpoint. Endpoint is accessible just for user with admin role</p>
<p>Response from camel: <b><%= CamelClient.sendRequest(request) %></b> </p>
<br><br>
</body>