Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View danbev's full-sized avatar
⌨️
T.C.B "Taking care of business." Cosmo Kramer

Daniel Bevenius danbev

⌨️
T.C.B "Taking care of business." Cosmo Kramer
  • Red Hat
  • Sweden
  • 11:30 (UTC +02:00)
View GitHub Profile
@danbev
danbev / gist:6294945
Last active December 21, 2015 10:49
SimplePush Subsystem Configuration

SimplePush Server Subsystem Configuration

This is a suggestion for the configuration of the SimplePush WildFly subsystem (AGPUSH-242). Note that this includes all configurable options and we will provide resonable defaults so that all are not required.

<subsystem xmlns="urn:org.jboss.aerogear.simplepush:1.0">
    <server 
        socket-binding="simplepush-socket-binding" 
        datasource-jndi-name="java:jboss/datasources/SimplePushDS" 
        token-key="936agbbhh6ee99=999333" 
@danbev
danbev / gist:6000585
Last active December 19, 2015 18:39
Bio
Daniel Bevenius works as Senior Software Engineer at Red Hat, where he is part of the AeroGear team which is focused on mobile (native and HTML5). Daniel works with AeroGear's server side offerings and has recently been working on AeroGear SimplePush server, which is a implementation of Mozilla SimplePush Protocol. The implementation uses WebSocket, SockJS, Netty and vert.x.
@danbev
danbev / gist:5932671
Last active December 19, 2015 09:28
Netty testing scheduled jobs

Testing Netty handlers that start scheduled jobs.

I'm trying to write a test for a channel handler that starts a scheduled job. When invoking such a code path the follwing exception is thrown:

[main] INFO org.jboss.aerogear.simplepush.server.netty.ReaperHandler - Creating UserAgentReaper job : 2000
[main] ERROR io.netty.handler.codec.sockjs.transports.WebSocketSendHandler - Caught : 
java.lang.UnsupportedOperationException
  at io.netty.util.concurrent.AbstractEventExecutor.scheduleAtFixedRate(AbstractEventExecutor.java:127)
	at org.jboss.aerogear.simplepush.server.netty.ReaperHandler.userEventTriggered(ReaperHandler.java:51)
	at io.netty.channel.DefaultChannelHandlerContext.invokeUserEventTriggered(DefaultChannelHandlerContext.java:336)
	at io.netty.channel.DefaultChannelHandlerContext.fireUserEventTriggered(DefaultChannelHandlerContext.java:321)
curl -i --header "Accept: application/json" "http://localhost:8080/aerogear-controller-demo/test?firstname=John&lastname=Doe&username=john&password=123"
@danbev
danbev / gist:5097502
Last active December 14, 2015 13:59
Camel Controller Endpoint Implementation

Camel Integration

This document describes the task of creating a number of adapters/connectors to backend services. The requirement for this came from the desire to be able to configure routes using a "no-code" solution. This gist investigates the options for using Camel Components to make the connections to the backend services but having the original requirements in mind.

The following adapters/connectors have been requested:

  • REST
  • SOAP
  • SQL
  • JMS

Prototyping code for the examples in this gist can be found here:

@danbev
danbev / gist:5081215
Last active December 14, 2015 11:48
ios-otp-demo steps to reproduce error
  1. Deploy aerogear-controller-demo
  2. Try ios-otp-demo to login and validate otp
  3. Log in to aerogear-controller-demo with user 'john'
  4. Use the restricted admin page to register a new user
  5. Delete the newly created user
  6. Try the iso-otp-demo once again. For me the error below will be displayed in the servers console
11:00:24,761 INFO  [stdout] (http--127.0.0.1-8080-3) [Demo Error handler :null
11:00:24,788 ERROR [org.jboss.ejb3.invocation] (http--127.0.0.1-8080-3) JBAS014134: EJB Invocation failed on component Otp for method public org.jboss.aerogear.security.model.AeroGearUser org.jboss.aerogear.controller.demo.Otp.secret(): javax.ejb.EJBException: java.lang.NullPointerException
@danbev
danbev / gist:5048419
Created February 27, 2013 14:48
Roles stacktrace
15:43:19,357 ERROR [org.jboss.aerogear.controller.log] (http--127.0.0.1-8080-5) AG_CONTROLLER000005: Exception Message: 'Only Agent and Group types are supported for this relationship type.': org.picketlink.idm.IdentityManagementException: Only Agent and Group types are supported for this relationship type.
at org.picketlink.idm.internal.DefaultIdentityManager.grantRole(DefaultIdentityManager.java:464) [picketlink-idm-impl-3.0.0-2013Feb20.jar:]
at org.picketlink.internal.SecuredIdentityManager.grantRole(SecuredIdentityManager.java:142) [picketlink-core-impl-3.0.0-2013Feb20.jar:]
at org.jboss.aerogear.security.picketlink.authz.GrantConfiguration.to(GrantConfiguration.java:73) [aerogear-security-picketlink-1.0.0.CR1-SNAPSHOT.jar:1.0.0.CR1-SNAPSHOT]
at org.jboss.aerogear.security.picketlink.authz.GrantConfiguration$Proxy$_$$_WeldClientProxy.to(GrantConfiguration$Proxy$_$$_WeldClientProxy.java) [aerogear-security-picketlink-1.0.0.CR1-SNAPSHOT.jar:1.0.0.CR1-SNAPSHOT]
at org.
@danbev
danbev / gist:5005542
Last active December 14, 2015 01:19
Stacktrace
Caused by: java.lang.NullPointerException
        at org.picketlink.idm.credential.internal.PasswordCredentialHandler.validate(PasswordCredentialHandler.java:80) [picketlink-idm-impl-3.0.0-2013Feb20.jar:]
        at org.picketlink.idm.jpa.internal.JPAIdentityStore.validateCredentials(JPAIdentityStore.java:708) [picketlink-idm-impl-3.0.0-2013Feb20.jar:]
        at org.picketlink.idm.internal.DefaultIdentityManager.validateCredentials(DefaultIdentityManager.java:486) [picketlink-idm-impl-3.0.0-2013Feb20.jar:]
        at org.picketlink.internal.SecuredIdentityManager.validateCredentials(SecuredIdentityManager.java:167) [picketlink-core-impl-3.0.0-2013Feb20.jar:]
        at org.picketlink.authentication.internal.IdmAuthenticator.authenticate(IdmAuthenticator.java:35) [picketlink-core-impl-3.0.0-2013Feb20.jar:]
        at org.picketlink.internal.DefaultIdentity.authenticate(DefaultIdentity.java:153) [picketlink-core-impl-3.0.0-2013Feb20.jar:]
 ... 173 more
@danbev
danbev / gist:4986088
Last active December 13, 2015 22:39
PaginationStrategy

Custom PaginationStrategy

This section describes how a custom pagination strategy can be implemented in AeroGear Controller.
Depending on if you need a completely different strategy, or if you simply want to change/add/rename the returned HTTP response headers, you have two options:

  • Extend AbstractPaginationStrategy
  • Implement PaginationStrategy

Extend AbstractPaginationStrategy

You would extend AbstractPaginationStrategy if you simply want to change/add/rename the returned HTTP response headers.

Example of extending AbstractPaginationStrategy:

@danbev
danbev / gist:4983976
Last active December 13, 2015 22:19
Route testing

Simplifying Route testing

For AEROGEAR-778 we have been looking into making it easier to test routes. We have been using Mockito which works nicely, but there was a bit of duplicated code spread across different tests and also the test were not that easy to read.
Below are examples of one of the tests before and after, hopefully the after will be easier to read, but if not, then please let us know.

Before

@Test
    public void testRestRouteWithPathParam() throws Exception {
        final RoutingModule routingModule = new AbstractRoutingModule() {