Skip to content

Instantly share code, notes, and snippets.

View iocanel's full-sized avatar

Ioannis Canellos iocanel

View GitHub Profile
@iocanel
iocanel / gist:1979586
Created March 5, 2012 17:22
Adding sample data to the JAAS table
insert into users values('iocanel','a564de63c2d0da68cf47586ee05984d7');
insert into roles values('iocanel','manager');
insert into roles values('iocanel','roles');
@iocanel
iocanel / gist:1979603
Created March 5, 2012 17:23
Creating a datasource OSGi service with blueprint
<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" id="mysqlDatasource">
<property name="serverName" value="localhost"></property>
<property name="databaseName" value="username_here"></property>
<property name="port" value="3306"></property>
<property name="user" value="root"></property>
<property name="password" value="password_here"></property>
</bean>
<service id="mysqlDS" interface="javax.sql.DataSource" ref="mysqlDatasource">
@iocanel
iocanel / gist:1979608
Created March 5, 2012 17:24
A simple jdbc login module for Karaf JAAS
<blueprint xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"> </ext:property-placeholder>
<jaas:config name="blog">
<jaas:module classname="org.apache.karaf.jaas.modules.jdbc.JDBCLoginModule" flags="required">
datasource = osgi:javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdb)
query.password = SELECT PASSWORD FROM users WHERE USERNAME=?
query.role = SELECT ROLE FROM roles WHERE USERNAME=?
encryption.name = jasypt
@iocanel
iocanel / gist:1979609
Created March 5, 2012 17:24
A simple jdbc login module for Karaf JAAS
<blueprint xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"> </ext:property-placeholder>
<jaas:config name="blog">
<jaas:module classname="org.apache.karaf.jaas.modules.jdbc.JDBCLoginModule" flags="required">
datasource = osgi:javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdb)
query.password = SELECT PASSWORD FROM users WHERE USERNAME=?
query.role = SELECT ROLE FROM roles WHERE USERNAME=?
encryption.name = jasypt
@iocanel
iocanel / gist:1979614
Created March 5, 2012 17:25
A wicket jaas session example
public class WicketJaasSession extends AuthenticatedWebSession {
public static final String ROLES_GROUP_NAME = "ROLES";
public static final String ROLES_PREFIX = "ROLE_";
public static final String APPLICATION_POLICY_NAME = "blog";
private Subject subject;
private Roles roles = new Roles();
@SuppressWarnings("deprecation")
public WicketJaasSession(AuthenticatedWebApplication app, Request request) {
@iocanel
iocanel / gist:1979615
Created March 5, 2012 17:26
Creating a wicket application that makes use of a custom authenticated session
public class WicketApplication extends AuthenticatedWebApplication {
/**
* Constructor
*/
public WicketApplication() {
}
@Override
protected void init() {
@iocanel
iocanel / gist:1979617
Created March 5, 2012 17:27
A wicket page with auth roles
@AuthorizeInstantiation("admin","manager")
public class HomePage extends WebPage {
}
@iocanel
iocanel / gist:1980336
Created March 5, 2012 18:53
Spring framework maven dependency
<dependency>
<groupid>org.springframework</groupid>
<artifactid>spring</artifactid>
<version>2.5.6</version>
</dependency>
@iocanel
iocanel / gist:1980339
Created March 5, 2012 18:54
Http Endpoint Manager
package net.iocanel.blog.servicemix.management;
import org.apache.servicemix.http.HttpEndpoint;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
/**
* A simple spring bean that gets injected an HttpEndpoint and exposes it to jmx
@iocanel
iocanel / gist:1980354
Created March 5, 2012 18:57
Attaching http endoint manager to http endpoint
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
xmlns:person="http://servicemix.apache.org/samples/wsdl-first">
<http:endpoint defaultmep="http://www.w3.org/2004/08/wsdl/in-out"
endpoint="soap"
id="httpEndpoint"
locationuri="http://0.0.0.0:8192/PersonService/"
role="consumer"
service="person:PersonService"
soap="true"