Skip to content

Instantly share code, notes, and snippets.

View lbalmaceda's full-sized avatar

Luciano Balmaceda lbalmaceda

  • Barcelona, Spain
View GitHub Profile
@lbalmaceda
lbalmaceda / dollar.sh
Created April 10, 2019 14:25 — forked from miguelangelgonzalez/dollar.sh
Get the quote of the dollar in the main Argentine banks
while true;do clear;echo "Cotizacion $(date)";echo -e "Dolar (Santander) : \t" $(curl -Ls "https://bit.ly/2O9Mvvm"|grep '[0-9]{2},[0-9]{2}' -Eo|head -n2);echo -e "Dolar (Nacion) : \t" $(curl -Ls "https://bit.ly/2NvKhcM"|tr -d ' '|grep DolarU\.S\.A -A2|grep -oE '[0-9]{2},[0-9]{2}'|tr '\n' ' ');echo -e "Dolar (Galicia) : \t" $(curl -Ls "https://bit.ly/2wWvApx"|jq -r '.buy + "0", .sell + "0"'|tr '\n' ' ');echo -e "Dolar (BBVA-Frances) : \t" $(curl -Ls "https://bit.ly/2O0wxUt"|iconv -f iso-8859-1 -t utf-8|sed -n "s,detalles,\n,gp"|grep -oE '[0-9]{2},[0-9]{2}'|head -n2|tr '\n' ' ');sleep 600;done
@lbalmaceda
lbalmaceda / PemUtils.java
Created June 15, 2018 14:32
Pem Keys file reader for Java
//Copyright 2017 - https://github.com/lbalmaceda
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOF
@lbalmaceda
lbalmaceda / CredentialsManagerUpdatev2.md
Created August 23, 2017 18:08
Credentials Manager v2

Secure CredentialsManager (v2)

We can enhance the existing manager to make it encrypt/decrypt the content before persisting it. Then as an extra improvement, we can ask for user authentication before allowing them to obtain the credentials.

APIs

  • API 18 introduces the algorithm I'm using to encrypt/decrypt.
  • API 21 introduces the Intent to call the LockScreen and wait for a cancel/pass signal.
  • API 23 introduces the protected keys, which means that in every key use we can ask for the user to be authenticated first.

The CredentialsManager usage can be divided in two:

@lbalmaceda
lbalmaceda / AuthenticatedCredentialsManager.md
Created August 17, 2017 17:36
Add authentication to the CredentialsManager

Authenticated CredentialsManager

The simple credentials manager receives a pair of Credentials and perform:

  • Storage of the values (either 1 by 1 or all together in a single operation)
  • Retrieval of the values (either 1 by 1 or all together in a single operation)
  • Check for existing credentials
  • Check for valid credentials and renew them if required

Because the manager receives a Storage, which abstracts the logic of reading/writing stuff, how the values are persisted is up to that implementation. What it's missing is a security layer to encrypt the values before saving them, ask for authentication before retrieving them, or both of the previous.

@lbalmaceda
lbalmaceda / CredentialsManagerUpdate.md
Last active July 5, 2017 13:25
Credentials Manager Report

CredentialsManager

Recently we introduced a helper class available here to handle Auth0 Credentials. Usage is simple: Once you create a new instance by passing an AuthenticationAPIClient (to renew credentials) and a Storage (to do persistance), you can call any of this 2 public methods:

  • saveCredentials: To synchronously save a pair of credentials in the storage. Will throw if the access_token or id_token is null, or if the expires_at date is missing.
  • getCredentials: To asynchronously get a pair of credentials from the storage.
    • If no credentials were stored before the methods fails.
    • If stored credentials have expired (expires_at > now) and no refresh_token was saved the method fails.
    • If the call to renew the credentials using the refresh_token fails, the method fails.
  • In any other case, a valid pair of credentials is ret
@lbalmaceda
lbalmaceda / fingerprint.md
Created April 17, 2017 15:10
Auth0 Fingerprint API

Auth0 Fingerprint API

Create a new instance

The context is needed to access the check for availability

public class Auth0Fingerprint implements FingerprintManager.AuthenticationCallback {

  private final FingerprintManagerCompat manager;
@lbalmaceda
lbalmaceda / circle.yml
Created March 15, 2017 17:32
CircleCI script for Android builds
#
# Build configuration for Circle CI
#
machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
ANDROID_API_LEVEL: 25
@lbalmaceda
lbalmaceda / AuthProvider.java
Last active July 1, 2016 18:10
Android IdP Improvement
//This is the abstract AuthProvider, with permission handling.
public abstract class AuthProvider implements PermissionProvider {
public AuthProvider(@NonNull PermissionHandler handler) {
this.handler = handler;
}
public void start(@NonNull Activity activity, @NonNull AuthCallback callback, int permissionRequestCode) {
this.callback = callback;
@lbalmaceda
lbalmaceda / genericsproject_CustomCallback.java
Created June 22, 2016 17:11
Generics with Factory as Interface
package com.lbalmaceda.genericsproject;
import com.lbalmaceda.genericsproject.exceptions.BaseException;
/**
* Created by lbalmaceda on 6/21/16.
*/
public interface CustomCallback<T, U extends BaseException> {
void onSuccess(T response);
@lbalmaceda
lbalmaceda / genericsproject_CustomCallback.java
Created June 22, 2016 16:11
Generics with Exception error builder
package com.lbalmaceda.genericsproject;
import com.lbalmaceda.genericsproject.exceptions.BaseException;
/**
* Created by lbalmaceda on 6/21/16.
*/
public interface CustomCallback<T, U extends BaseException> {
void onSuccess(T response);