Fix fuse example

This commit is contained in:
mposolda 2015-04-01 18:02:22 +02:00
parent fc18190c5d
commit 15dfb6180c
5 changed files with 11 additions and 28 deletions

View file

@ -52,8 +52,8 @@ Once you run Apache Karaf, you need to run these commands from Karaf console (Ma
``` ```
feature:repo-add mvn:org.apache.camel.karaf/apache-camel/2.12.5/xml/features feature:repo-add mvn:org.apache.camel.karaf/apache-camel/2.12.5/xml/features
feature:repo-add mvn:org.apache.cxf.karaf/apache-cxf/2.7.14/xml/features feature:repo-add mvn:org.apache.cxf.karaf/apache-cxf/2.7.14/xml/features
feature:repo-add mvn:org.keycloak/keycloak-osgi-features/1.1.0.Final/xml/features feature:repo-add mvn:org.keycloak/keycloak-osgi-features/1.2.0.Beta1/xml/features
feature:repo-add mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.1.0.Final/xml/features feature:repo-add mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.2.0.Beta1/xml/features
feature:install keycloak-fuse-example feature:install keycloak-fuse-example
``` ```
@ -88,8 +88,8 @@ as pax-web is not installed at the moment. Then run those commands:
``` ```
features:addurl mvn:org.ops4j.pax.web/pax-web-features/3.1.2/xml/features features:addurl mvn:org.ops4j.pax.web/pax-web-features/3.1.2/xml/features
features:addurl mvn:org.keycloak/keycloak-osgi-features/1.1.0.Final/xml/features features:addurl mvn:org.keycloak/keycloak-osgi-features/1.2.0.Beta1/xml/features
features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.1.0.Final/xml/features features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.2.0.Beta1/xml/features
features:install keycloak-pax-web-upgrade features:install keycloak-pax-web-upgrade
features:install pax-http-whiteboard/3.1.2 features:install pax-http-whiteboard/3.1.2
features:install pax-war/3.1.2 features:install pax-war/3.1.2
@ -110,8 +110,8 @@ This is snapshot version of JBoss Fuse, which is not released yet at this moment
sufficient to install the demo (Replace Keycloak versions with the current Keycloak version number): sufficient to install the demo (Replace Keycloak versions with the current Keycloak version number):
``` ```
features:addurl mvn:org.keycloak/keycloak-osgi-features/1.1.0.Final/xml/features features:addurl mvn:org.keycloak/keycloak-osgi-features/1.2.0.Beta1/xml/features
features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.1.0.Final/xml/features features:addurl mvn:org.keycloak.example.demo/keycloak-fuse-example-features/1.2.0.Beta1/xml/features
features:install keycloak-fuse-example features:install keycloak-fuse-example
``` ```

View file

@ -1,40 +1,26 @@
package org.keycloak.example; 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 javax.servlet.http.HttpServletRequest;
import org.apache.camel.Exchange; import org.apache.camel.Exchange;
import org.apache.camel.Processor; import org.apache.camel.Processor;
import org.ietf.jgss.GSSCredential;
import org.keycloak.KeycloakPrincipal; import org.keycloak.KeycloakPrincipal;
import org.keycloak.constants.KerberosConstants;
import org.keycloak.representations.AccessToken; import org.keycloak.representations.AccessToken;
import org.keycloak.util.KerberosSerializationUtils;
/** /**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/ */
public class CamelHelloProcessor implements Processor { public class CamelHelloProcessor implements Processor {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override @Override
public void process(Exchange exchange) throws Exception { public void process(Exchange exchange) throws Exception {
HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class); HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
KeycloakPrincipal keycloakPrincipal = (KeycloakPrincipal) req.getUserPrincipal(); KeycloakPrincipal keycloakPrincipal = (KeycloakPrincipal) req.getUserPrincipal();
AccessToken accessToken = keycloakPrincipal.getKeycloakSecurityContext().getToken(); AccessToken accessToken = keycloakPrincipal.getKeycloakSecurityContext().getToken();
String username = accessToken.getPreferredUsername(); String username = accessToken.getPreferredUsername();
String fullName = accessToken.getName();
// send a html response with fullName from LDAP // send a html response with fullName from LDAP
exchange.getOut().setBody("<html><body>Hello " + username + "! It's " + sdf.format(new Date()) + "</body></html>"); exchange.getOut().setBody("Hello " + username + "! Your full name is " + fullName + ".");
} }
} }

View file

@ -11,6 +11,7 @@
<property name="resource" value="admin-camel-endpoint"/> <property name="resource" value="admin-camel-endpoint"/>
<property name="realmKey" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB"/> <property name="realmKey" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB"/>
<property name="bearerOnly" value="true"/> <property name="bearerOnly" value="true"/>
<property name="authServerUrl" value="http://localhost:8080/auth" />
<property name="sslRequired" value="EXTERNAL"/> <property name="sslRequired" value="EXTERNAL"/>
</bean> </bean>

View file

@ -17,6 +17,7 @@
<property name="resource" value="custom-cxf-endpoint"/> <property name="resource" value="custom-cxf-endpoint"/>
<property name="realmKey" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB"/> <property name="realmKey" value="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB"/>
<property name="bearerOnly" value="true"/> <property name="bearerOnly" value="true"/>
<property name="authServerUrl" value="http://localhost:8080/auth" />
<property name="sslRequired" value="EXTERNAL"/> <property name="sslRequired" value="EXTERNAL"/>
</bean> </bean>

View file

@ -186,12 +186,7 @@
"enabled": true, "enabled": true,
"publicClient": false, "publicClient": false,
"directGrantsOnly": true, "directGrantsOnly": true,
"secret": "password", "secret": "password"
"claims" : {
"name" : true,
"username" : true,
"email" : true
}
} }
], ],
"scopeMappings": [ "scopeMappings": [