Package pt.gov.cartaodecidadao
Class PTEID_Card
- java.lang.Object
-
- pt.gov.cartaodecidadao.PTEID_Object
-
- pt.gov.cartaodecidadao.PTEID_Card
-
- All Implemented Interfaces:
PTEID_SigningDevice
- Direct Known Subclasses:
PTEID_SmartCard
public class PTEID_Card extends PTEID_Object implements PTEID_SigningDevice
Abstract base class for all the card type supported.
The PTEID_ReaderContext::getCard() method will return such an object.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddelete()PTEID_CertificategetAuthentication()PTEID_CertificategetCA()PTEID_CertificategetCert(PTEID_CertifType type)PTEID_CertificatesgetCertificates()PTEID_SigningDeviceTypegetDeviceType()PTEID_CertificategetRoot()PTEID_CertificategetSignature()PTEID_CardTypegetType()Return the type of the cardvoidinitPaceAuthentication(java.lang.String secret, long length, PTEID_CardPaceSecretType secretType)Init the Pace authentication processlongPTEID_SigningDevice_GetInterfaceCPtr()PTEID_ByteArrayreadFile(java.lang.String fileID)Read a File from the card.PTEID_ByteArrayreadFile(java.lang.String fileID, long ulOffset)Read a File from the card.PTEID_ByteArrayreadFile(java.lang.String fileID, long ulOffset, long ulMaxLength)Read a File from the card.PTEID_ByteArraysendAPDU(PTEID_ByteArray cmd)Send an APDU command to the card and get the result.PTEID_ByteArraySign(PTEID_ByteArray data)Signs a block of data using RSA-PKCS#1.
PTEID_ByteArraySign(PTEID_ByteArray data, boolean signatureKey)Signs a block of data using RSA-PKCS#1.
PTEID_ByteArraySign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType)Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
PTEID_ByteArraySign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType, boolean signatureKey)Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
voidSignASiC(java.lang.String path)voidSignASiC(java.lang.String path, PTEID_SignatureLevel level)intSignPDF(PTEID_PDFSignature sig_handler, int page, double coord_x, double coord_y, java.lang.String location, java.lang.String reason, java.lang.String outfile_path)intSignPDF(PTEID_PDFSignature sig_handler, int page, int page_sector, boolean is_landscape, java.lang.String location, java.lang.String reason, java.lang.String outfile_path)PTEID_ByteArraySignSHA256(PTEID_ByteArray data)Deprecated.Use PTEID_Card::Sign instead.PTEID_ByteArraySignSHA256(PTEID_ByteArray data, boolean signatureKey)Deprecated.Use PTEID_Card::Sign instead.PTEID_ByteArraySignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths)PTEID_ByteArraySignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths, PTEID_SignatureLevel level)PTEID_ByteArraySignXadesA(java.lang.String output_path, java.lang.String[] paths, long n_paths)voidSignXadesAIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)voidSignXadesIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)PTEID_ByteArraySignXadesT(java.lang.String output_path, java.lang.String[] paths, long n_paths)voidSignXadesTIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)booleanwriteFile(java.lang.String fileID, PTEID_ByteArray oData)Write a file to the card.booleanwriteFile(java.lang.String fileID, PTEID_ByteArray oData, long ulOffset)Write a file to the card.
-
-
-
Method Detail
-
delete
public void delete()
- Overrides:
deletein classPTEID_Object
-
PTEID_SigningDevice_GetInterfaceCPtr
public long PTEID_SigningDevice_GetInterfaceCPtr()
- Specified by:
PTEID_SigningDevice_GetInterfaceCPtrin interfacePTEID_SigningDevice
-
getType
public PTEID_CardType getType() throws PTEID_Exception
Return the type of the card- Throws:
PTEID_Exception
-
sendAPDU
public PTEID_ByteArray sendAPDU(PTEID_ByteArray cmd) throws PTEID_Exception
Send an APDU command to the card and get the result.- Parameters:
cmd- is the apdu command- Returns:
- A PTEID_ByteArray containing the result
- Throws:
PTEID_Exception
-
Sign
public PTEID_ByteArray Sign(PTEID_ByteArray data, boolean signatureKey) throws PTEID_Exception
Signs a block of data using RSA-PKCS#1.
- Specified by:
Signin interfacePTEID_SigningDevice- Parameters:
data- block of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, size of data array has to be at max 64 bytes.signatureKey- by default uses the 'Authentication private key' to sign message. Setting this to true makes use of 'Signature private key' instead.- Returns:
- PTEID_ByteArray containing the signature
- Throws:
PTEID_Exception
-
Sign
public PTEID_ByteArray Sign(PTEID_ByteArray data) throws PTEID_Exception
Signs a block of data using RSA-PKCS#1.
- Specified by:
Signin interfacePTEID_SigningDevice- Parameters:
data- block of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, size of data array has to be at max 64 bytes.
- Returns:
- PTEID_ByteArray containing the signature
- Throws:
PTEID_Exception
-
SignSHA256
public PTEID_ByteArray SignSHA256(PTEID_ByteArray data, boolean signatureKey) throws PTEID_Exception
Deprecated.Use PTEID_Card::Sign instead.- Specified by:
SignSHA256in interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignSHA256
public PTEID_ByteArray SignSHA256(PTEID_ByteArray data) throws PTEID_Exception
Deprecated.Use PTEID_Card::Sign instead.- Specified by:
SignSHA256in interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
Sign
public PTEID_ByteArray Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType, boolean signatureKey) throws PTEID_Exception
Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
- Parameters:
data- block of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, data has to be at max 64 bytes.paddingType- either RSA-PSS or RSA-PKCS#1signatureKey- by default uses the 'Authentication private key' to sign message. Setting this to true makes use of 'Signature private key' instead.- Returns:
- PTEID_ByteArray containing the signature
- Throws:
PTEID_Exception
-
Sign
public PTEID_ByteArray Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType) throws PTEID_Exception
Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
- Parameters:
data- block of data to be signed. Has to be hashed using either sha1, sha256, sha384 or sha512. Therefore, data has to be at max 64 bytes.paddingType- either RSA-PSS or RSA-PKCS#1
- Returns:
- PTEID_ByteArray containing the signature
- Throws:
PTEID_Exception
-
SignXades
public PTEID_ByteArray SignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths, PTEID_SignatureLevel level) throws PTEID_Exception
- Specified by:
SignXadesin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXades
public PTEID_ByteArray SignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception
- Specified by:
SignXadesin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesT
public PTEID_ByteArray SignXadesT(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception
- Specified by:
SignXadesTin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesA
public PTEID_ByteArray SignXadesA(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception
- Specified by:
SignXadesAin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesIndividual
public void SignXadesIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception- Specified by:
SignXadesIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesTIndividual
public void SignXadesTIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception- Specified by:
SignXadesTIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesAIndividual
public void SignXadesAIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths) throws PTEID_Exception- Specified by:
SignXadesAIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignASiC
public void SignASiC(java.lang.String path, PTEID_SignatureLevel level)- Specified by:
SignASiCin interfacePTEID_SigningDevice
-
SignASiC
public void SignASiC(java.lang.String path)
- Specified by:
SignASiCin interfacePTEID_SigningDevice
-
SignPDF
public int SignPDF(PTEID_PDFSignature sig_handler, int page, int page_sector, boolean is_landscape, java.lang.String location, java.lang.String reason, java.lang.String outfile_path) throws PTEID_Exception
- Specified by:
SignPDFin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignPDF
public int SignPDF(PTEID_PDFSignature sig_handler, int page, double coord_x, double coord_y, java.lang.String location, java.lang.String reason, java.lang.String outfile_path) throws PTEID_Exception
- Specified by:
SignPDFin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getCertificates
public PTEID_Certificates getCertificates() throws PTEID_Exception
- Specified by:
getCertificatesin interfacePTEID_SigningDevice- Returns:
- an object to access all the certificates on the card.
- Throws:
PTEID_Exception
-
getCert
public PTEID_Certificate getCert(PTEID_CertifType type) throws PTEID_Exception
- Specified by:
getCertin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getRoot
public PTEID_Certificate getRoot() throws PTEID_Exception
- Specified by:
getRootin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getCA
public PTEID_Certificate getCA() throws PTEID_Exception
- Specified by:
getCAin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getSignature
public PTEID_Certificate getSignature() throws PTEID_Exception
- Specified by:
getSignaturein interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getAuthentication
public PTEID_Certificate getAuthentication() throws PTEID_Exception
- Specified by:
getAuthenticationin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getDeviceType
public PTEID_SigningDeviceType getDeviceType()
- Specified by:
getDeviceTypein interfacePTEID_SigningDevice
-
readFile
public PTEID_ByteArray readFile(java.lang.String fileID, long ulOffset, long ulMaxLength) throws PTEID_Exception
Read a File from the card.- Parameters:
fileID- is the path of the fileulOffset- is the offset to begin the readingulMaxLength- is the maximum length of bytes to read- Returns:
- A PTEID_ByteArray with the content of the file
- Throws:
PTEID_Exception
-
readFile
public PTEID_ByteArray readFile(java.lang.String fileID, long ulOffset) throws PTEID_Exception
Read a File from the card.- Parameters:
fileID- is the path of the fileulOffset- is the offset to begin the reading
- Returns:
- A PTEID_ByteArray with the content of the file
- Throws:
PTEID_Exception
-
readFile
public PTEID_ByteArray readFile(java.lang.String fileID) throws PTEID_Exception
Read a File from the card.- Parameters:
fileID- is the path of the file
- Returns:
- A PTEID_ByteArray with the content of the file
- Throws:
PTEID_Exception
-
writeFile
public boolean writeFile(java.lang.String fileID, PTEID_ByteArray oData, long ulOffset) throws PTEID_ExceptionWrite a file to the card.- Parameters:
fileID- is the path of the fileoData- contents the bytes to writeulOffset- is the offset to begin the writing- Throws:
PTEID_Exception
-
writeFile
public boolean writeFile(java.lang.String fileID, PTEID_ByteArray oData) throws PTEID_ExceptionWrite a file to the card.- Parameters:
fileID- is the path of the fileoData- contents the bytes to write- Throws:
PTEID_Exception
-
initPaceAuthentication
public void initPaceAuthentication(java.lang.String secret, long length, PTEID_CardPaceSecretType secretType) throws PTEID_ExceptionInit the Pace authentication process- Parameters:
secret- string that holds the secret to make the PACE processlength- size of the secret stringsecretType- type of the secret used to make the PACE process- Throws:
PTEID_Exception
-
-