public class Sys extends java.lang.Object implements SessionHandler
Sys
singleton class comprises methods that one can use to access
non-security related system features (like get hardware information, secure date time,
setting led animation, etc) provided by the secure processor available on the Yello terminal.
Sys
singleton
class allows the user to access the system features either locally from the Yello Android device
or remotely from a PC or Server, provided that there is a proxy agent running on the Yello terminal
to relay the system requests. The proxy-agent can be implemented by the client.
openSession(int)
or openSession(String, String, String, int)
, which
notably allow an Android application to open respectively a normal session or a secure session
to the secure processor.
openSession(SocketChannel, int)
or
openSession(SocketChannel, String, String, String, int)
, which allows to open
respectively a normal session or a secure session to the secure-processor on the Yello terminal via
a SocketChannel connected to a proxy agent running on the Android side of the Yello terminal. In
this case, the proxy agent will just relay information being sent between the remote
client-application and the secure-processor.
import org.joda.time.Instant; ... Sys sys = Sys.getInstance(); try { //Use default connection timeout sys.openSession(0); //Use default request timeout Instant date = sys.getSecureDateTime(0); Log.i("DEMOAPI", "Secure date-time " + date.toString()); } catch(Exception e) { Log.e("DEMOAPI", "Exception " + e); } finally { sys.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. import org.joda.time.Instant; ... Sys sys = Sys.getInstance(); //Use default connection timeout try { sys.openSession(ca_cert, cert, pkey, 0); //Use default request timeout Instant date = sys.getSecureDateTime(0); Log.i("DEMOAPI", "Secure date-time " + date.toString()); } catch(Exception e) { Log.e("DEMOAPI", "Exception " + e); } finally { sys.closeSession(); }NOTE: full example of remote access will be provided at a later time.
Modifier and Type | Method and Description |
---|---|
void |
closeSession()
Closes the currently opened session (normal or secure) to the secure processor
|
static Sys |
getInstance()
Gets the instance of the
Sys singleton |
org.joda.time.Instant |
getSecureDateTime(int timeoutMs)
Gets date-time from the secure processor in UTC
|
HardwareInfo |
getSecureHardwareInfo(int timeoutMs)
Gets hardware information relative to the secure processor
|
LifeCycleType |
getSecureLifeCycleState(int timeoutMs)
Gets the current life cycle state of the secure processor
|
int |
getSecureTimeZoneOffset(int timeoutMs)
Gets the timezone offset in the secure processor
|
boolean |
isSessionOpened()
Checks if a session to the secure processor is already opened
|
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 |
setSecureTimeZoneOffset(int offset,
int timeoutMs)
Sets the timezone offset in the secure processor
|
int |
setSecurityLedBrightness(int brightness,
int timeoutMs)
Set security LEDs brightness
|
void |
startLedAnimation(LedAnimationType type,
int durationMs,
int timeoutMs)
Starts a led animation on the yello device
|
void |
stopLedAnimation(int timeoutMs)
Stops a led animation on the yello device
|
void |
useExistingSession(boolean secure)
Uses an existing session opened by another SessionHandler
|
public static Sys getInstance()
Sys
singletonSys
object.public int getSecureTimeZoneOffset(int timeoutMs) throws java.lang.Exception
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.io.IOException
- if the secure timezone cannot be obtained due to IO errors.java.lang.Exception
- for other types of exceptionspublic void setSecureTimeZoneOffset(int offset, int timeoutMs) throws java.lang.Exception
offset
- integer representing the timezone offset to set in secondstimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedjava.io.IOException
- if the secure timezone cannot be obtained due to IO errors.java.lang.Exception
- for other types of exceptionspublic org.joda.time.Instant getSecureDateTime(int timeoutMs) throws java.lang.Exception
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0, internal default timeout will be usedInstant
representing the secure date-time in UTCjava.io.IOException
- if the secure date-time cannot be obtained due to IO errors.java.lang.Exception
- for other types of exceptionspublic void startLedAnimation(LedAnimationType type, int durationMs, int timeoutMs) throws java.lang.Exception
type
- type of led animation to perform as defined in LedAnimationType
durationMs
- duration of the animation in milliseconds. If durationMs = 0,
animation is performed forever.timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0,
internal default timeout will be usedjava.lang.IllegalArgumentException
- if parameters are invalidjava.io.IOException
- if the led animation cannot be performed due to IO errors.java.lang.Exception
- for other types of exceptionspublic void stopLedAnimation(int timeoutMs) throws java.lang.Exception
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0,
internal default timeout will be usedjava.io.IOException
- if the led animation cannot be stopped due to IO errors.java.lang.Exception
- for other types of exceptionspublic LifeCycleType getSecureLifeCycleState(int timeoutMs) throws java.lang.Exception
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0,
internal default timeout will be usedLifeCycleType
representing the current life cycle state of the secure processorjava.io.IOException
- if the life cycle state cannot be retrieved due to IO errors.java.lang.Exception
- for other types of exceptionspublic HardwareInfo getSecureHardwareInfo(int timeoutMs) throws java.lang.Exception
timeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0,
internal default timeout will be usedHardwareInfo
representing the secure hardware informationjava.io.IOException
- if the secure hardware information cannot be retrieved due to IO errors.java.lang.Exception
- for other types of exceptionspublic int setSecurityLedBrightness(int brightness, int timeoutMs) throws java.lang.Exception
brightness
- brightness valuetimeoutMs
- Timeout in milliseconds. If timeoutMs is <= 0,
internal default timeout will be usedjava.lang.IllegalArgumentException
- if parameters are invalidjava.io.IOException
- if the led animation cannot be performed due to IO errors.java.lang.Exception
- for other types of exceptionspublic 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.