Skip to content

Commit

Permalink
Merge pull request crossbario#30 from magnux/master
Browse files Browse the repository at this point in the history
Fixes to WampCra Implementation
  • Loading branch information
Tobias Oberstein committed Mar 23, 2013
2 parents ccc2693 + 9365701 commit 80f8b96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 10 additions & 1 deletion Autobahn/src/de/tavendo/autobahn/WampCra.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public interface AuthHandler {
}


/**
* Authenticate the WAMP Session.
*
* @param authHandler The handler to be invoked upon authentication completion.
* @param authKey The user Key for authentication.
* @param authSecret The user Secret for authentication.
*/
public void authenticate(AuthHandler authHandler, String authKey, String authSecret);

/**
* Authenticate the WAMP Session.
*
Expand All @@ -50,7 +59,7 @@ public interface AuthHandler {
* @param authSecret The user Secret for authentication.
* @param authExtra Zero, one or more extra arguments for the authentication.
*/
public void authenticate(AuthHandler authHandler, String authKey, String authSecret, Object... authExtra);
public void authenticate(AuthHandler authHandler, String authKey, String authSecret, Object authExtra);


}
14 changes: 11 additions & 3 deletions Autobahn/src/de/tavendo/autobahn/WampCraConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@

public class WampCraConnection extends WampConnection implements WampCra {

public void authenticate(final AuthHandler authHandler, final String authKey, final String authSecret, Object... authExtra) {
call(Wamp.URI_WAMP_PROCEDURE + "authreq", String.class, new CallHandler(){
public void authenticate(final AuthHandler authHandler, final String authKey, final String authSecret){
authenticate(authHandler, authKey, authSecret, null);
}

public void authenticate(final AuthHandler authHandler, final String authKey, final String authSecret, Object authExtra) {
CallHandler callHandler = new CallHandler(){

public void onResult(Object challenge) {

Expand Down Expand Up @@ -62,7 +66,11 @@ public void onError(String errorUri, String errorDesc) {
authHandler.onAuthError(errorUri,errorDesc);
}

}, authKey, authExtra);
};
if (authExtra != null)
call(Wamp.URI_WAMP_PROCEDURE + "authreq", String.class, callHandler, authKey, authExtra);
else
call(Wamp.URI_WAMP_PROCEDURE + "authreq", String.class, callHandler, authKey);
}

public String authSignature(String authChallenge, String authSecret) throws SignatureException{
Expand Down

0 comments on commit 80f8b96

Please sign in to comment.