Search in sources :

Example 6 with ECCKeyPair

use of com.fitpay.android.api.models.security.ECCKeyPair in project fitpay-android-sdk by fitpay.

the class KeysManager method updateECCKey.

public void updateECCKey(@KeyType final int type, @NonNull final Runnable successRunnable, final ApiCallback callback) {
    try {
        ECCKeyPair keyPair = createPairForType(type);
        ApiCallback<ECCKeyPair> apiCallback = new ApiCallback<ECCKeyPair>() {

            @Override
            public void onSuccess(ECCKeyPair result) {
                result.setPrivateKey(mKeysMap.get(type).getPrivateKey());
                mKeysMap.put(type, result);
                if (successRunnable != null) {
                    successRunnable.run();
                }
            }

            @Override
            public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
                if (callback != null) {
                    callback.onFailure(errorCode, errorMessage);
                }
            }
        };
        Call<ECCKeyPair> getKeyCall = ApiManager.getInstance().getClient().createEncryptionKey(keyPair);
        getKeyCall.enqueue(new CallbackWrapper<>(apiCallback));
    } catch (Exception e) {
        FPLog.e(TAG, e);
        callback.onFailure(ResultCode.REQUEST_FAILED, e.toString());
    }
}
Also used : ApiCallback(com.fitpay.android.api.callbacks.ApiCallback) ECCKeyPair(com.fitpay.android.api.models.security.ECCKeyPair)

Aggregations

ECCKeyPair (com.fitpay.android.api.models.security.ECCKeyPair)6 JOSEException (com.nimbusds.jose.JOSEException)2 JWEHeader (com.nimbusds.jose.JWEHeader)2 JWEObject (com.nimbusds.jose.JWEObject)2 ECPublicKey (java.security.interfaces.ECPublicKey)2 ApiCallback (com.fitpay.android.api.callbacks.ApiCallback)1 EncryptionMethod (com.nimbusds.jose.EncryptionMethod)1 JWEAlgorithm (com.nimbusds.jose.JWEAlgorithm)1 JWEEncrypter (com.nimbusds.jose.JWEEncrypter)1 JWSVerifier (com.nimbusds.jose.JWSVerifier)1 Payload (com.nimbusds.jose.Payload)1 AESDecrypter (com.nimbusds.jose.crypto.AESDecrypter)1 AESEncrypter (com.nimbusds.jose.crypto.AESEncrypter)1 ECDSAVerifier (com.nimbusds.jose.crypto.ECDSAVerifier)1 SignedJWT (com.nimbusds.jwt.SignedJWT)1 KeyPair (java.security.KeyPair)1 KeyPairGenerator (java.security.KeyPairGenerator)1 SecureRandom (java.security.SecureRandom)1 ECPrivateKey (java.security.interfaces.ECPrivateKey)1 ECGenParameterSpec (java.security.spec.ECGenParameterSpec)1