|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ofbiz.accounting.thirdparty.valuelink.ValueLinkApi
public class ValueLinkApi
ValueLinkApi - Implementation of ValueLink Encryption & Transport
| Field Summary | |
|---|---|
protected boolean |
debug
|
protected Delegator |
delegator
|
protected javax.crypto.SecretKey |
kek
|
protected java.lang.String |
merchantId
|
static java.lang.String |
module
|
protected javax.crypto.SecretKey |
mwk
|
protected java.lang.Long |
mwkIndex
|
protected java.util.Properties |
props
|
protected java.lang.String |
terminalId
|
| Constructor Summary | |
|---|---|
protected |
ValueLinkApi()
|
protected |
ValueLinkApi(Delegator delegator,
java.util.Properties props)
|
| Method Summary | |
|---|---|
static byte[] |
copyBytes(byte[] source,
byte[] target,
int position)
Copies a byte[] into another byte[] starting at a specific position |
java.security.KeyPair |
createKeys()
Create a set of public/private keys using ValueLinks defined parameters |
protected byte[] |
cryptoViaKek(byte[] content,
int mode)
|
java.lang.String |
decryptPin(java.lang.String pin)
Decrypt an encrypted pin using the configured keys |
byte[] |
decryptViaKek(byte[] content)
Ue the KEK to decrypt a value |
java.lang.String |
encryptPin(java.lang.String pin)
Encrypt the defined pin using the configured keys |
byte[] |
encryptViaKek(byte[] content)
Use the KEK to encrypt a value usually the MWK |
byte[] |
generateKek(java.security.PrivateKey privateKey)
Generate a key exchange key for use in encrypting the mwk |
byte[] |
generateMwk()
Generate a new MWK |
byte[] |
generateMwk(byte[] desBytes)
Generate a new MWK |
byte[] |
generateMwk(javax.crypto.SecretKey mwkdes3)
Generate a new MWK |
java.lang.String |
getAmount(java.math.BigDecimal amount)
Returns a ValueLink formatted amount String |
java.math.BigDecimal |
getAmount(java.lang.String amount)
Returns a BigDecimal from a ValueLink formatted amount String |
static byte[] |
getByteRange(byte[] bytes,
int offset,
int length)
Returns a new byte[] from the offset of the defined byte[] with a specific number of bytes |
protected javax.crypto.Cipher |
getCipher(javax.crypto.SecretKey key,
int mode)
|
java.lang.String |
getCurrency(java.lang.String currency)
|
java.lang.String |
getDateString()
Returns a date string formatted as directed by ValueLink |
protected javax.crypto.SecretKey |
getDesEdeKey(byte[] rawKey)
|
protected javax.crypto.spec.DHParameterSpec |
getDHParameterSpec()
|
GenericValue |
getGenericValue()
Gets the cached value object for this merchant's keys |
java.util.Map<java.lang.String,java.lang.Object> |
getInitialRequestMap(java.util.Map<java.lang.String,java.lang.Object> context)
Creates a Map of initial request values (MerchID, AltMerchNo, Modes, MerchTime, TermTxnNo, EncryptID) Note: For 2010 (assign working key) transaction, the EncryptID will need to be adjusted |
static ValueLinkApi |
getInstance(Delegator delegator,
java.util.Properties props)
Obtain an instance of the ValueLinkApi; this method will always return an existing reference if one is available |
static ValueLinkApi |
getInstance(Delegator delegator,
java.util.Properties props,
boolean reload)
Obtain an instance of the ValueLinkApi |
protected byte[] |
getKek()
|
protected javax.crypto.SecretKey |
getKekKey()
|
protected byte[] |
getMwk()
|
protected javax.crypto.SecretKey |
getMwkKey()
|
protected byte[] |
getPinCheckSum(byte[] pinBytes)
|
java.security.PrivateKey |
getPrivateKey()
Get merchant Private Key |
protected byte[] |
getPrivateKeyBytes()
|
protected byte[] |
getRandomBytes(int length)
|
java.security.PublicKey |
getValueLinkPublicKey()
Get a public key object for the ValueLink supplied public key |
java.lang.Long |
getWorkingKeyIndex()
Returns the current working key index |
java.lang.StringBuffer |
outputKeyCreation(boolean kekOnly,
java.lang.String kekTest)
Output the creation of public/private keys + KEK to the console for manual database update |
protected java.util.Map<java.lang.String,java.lang.Object> |
parseResponse(java.lang.String response)
|
void |
reload()
Reloads the keys in the object cache; use this when re-creating keys |
java.util.Map<java.lang.String,java.lang.Object> |
send(java.util.Map<java.lang.String,java.lang.Object> request)
Transmit a request to ValueLink |
java.util.Map<java.lang.String,java.lang.Object> |
send(java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> request)
Transmit a request to ValueLink |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String module
protected Delegator delegator
protected java.util.Properties props
protected javax.crypto.SecretKey kek
protected javax.crypto.SecretKey mwk
protected java.lang.String merchantId
protected java.lang.String terminalId
protected java.lang.Long mwkIndex
protected boolean debug
| Constructor Detail |
|---|
protected ValueLinkApi()
protected ValueLinkApi(Delegator delegator,
java.util.Properties props)
| Method Detail |
|---|
public static ValueLinkApi getInstance(Delegator delegator,
java.util.Properties props,
boolean reload)
delegator - Delegator used to query the encryption keysprops - Properties to use for the Api (usually payment.properties)reload - When true, will replace an existing instance in the cache and reload all properties
public static ValueLinkApi getInstance(Delegator delegator,
java.util.Properties props)
delegator - Delegator used to query the encryption keysprops - Properties to use for the Api (usually payment.properties)
public java.lang.String encryptPin(java.lang.String pin)
pin - Plain text String of the pin
public java.lang.String decryptPin(java.lang.String pin)
pin - Hex String of the encrypted pin (EAN)
public java.util.Map<java.lang.String,java.lang.Object> send(java.util.Map<java.lang.String,java.lang.Object> request)
throws HttpClientException
request - Map of request parameters
HttpClientException
public java.util.Map<java.lang.String,java.lang.Object> send(java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> request)
throws HttpClientException
url - override URL from what is defined in the propertiesrequest - request Map of request parameters
HttpClientException
public java.lang.StringBuffer outputKeyCreation(boolean kekOnly,
java.lang.String kekTest)
public java.security.KeyPair createKeys()
throws java.security.NoSuchAlgorithmException,
java.security.InvalidAlgorithmParameterException,
java.security.spec.InvalidKeySpecException
java.security.NoSuchAlgorithmException
java.security.InvalidAlgorithmParameterException
java.security.spec.InvalidKeySpecException
public byte[] generateKek(java.security.PrivateKey privateKey)
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException,
java.security.InvalidKeyException
privateKey - The private key for the merchant
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.InvalidKeyException
public java.security.PublicKey getValueLinkPublicKey()
throws java.security.NoSuchAlgorithmException,
java.security.spec.InvalidKeySpecException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
public java.security.PrivateKey getPrivateKey()
throws java.security.spec.InvalidKeySpecException,
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.security.NoSuchAlgorithmExceptionpublic byte[] generateMwk()
public byte[] generateMwk(byte[] desBytes)
desBytes - byte array of the DES key (24 bytes)
public byte[] generateMwk(javax.crypto.SecretKey mwkdes3)
mwkdes3 - pre-generated DES3 SecretKey
public byte[] encryptViaKek(byte[] content)
content - byte array to encrypt
public byte[] decryptViaKek(byte[] content)
content - byte array to decrypt
public java.lang.String getDateString()
public java.lang.Long getWorkingKeyIndex()
public java.lang.String getAmount(java.math.BigDecimal amount)
amount - BigDecimal value to format
public java.math.BigDecimal getAmount(java.lang.String amount)
amount - The ValueLink formatted amount String
public java.lang.String getCurrency(java.lang.String currency)
public java.util.Map<java.lang.String,java.lang.Object> getInitialRequestMap(java.util.Map<java.lang.String,java.lang.Object> context)
public GenericValue getGenericValue()
public void reload()
protected javax.crypto.spec.DHParameterSpec getDHParameterSpec()
protected byte[] cryptoViaKek(byte[] content,
int mode)
protected javax.crypto.Cipher getCipher(javax.crypto.SecretKey key,
int mode)
protected byte[] getPinCheckSum(byte[] pinBytes)
protected byte[] getRandomBytes(int length)
protected javax.crypto.SecretKey getMwkKey()
protected javax.crypto.SecretKey getKekKey()
protected javax.crypto.SecretKey getDesEdeKey(byte[] rawKey)
protected byte[] getMwk()
protected byte[] getKek()
protected byte[] getPrivateKeyBytes()
protected java.util.Map<java.lang.String,java.lang.Object> parseResponse(java.lang.String response)
public static byte[] getByteRange(byte[] bytes,
int offset,
int length)
bytes - The byte[] to extract fromoffset - The starting postitionlength - The number of bytes to copy
public static byte[] copyBytes(byte[] source,
byte[] target,
int position)
source - byte[] to copy fromtarget - byte[] coping intoposition - the position on target where source will be copied to
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||