Skip to content

Instantly share code, notes, and snippets.

public void handleMessage(Message msg) {
int status = msg.getData().getInt("status");
switch (status) {
case Status.INITIALISED:
case Status.SCANNER_POWERED_ON:
case Status.READY_TO_SCAN:
case Status.FINGER_DETECTED:
case Status.RECEIVING_IMAGE:
case Status.FINGER_LIFTED:
case Status.SCANNER_POWERED_OFF:
import java.io.IOException;
import java.nio.ByteBuffer;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class AndroidBmpUtil {
private static final int BMP_WIDTH_OF_TIMES = 4;
private static final int BYTE_PER_PIXEL = 3;
@DavidOndrus
DavidOndrus / RefreshTokenGrant.php
Created May 21, 2018 05:59
updated RefreshTokenGrant.php:respondToAccessTokenRequest
$newScopes = array();
$newScopesIdentifiers = array();
foreach ($scopes as $scope) {
if (in_array($scope->getIdentifier(), $oldRefreshToken['scopes'])) {
array_push($newScopes, $scope);
array_push($newScopesIdentifiers, $scope->getIdentifier());
}
}
@DavidOndrus
DavidOndrus / RefreshTokenGrant.php
Created May 21, 2018 05:58
old RefreshTokenGrant.php:respondToAccessTokenRequest
foreach ($scopes as $scope) {
if (in_array($scope->getIdentifier(), $oldRefreshToken['scopes']) === false) {
throw OAuthServerException::invalidScope($scope->getIdentifier());
}
}
...
$accessToken = $this->issueAccessToken($accessTokenTTL, $client, $oldRefreshToken['user_id'], $scopes);
...
@DavidOndrus
DavidOndrus / ok.js
Last active May 21, 2018 08:16
response 200
if (req.waterwheel) {
req.session.tokenInformation = _.cloneDeep(req.waterwheel.oauth.tokenInformation);
req.session.tokenExpireTime = req.waterwheel.oauth.tokenExpireTime;
}
@DavidOndrus
DavidOndrus / waterwheel.js
Created May 21, 2018 05:56
waterwheel.js policy
if (req.session.tokenInformation && req.session.tokenExpireTime) {
const config = _.cloneDeep(sails.config.waterwheel);
config.oauth = _.cloneDeep(req.session.tokenInformation);
config.oauth.tokenExpireTime = req.session.tokenExpireTime;
req.waterwheel = new Waterwheel(config);
}
req.session.tokenInformation = _.cloneDeep(waterwheel.oauth.tokenInformation);
req.session.tokenExpireTime = waterwheel.oauth.tokenExpireTime;
@DavidOndrus
DavidOndrus / waterwheel.js
Created May 21, 2018 05:54
waterwheel.js config
{
base: 'http://drupal',
oauth: {
grant_type: 'password',
client_id: '<client_id>',
client_secret: '<client_secret>',
scope: 'student teacher authenticated',
username: '<drupal_username>',
password: '<drupal_password>'
}
@DavidOndrus
DavidOndrus / UserController.js
Created May 21, 2018 05:54
User controller
User.getCurrentUser(waterwheelInstance, username).then(result....
@DavidOndrus
DavidOndrus / User.js
Created May 21, 2018 05:52
User service
getCurrentUser(waterwheelInstance, username) {
return waterwheelInstance.jsonapi.get('user/user', {
filter: { name: { value: username } } } );
}