Skip to content

Instantly share code, notes, and snippets.

View matzew's full-sized avatar
💩
hacking hacking hacking!

Matthias Wessendorf matzew

💩
hacking hacking hacking!
  • Red Hat
  • Emsdetten, Germany
View GitHub Profile
package net.wessendorf.undertow;
import io.undertow.Undertow;
import io.undertow.server.handlers.resource.FileResourceManager;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import java.io.File;
import java.util.logging.Logger;
import static io.undertow.Handlers.resource;

Plain WS works, pretty simple:

final WebSocketClient wsc = new WebSocketClient(new URI("ws://echo.websocket.org")) {
    @Override
    public void onOpen(ServerHandshake handshakedata) {
      System.out.println("connected");
    }

 @Override
final WebSocketContainer container = ContainerProvider.getWebSocketContainer();
final URI securedEndpointURL = new URI("wss://echo.websocket.org");
container.connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig config) {
System.out.println("Connected!!!!!");
}
//}, ClientEndpointConfig.Builder.create().build(), securedEndpointURL);
}, securedEndpointURL); // ah !!! :-)
@matzew
matzew / A_PasswordEncryption.java
Last active August 29, 2015 13:56
Simple AeroGear Crypto Example
package net.wessendorf.aerogear;
import org.jboss.aerogear.AeroGearCrypto;
import org.jboss.aerogear.crypto.password.DefaultPbkdf2;
import org.jboss.aerogear.crypto.password.Pbkdf2;
import org.junit.Before;
import org.junit.Test;
import java.security.spec.InvalidKeySpecException;
// When the program is in the foreground, this callback receives the Payload of the received Push Notification message
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// 'userInfo' contains information related to the remote notification.
//NSString *alertValue = [userInfo valueForKeyPath:@"aps.alert"];
NSLog(@"\nForeground: %@\n", userInfo);
}

User Foo has these friends:

  • mr_wolf
  • marcellus.Wallace

Now something w/ Foo happened, and all the friends need to be send a mobile push notification.

curl -3 -u "{PushApplicationID}:{MasterSecret}"
   -v -H "Accept: application/json" -H "Content-type: application/json"
 -X POST
@matzew
matzew / AppDelegate.m
Created February 20, 2014 17:05
Wake Up
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.repeatInterval = NSDayCalendarUnit;
[notification setAlertBody:@"Wake up! You lost a billion in stocks already!"];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
completionHandler(UIBackgroundFetchResultNewData);
@matzew
matzew / Cordova.md
Created March 17, 2014 16:10
Cordova Photo Picker
  1. cordova plugin add org.apache.cordova.camera

  2. simple HTML

	<img style="display:none;width:400px;height:400px;" id="bildcken" src="" />
	<button onclick="takePhoto();">TAKE IT</button>

And the required JS:

17:02:22,634 INFO [org.keycloak.services.managers.AuthenticationManager] (http--127.0.0.1-8080-6) authenticateCookie could not find cookie: KEYCLOAK_ADMIN_CONSOLE_IDENTITY
17:02:22,657 WARN [org.jboss.resteasy.core.ExceptionHandler] (http--127.0.0.1-8080-6) Failed executing GET /realms/UnifiedPushServer/tokens/login: org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: org.keycloak.services.ClientConnection
at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:54) [resteasy-jaxrs-3.0.6.Final.jar:]
at $Proxy98.getRemoteAddr(Unknown Source) at org.keycloak.services.resources.RealmsResource.createAudit(RealmsResource.java:129) [keycloak-services-1.0-beta-1-SNAPSHOT.jar:]
at org.keycloak.services.resources.RealmsResource.getTokenService(RealmsResource.java:71) [keycloak-services-1.0-beta-1-SNAPSHOT.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl
<dependency>
<groupId>org.jboss.aerogear</groupId>
<artifactId>unifiedpush-java-client</artifactId>
<version>0.5.0</version>
</dependency>