Skip to content

Instantly share code, notes, and snippets.

View gsandaru's full-sized avatar

GIHAN SANDARU gsandaru

View GitHub Profile
@gsandaru
gsandaru / minio-ssl-nginx-docker-compose.yml
Last active January 30, 2022 16:21
Minio Setup with SSL / Nginx (https-portal) - Docker
services:
https-portal:
image: steveltn/https-portal:1
ports:
- 80:80
- 443:443
restart: always
networks:
- front-tier
environment:
@gsandaru
gsandaru / ArticleGist2.md
Created January 4, 2020 18:56
NodeJS Client Setup KeyCloak

Imports

    const session =  require("express-session");
    const Keycloak =  require("keycloak-connect");    
    const express =  require("express");    
    const app =  express(); 
@gsandaru
gsandaru / ArticleGist1.md
Created January 4, 2020 18:52
AndroidClientSetup

Dependancies build.gradle(Module: app)

implementation ('org.jboss.aerogear:aerogear-android-authz:2.0.0') {  
        exclude module : 'compatibility-v4'  
        transitive = true  
    }
@gsandaru
gsandaru / AndroidAndKeyCloak.md
Last active April 21, 2020 17:52
OAuth2 Guide for Node Rest APIs and Android clients using KeyCloak Identity Server

OAuth2 Guide for Node Rest APIs and Android clients using KeyCloak Identity Server

What is KeyCloak ?

Keycloak is an open source Identity and Access Management solution aimed at modern applications and services. It makes it easy to secure applications and services with little to no code. It's open source and free to use

When to use KeyCloak ?

  • When you don't know how to implement complex role based user authentication/ authorization mechanism to your app.
  • Accelerated development time? maybe you'll have great business logic to focus on.

Few steps to complete !

  1. Setup and deploy KeyCloak Server. ( In 5 Mins ?😎😎 )
  2. Setup Realms and Clients.
@gsandaru
gsandaru / NotificationSnippets.java
Last active October 22, 2019 10:28
Notification Snippets
private static final String CHANNEL_ID = "com.apps.testnotifications" ;
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.app_name);
String description = getString(R.string.app_name);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
@gsandaru
gsandaru / CryptoUtilsTest.java
Last active February 8, 2021 20:06
AES and Blowfish file encryption for Android
import android.os.Environment;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
@gsandaru
gsandaru / test.java
Last active August 15, 2019 12:48
Java,Android - Get RSAPrivateKey and RSAPublicKey from String
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
try {
String privateKeyContent = sharedPreferences.getString("SAMPLE_KEY_PRI",null); // load private key here
data class Repo(
val `private`: Boolean,
val archive_url: String,
val archived: Boolean,
val assignees_url: String,
val blobs_url: String,
val branches_url: String,
val clone_url: String,
val collaborators_url: String,
val comments_url: String,
@gsandaru
gsandaru / app.js
Created April 10, 2018 17:31
Dynamsoft Dynamic Web TWAIN + Angular JS Sample
var app = angular.module('app',[]);
app.controller('homeCtrl', function($scope){
var DWObject;
$scope.initiate = function () {
Dynamsoft.WebTwainEnv.Load();
}
$scope.AcquireImage = function(){
Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', $scope.Dynamsoft_OnReady());