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 / PermissionHandlerActivity.java
Last active July 11, 2016 14:52
Permissions on Android M
/*
* PermissionHandlerActivity.java
*
* Copyright (c) 2016 Auth0 (http://auth0.com)
*
* 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
@lbalmaceda
lbalmaceda / AuthorizedIdentityProvider.java
Last active March 3, 2016 00:48
CustomIdentityProvider accepts checking for granted permissions before starting the authentication flow.
/**
* Interface for allowing an IdentityProvider to request specific permissions
* before calling start.
*/
public abstract class AuthorizedIdentityProvider implements IdentityProvider, PermissionCallback {
protected IdentityProvider idp;
public AuthorizedIdentityProvider(@NonNull IdentityProvider idp){
this.idp = idp;
@lbalmaceda
lbalmaceda / CustomField.java
Created April 25, 2016 16:22
Custom SignUp Fields
public class CustomField implements Parcelable {
private static final int CAP_SENTENCES = 0;
private static final int CAP_WORDS = 1;
private static final int CAP_CHARACTERS = 2;
private static final int MAX_ALLOWED_LENGTH = 100;
private int cap;
private int maxLength;
private boolean onlyNumbers;
private boolean hideInput;
@lbalmaceda
lbalmaceda / custom-social-connectons.md
Created May 10, 2016 22:36
Custom Social Connections on Lock v2

Custom Social Connections

Auth0 Dashboard

Configure the custom social connection on the dashboard by adding all the data needed by the extension.

  • Name
  • Authorization URL
  • Token URL
  • Client ID
  • Client Secret
@lbalmaceda
lbalmaceda / auth-error.md
Last active June 16, 2016 19:41
Remove auth0-java dependency from lock.android

Move auth0-java into auth0 (inside Lock.Android)

Some thoughts

At first, I wanted AuthenticationError to be a class not extending any Exception class. It received the Map<Object, String> and the Throwable to keep the error stack. Then I've found that many calls from our *Request classes instantiated a new Auth0Exception giving a simple message like "cannot parse this JSON" or "invalid response" instead of the values map, so I needed to add that String as another parameter. Maybe in a second constructor.

It seems better to extend Auth0Exception so the default getMessage() and getCause() were there already. I thought about creating an interface AuthenticationError with the common error methods, like getError(), getDescription() and the rest of the values inside a map getValues(). So I ended up with a class that extends Auth0Exception and implements AuthenticationError. ---> AuthenticationException.

I tried making the callback.onFailure return an AuthenticationError (interface) ob

@lbalmaceda
lbalmaceda / android_osx_setup.md
Last active February 26, 2021 08:14
Mac OS X Environment Setup with Android

Mac OS X Environment Setup with Android

Every time I format the drive and perform a clean install of the SO, I end up searching for my favorite stuff. This file tries to sum up my setup.

Browser

Download Chrome.

Also install the latest JDK (Java Development Kit).

Text Editor

package com.lbalmaceda.genericsproject;
import com.lbalmaceda.genericsproject.exceptions.CustomException;
/**
* Created by lbalmaceda on 6/21/16.
*/
public interface CustomCallback<T, U extends CustomException> {
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);
@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 / 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;