public final class RedsysKeyConfig extends java.lang.Object implements RedsysKeyProcessingInterface, SessionHandler
RedsysKeyConfig
singleton class handles the configuration of all redsys related
cryptographic keys on the security processor.
RedsysKeyConfig
singleton class:
setCAKey(RedsysProcessorSlotEnum, RedsysKey, int, ProgressListener)
,
setCIKey(RedsysProcessorSlotEnum, String, RedsysKey, int, ProgressListener)
,
or setCPINKey(RedsysProcessorSlotEnum, String, RedsysKey, int, ProgressListener)
, etc)
can only be performed by opening a secure session with the security processor on the Yello terminalRedsysKeyConfig
singleton class can pe performed:
openSession(String, String, String, int)
(secure session)
or openSession(int)
(non-secure session for info retrieval only));openSession(SocketChannel, String, String, String, int)
or
openSession(SocketChannel, Certificate, Certificate, Key, int)
,
or via non-secure session method (for info retrieval only)
openSession(SocketChannel, int)
), provided that
that there is a proxy agent running on the Yello terminal to relay the request.
The proxy-agent can be implemented by the client.//Assuming that String ca_cert, cert and pkey are populated with data respectively from a SSL //CA Certificate, a SSL client certificate and SSL client private key, all in PEM format. // Assuming that ca_key_data is a byte array containing the Redsys CA key to update ... String ca_cert, cert, pkey; byte[] ca_key_data; // Populate ca_cert, cert, pkey // Populate ca_key_data; ... RedsysSystemConfig cfg = RedsysSystemConfig.getInstance(); try { cfg.openSession(ca_cert, cert, pkey, 0); cfg.setCAKey(RedsysProcessorSlotEnum.SLOT_1, new RedsysKey(ca_key_data), 0, null); } catch (Exception e) { Log.e("SetCAKey", "Failed to update CA Key" + e); } finally { cfg.closeSession(); }
//Assuming that String ca_cert, cert and pkey are populated with data respectively from a SSL //CA Certificate, a SSL client certificate and SSL client private key, all in PEM format. // Assuming that ctc_key_data is a byte array containing the Redsys CTC key to update // Assuming that ci_key_data is a byte array containing the Redsys CI key to encrypt the CTC key ... String ca_cert, cert, pkey; byte[] ctc_key_data; byte[] ci_key_data; // Populate ca_cert, cert, pkey // Populate ca_key_data; // Populate ci_key_data; ... RedsysSystemConfig cfg = RedsysSystemConfig.getInstance(); try { cfg.openSession(ca_cert, cert, pkey, 0); cfg.setCTCKey(RedsysProcessorSlotEnum.SLOT_1, new RedsysKey(ctc_1, ci_1), 0, null); } catch (Exception e) { Log.e("SetCTCKey", "Failed to update CTC Key" + e); } finally { cfg.closeSession(); }
Modifier and Type | Method and Description |
---|---|
void |
closeSession()
Closes the currently opened session (normal or secure) to the secure processor
|
void |
deleteAllOperationalKeys(int timeout,
ProgressListener listener)
Deletes all Operational Keys
|
java.lang.String |
getCCPKeysVersion(int timeoutMs)
Gets CCP Keys version
|
java.lang.String |
getCIKeyVersion(RedsysProcessorSlotEnum slotId,
int timeoutMs)
Get CI key version by slot
|
java.lang.String |
getCPINZoneIndex(RedsysProcessorSlotEnum slotId,
int timeoutMs)
Gets CPIN Zone index of a given Processor Slot.
|
static RedsysKeyConfig |
getInstance() |
java.lang.String |
getProcessorSlotKCV(RedsysProcessorSlotEnum slotId,
RedsysProcessorKeyTypeEnum keyType,
int timeoutMs)
Gets the Key KCV value of a given Processor Slot.
|
boolean |
isSessionOpened()
Checks if a session to the secure processor is already opened
|
void |
loadFactoryKeys(RedsysKey caf,
RedsysKey ctc,
int timeout,
ProgressListener listener)
Loads the factory keys
|
void |
openSession(int timeoutMs)
Opens a local session to the secure processor
(from an Android application running on the Yello terminal)
|
void |
openSession(java.nio.channels.SocketChannel channel,
java.security.cert.Certificate caCert,
java.security.cert.Certificate cert,
java.security.Key pKey,
int timeoutMs)
Opens a remote (from a PC or server) secure session to the secure processor.
|
void |
openSession(java.nio.channels.SocketChannel channel,
int timeoutMs)
Opens a remote (from PC or Server) session to the secure processor
|
void |
openSession(java.nio.channels.SocketChannel channel,
java.lang.String caCert,
java.lang.String cert,
java.lang.String pKey,
int timeoutMs)
Opens a remote (from a PC or server) secure session to the secure processor.
|
void |
openSession(java.lang.String caCert,
java.lang.String cert,
java.lang.String pKey,
int timeoutMs)
Opens a local secure session to the secure processor
(from an Android application running on the Yello terminal)
|
void |
setCAKey(RedsysProcessorSlotEnum slotId,
RedsysKey key,
int timeout,
ProgressListener listener)
Sets the CA key of a given Processor Slot
|
void |
setCCPKeys(java.lang.String version,
RedsysKey[] list,
int timeout,
ProgressListener listener)
Set CCP Keys
|
void |
setCIKey(RedsysProcessorSlotEnum slotId,
java.lang.String version,
RedsysKey key,
int timeout,
ProgressListener listener)
Sets the CI key of a given Processor Slot
|
void |
setCPINKey(RedsysProcessorSlotEnum slotId,
java.lang.String zoneIdx,
RedsysKey key,
int timeout,
ProgressListener listener)
Sets the CPIN key of a given Processor Slot
|
void |
setCTCKey(RedsysProcessorSlotEnum slotId,
RedsysKey key,
int timeout,
ProgressListener listener)
Sets the CTC key of a given Processor Slot
|
void |
updateCPINKey(RedsysProcessorSlotEnum slotId,
java.lang.String zoneIdx,
RedsysKey key,
int timeout,
ProgressListener listener)
Updates the CPIN key of a given Processor Slot
|
void |
updateCTCKey(RedsysProcessorSlotEnum slotId,
RedsysKey key,
int timeout,
ProgressListener listener)
Updates the CTC key of a given Processor Slot
|
void |
useExistingSession(boolean secure)
Uses an existing session opened by another SessionHandler
|
public static RedsysKeyConfig getInstance()
public void setCCPKeys(java.lang.String version, RedsysKey[] list, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
setCCPKeys
in interface RedsysKeyProcessingInterface
version
- key versionlist
- array of RedsysKey
CCP keys to be settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic java.lang.String getCCPKeysVersion(int timeoutMs) throws java.io.IOException
RedsysKeyProcessingInterface
getCCPKeysVersion
in interface RedsysKeyProcessingInterface
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.io.IOException
- if the operation cannot be performed due to IO errorspublic void setCIKey(RedsysProcessorSlotEnum slotId, java.lang.String version, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
setCIKey
in interface RedsysKeyProcessingInterface
slotId
- processor slot IDversion
- key versionkey
- RedsysKey
to settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic java.lang.String getCIKeyVersion(RedsysProcessorSlotEnum slotId, int timeoutMs) throws java.io.IOException
getCIKeyVersion
in interface RedsysKeyProcessingInterface
slotId
- processor slot IDtimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.io.IOException
- general errorpublic void setCAKey(RedsysProcessorSlotEnum slotId, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
setCAKey
in interface RedsysKeyProcessingInterface
slotId
- processor slot IDkey
- key to be settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void setCTCKey(RedsysProcessorSlotEnum slotId, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
setCTCKey
in interface RedsysKeyProcessingInterface
slotId
- processor slot IDkey
- RedsysKey
to settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void updateCTCKey(RedsysProcessorSlotEnum slotId, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
updateCTCKey
in interface RedsysKeyProcessingInterface
slotId
- RedsysProcessorSlotEnum
processor slot IDkey
- RedsysKey
to settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void setCPINKey(RedsysProcessorSlotEnum slotId, java.lang.String zoneIdx, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
setCPINKey
in interface RedsysKeyProcessingInterface
slotId
- RedsysProcessorSlotEnum
processor slot IDzoneIdx
- zone indexkey
- RedsysKey
to settimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void updateCPINKey(RedsysProcessorSlotEnum slotId, java.lang.String zoneIdx, RedsysKey key, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
updateCPINKey
in interface RedsysKeyProcessingInterface
slotId
- RedsysProcessorSlotEnum
processor slot IDzoneIdx
- zone indexkey
- RedsysKey
to updatetimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic java.lang.String getCPINZoneIndex(RedsysProcessorSlotEnum slotId, int timeoutMs) throws java.lang.Exception
RedsysKeyProcessingInterface
getCPINZoneIndex
in interface RedsysKeyProcessingInterface
slotId
- RedsysProcessorSlotEnum
processor slot IDtimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedRedsysKeyProcessingException
- general errorjava.lang.Exception
public java.lang.String getProcessorSlotKCV(RedsysProcessorSlotEnum slotId, RedsysProcessorKeyTypeEnum keyType, int timeoutMs) throws java.lang.Exception
RedsysKeyProcessingInterface
getProcessorSlotKCV
in interface RedsysKeyProcessingInterface
slotId
- RedsysProcessorSlotEnum
processor slot IDkeyType
- RedsysProcessorKeyTypeEnum
key typetimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedRedsysKeyProcessingException
- general errorjava.lang.Exception
public void deleteAllOperationalKeys(int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
deleteAllOperationalKeys
in interface RedsysKeyProcessingInterface
timeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void loadFactoryKeys(RedsysKey caf, RedsysKey ctc, int timeout, ProgressListener listener) throws RedsysKeyProcessingException
RedsysKeyProcessingInterface
loadFactoryKeys
in interface RedsysKeyProcessingInterface
caf
- RedsysKey
caf keyctc
- RedsysKey
ctc keytimeout
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedlistener
- ProgressListener
to keep track of the update. Optional, can be null.RedsysKeyProcessingException
- general errorpublic void openSession(java.nio.channels.SocketChannel channel, java.lang.String caCert, java.lang.String cert, java.lang.String pKey, int timeoutMs) throws java.lang.Exception
SessionHandler
openSession
in interface SessionHandler
channel
- SocketChannel opened and connected to a proxy agent running on the Yello terminalcaCert
- String containing SSL CA certificate data in PEM formatcert
- String containing an SSL client certificate data in PEM formatpKey
- String containing an SSL client private key data in PEM formattimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.lang.IllegalAccessException
- if a session (either secure or non-secure) is already openedjava.io.IOException
- if the session cannot be opened due to IO errors or if
the SocketChannel provided as parameter is not connected.java.lang.Exception
- for other types of exceptionspublic void openSession(java.nio.channels.SocketChannel channel, java.security.cert.Certificate caCert, java.security.cert.Certificate cert, java.security.Key pKey, int timeoutMs) throws java.lang.Exception
SessionHandler
openSession
in interface SessionHandler
channel
- SocketChannel opened and connected to a proxy agent running on the Yello terminalcaCert
- SSL CA certificatecert
- SSL client certificatepKey
- SSL client private keytimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.lang.IllegalAccessException
- if a session (either secure or non-secure) is already openedjava.io.IOException
- if the session cannot be opened due to IO errors or if
the SocketChannel provided as parameter is not connected.java.lang.Exception
- for other types of exceptionspublic void openSession(java.lang.String caCert, java.lang.String cert, java.lang.String pKey, int timeoutMs) throws java.lang.Exception
SessionHandler
openSession
in interface SessionHandler
caCert
- String containing SSL CA certificate data in PEM formatcert
- String containing an SSL client certificate data in PEM formatpKey
- String containing an SSL client private key data in PEM formattimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.lang.IllegalAccessException
- if a session (either secure or non-secure) is already opened.java.io.IOException
- if the session cannot be opened due to IO errors or if
the SocketChannel provided as parameter is not connected.java.lang.Exception
- for other types of exceptionspublic void openSession(java.nio.channels.SocketChannel channel, int timeoutMs) throws java.lang.Exception
SessionHandler
openSession
in interface SessionHandler
channel
- SocketChannel opened and connected to a proxy agent running on the Yello terminaltimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.lang.IllegalAccessException
- if a session (either secure or non-secure) is already opened.java.io.IOException
- if the session cannot be opened due to IO errors or if
the SocketChannel provided as parameter is not connected.java.lang.Exception
- for other types of exceptionspublic void openSession(int timeoutMs) throws java.lang.Exception
SessionHandler
openSession
in interface SessionHandler
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.lang.IllegalAccessException
- if a session (either secure or non-secure) is already opened.java.io.IOException
- if the session cannot be opened due to IO errors or if
the SocketChannel provided as parameter is not connected.java.lang.Exception
- for other types of exceptionspublic boolean isSessionOpened()
SessionHandler
isSessionOpened
in interface SessionHandler
public void closeSession()
SessionHandler
closeSession
in interface SessionHandler
public void useExistingSession(boolean secure) throws java.lang.Exception
SessionHandler
useExistingSession
in interface SessionHandler
secure
- boolean indicating whether to reused a secure session or plain sessionjava.lang.IllegalAccessException
- if no session is opened.java.lang.Exception
- for other types of exceptionsCopyright © 2019 Yello. All rights reserved.