public class MifareSam extends SamBase
Example Usage: public class MainActivity extends Activity implements EMDKListener { SecureNfcManager secureNfcManager; EMDKManager emdkManager; SamType samType; MifareSam mifareSam; protected void onCreate(Bundle savedInstanceState) { EMDKResults results = EMDKManager.getEMDKManager( getApplicationContext(), this); } public void onOpened(EMDKManager emdkManager) { this.emdkManager = emdkManager; this.secureNfcManager = (secureNfcManager) this.emdkManager .getInstance(FEATURE_TYPE.SECURENFC); if (this.secureNfcManager != null) { samType = secureNfcManager.getAvailableSam(); if (samType.equals(SamType.MIFARE)) { mifareSam = (MifareSam) secureNfcMgr .getSamInstance(samType); if (mifareSam != null) { try { SamMode samMode = mifareSam.connect(); mifareSam.authenticateSam(authKey, samKey, null); mifareSam.close(); } catch (MifareSamException e) { e.printStackTrace(); } } } } } public void onDestroy() { if (this.emdkManager != null) this.emdkManager.release(); } public void onClosed() { this.emdkManager.release(); } }
Modifier and Type | Class and Description |
---|---|
class |
MifareSam.AdditionalAuthData
Mifare Sam additional authentication data
|
static class |
MifareSam.ProtectionMode
Protection mode
|
class |
MifareSam.SamInfo
SAM information
|
static class |
MifareSam.SamMode
SAM modes
|
Modifier and Type | Method and Description |
---|---|
void |
authenticateSam(byte[] authKey,
SamKey samKey,
MifareSam.AdditionalAuthData additionalAuthData)
Performs the SAM authentication.
|
void |
close()
Close with the SAM to perform I/O operations.
|
MifareSam.SamMode |
connect()
Connects to the SAM to perform I/O operations.
|
MifareSam.SamInfo |
getSamInfo()
Returns manufacturing related information of the MIFARESAM.
|
public static final String TAG
public MifareSam.SamMode connect() throws MifareSamException
MifareSamException
- The exception will be thrown if it fails to establish
connection with the SAM.public MifareSam.SamInfo getSamInfo() throws MifareSamException
MifareSamException
- The exception will be thrown if it fails to
return manufacturing related information of the SAM.public void authenticateSam(byte[] authKey, SamKey samKey, MifareSam.AdditionalAuthData additionalAuthData) throws MifareSamException
authKey
- Authentication key to be used.samKey
- SAM key to be used for authenticationadditionalAuthData
- Additional authentication data.MifareSamException
- The exception will be thrown if it fails to authenticate the
SAM.public void close() throws MifareSamException
MifareSamException
- The exception will be thrown if it fails to close the
connection with the SAM.