-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new API endpoint for canceling a payout order
This commit adds a new API endpoint `cancelPayoutOrderById` to the `PayoutOrdersApi` class. This endpoint allows users to cancel a payout order by providing the ID of the resource. The method is a PUT request and is located at `/payout_orders/{id}/cancel`. The commit also includes updates to the documentation, specifically in the `PayoutOrdersApi.md` file, where the new endpoint is described along with its parameters and return type. Additionally, there are some changes made to other files such as `Makefile`, `README.md`, `EncryptedTypeAdapter.java`, `ApiKeyCreateResponse.java`, `ApiKeyRequest.java`, `ApiKeyResponse.java`, `ApiKeyResponseOnDelete.java`, `ApiKeyUpdateRequest.java`, and `BalanceCommonField.java`. These changes include code refactoring, imports optimization, and minor updates to class descriptions. These changes aim to improve code readability and maintainability.
- Loading branch information
Showing
183 changed files
with
6,981 additions
and
5,190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,34 @@ | ||
package io.conekta; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
import javax.crypto.Cipher; | ||
import java.io.IOException; | ||
import java.security.KeyFactory; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.PublicKey; | ||
import java.security.Security; | ||
import java.security.spec.InvalidKeySpecException; | ||
import java.security.spec.X509EncodedKeySpec; | ||
|
||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
import org.bouncycastle.util.encoders.Base64; | ||
|
||
public class EncryptedTypeAdapter extends TypeAdapter<String> { | ||
public class EncryptedTypeAdapter { | ||
|
||
private static final String PUBLIC_KEY_PEM = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjet2Jm4iPJTqDlW64tEG\nI9/dJTJAcn3OQdHrEwNXCz0/Rewqcv/Hm+V0klsUiS9h2W5CLC42q6wGhtl9Buu5\nvefuLVyxc8klEEjrSz/5AgfZ4HvzatbVX0KQhHI1j+caOjatDHM/ih13Rj7HIJFn\nAcutRB9vyFiCVluqRhlB9/64sqGtVmxJAir7WJp4TmpPvSEqeGKQIb80Tq+FYY7f\ntpMxQpsBT8B6y4Kn95ZfDH72H3yJezs/mExVB3M/OCBg+xt/c3dXp65JsbS482c4\nKhkxxHChNn1Y/nZ8kFYzakRGhh0BMqkvkqtAwcQJK1xPx2jRELS1vj7OFfMR+3ms\nSQIDAQAB\n-----END PUBLIC KEY-----"; | ||
|
||
private PublicKey publicKey; | ||
private PublicKey loadPublicKey(String publicKeyPem) throws NoSuchAlgorithmException, InvalidKeySpecException { | ||
byte[] keyBytes = Base64.decode(publicKeyPem.replaceAll("-----BEGIN PUBLIC KEY-----", "") | ||
.replaceAll("-----END PUBLIC KEY-----", "").replaceAll("\\s+", "")); | ||
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); | ||
return KeyFactory.getInstance("RSA").generatePublic(spec); | ||
|
||
public EncryptedTypeAdapter() throws Exception { | ||
Security.addProvider(new BouncyCastleProvider()); | ||
this.publicKey = loadPublicKey(PUBLIC_KEY_PEM); | ||
} | ||
|
||
@Override | ||
public void write(JsonWriter out, String value) throws IOException { | ||
public String encryptValue(String plainText) { | ||
try { | ||
out.value(encrypt(value, publicKey)); | ||
} catch (Exception e) { | ||
throw new IOException("Error encrypting value", e); | ||
PublicKey publicKey = loadPublicKey(PUBLIC_KEY_PEM); | ||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); | ||
Check failure Code scanning / CodeQL Use of RSA algorithm without OAEP High
This specification is used to
initialize an RSA cipher Error loading related location Loading |
||
cipher.init(Cipher.ENCRYPT_MODE, publicKey); | ||
byte[] encryptedBytes = cipher.doFinal(plainText.getBytes("UTF-8")); | ||
return Base64.toBase64String(encryptedBytes); | ||
}catch (Exception e){ | ||
return plainText; | ||
} | ||
} | ||
|
||
@Override | ||
public String read(JsonReader in) throws IOException { | ||
return in.nextString(); | ||
} | ||
|
||
public static String encrypt(String plainText, PublicKey publicKey) throws Exception { | ||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); | ||
cipher.init(Cipher.ENCRYPT_MODE, publicKey); | ||
byte[] encryptedBytes = cipher.doFinal(plainText.getBytes("UTF-8")); | ||
return Base64.toBase64String(encryptedBytes); | ||
} | ||
|
||
private PublicKey loadPublicKey(String publicKeyPem) throws Exception { | ||
byte[] keyBytes = Base64.decode(publicKeyPem.replaceAll("-----BEGIN PUBLIC KEY-----", "") | ||
.replaceAll("-----END PUBLIC KEY-----", "").replaceAll("\\s+", "")); | ||
X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); | ||
return KeyFactory.getInstance("RSA").generatePublic(spec); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.