本文整理汇总了Java中org.jmrtd.PassportService类的典型用法代码示例。如果您正苦于以下问题:Java PassportService类的具体用法?Java PassportService怎么用?Java PassportService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PassportService类属于org.jmrtd包,在下文中一共展示了PassportService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signData
import org.jmrtd.PassportService; //导入依赖的package包/类
/**
* Signs 8 bytes by the passport using the AA functionality.
*
* @return byte[] - signed byte array
*/
public byte[] signData(PassportService ps, byte[] data) throws Exception{
InputStream is15 = null;
try {
is15 = ps.getInputStream(PassportService.EF_DG15);
// doAA of JMRTD library only returns signed data, and does not have the AA functionality yet
// there is no need for sending public key information with the method.
return ps.doAA(null, null, null, data);
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
} finally {
if (is15 != null)
is15.close();
}
}
示例2: getVoter
import org.jmrtd.PassportService; //导入依赖的package包/类
/**
* Get personal information about a voter from datagroup1.
* @return Voter - Voter object containing personal data.
*/
public Voter getVoter(PassportService ps) throws Exception {
InputStream is = null;
try {
is = ps.getInputStream(PassportService.EF_DG1);
DG1File dg1 = (DG1File) LDSFileUtil.getLDSFile(PassportService.EF_DG1, is);
MRZInfo mrzInfo = dg1.getMRZInfo();
//Replace '<' with spaces since JMRTD does not remove these.
return new Voter(mrzInfo.getSecondaryIdentifier().replaceAll("<", " ").trim(),
mrzInfo.getPrimaryIdentifier().replaceAll("<", " ").trim(),
mrzInfo.getGender());
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
} finally {
if (is != null)
is.close();
}
}
示例3: openConnection
import org.jmrtd.PassportService; //导入依赖的package包/类
/**
* Opens a connection with the ID by doing BAC
* Uses hardcoded parameters for now
*
* @param tag - NFC tag that started this activity (ID NFC tag)
* @return PassportService - passportservice that has an open connection with the ID
*/
public PassportService openConnection(Tag tag, final DocumentData docData) throws CardServiceException {
try {
IsoDep nfc = IsoDep.get(tag);
CardService cs = CardService.getInstance(nfc);
this.ps = new PassportService(cs);
this.ps.open();
// Get the information needed for BAC from the data provided by OCR
this.ps.sendSelectApplet(false);
BACKeySpec bacKey = new BACKeySpec() {
@Override
public String getDocumentNumber() {
return docData.getDocumentNumber();
}
@Override
public String getDateOfBirth() { return docData.getDateOfBirth(); }
@Override
public String getDateOfExpiry() { return docData.getExpiryDate(); }
};
ps.doBAC(bacKey);
return ps;
} catch (CardServiceException ex) {
try {
ps.close();
} catch (Exception ex2) {
ex2.printStackTrace();
}
throw ex;
}
}
示例4: getAAPublicKey
import org.jmrtd.PassportService; //导入依赖的package包/类
/**
* Retrieves the public key used for Active Authentication from datagroup 15.
*
* @return Publickey - returns the publickey used for AA
*/
public PublicKey getAAPublicKey(PassportService ps) throws Exception{
InputStream is15 = null;
try {
is15 = ps.getInputStream(PassportService.EF_DG15);
DG15File dg15 = new DG15File(is15);
return dg15.getPublicKey();
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
} finally {
if (is15 != null)
is15.close();
}
}