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 void
delete()
PTEID_Certificate
getAuthentication()
PTEID_Certificate
getCA()
PTEID_Certificate
getCert(PTEID_CertifType type)
PTEID_Certificates
getCertificates()
PTEID_SigningDeviceType
getDeviceType()
PTEID_Certificate
getRoot()
PTEID_Certificate
getSignature()
PTEID_CardType
getType()
Return the type of the cardvoid
initPaceAuthentication(java.lang.String secret, long length, PTEID_CardPaceSecretType secretType)
Init the Pace authentication processlong
PTEID_SigningDevice_GetInterfaceCPtr()
PTEID_ByteArray
readFile(java.lang.String fileID)
Read a File from the card.PTEID_ByteArray
readFile(java.lang.String fileID, long ulOffset)
Read a File from the card.PTEID_ByteArray
readFile(java.lang.String fileID, long ulOffset, long ulMaxLength)
Read a File from the card.PTEID_ByteArray
sendAPDU(PTEID_ByteArray cmd)
Send an APDU command to the card and get the result.PTEID_ByteArray
Sign(PTEID_ByteArray data)
Signs a block of data using RSA-PKCS#1.
PTEID_ByteArray
Sign(PTEID_ByteArray data, boolean signatureKey)
Signs a block of data using RSA-PKCS#1.
PTEID_ByteArray
Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType)
Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
PTEID_ByteArray
Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType, boolean signatureKey)
Signs a block of data using either RSA-PKCS#1 or RSA-PSS.
void
SignASiC(java.lang.String path)
void
SignASiC(java.lang.String path, PTEID_SignatureLevel level)
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)
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)
PTEID_ByteArray
SignSHA256(PTEID_ByteArray data)
Deprecated.Use PTEID_Card::Sign instead.PTEID_ByteArray
SignSHA256(PTEID_ByteArray data, boolean signatureKey)
Deprecated.Use PTEID_Card::Sign instead.PTEID_ByteArray
SignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths)
PTEID_ByteArray
SignXades(java.lang.String output_path, java.lang.String[] paths, long n_paths, PTEID_SignatureLevel level)
PTEID_ByteArray
SignXadesA(java.lang.String output_path, java.lang.String[] paths, long n_paths)
void
SignXadesAIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)
void
SignXadesIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)
PTEID_ByteArray
SignXadesT(java.lang.String output_path, java.lang.String[] paths, long n_paths)
void
SignXadesTIndividual(java.lang.String output_path, java.lang.String[] paths, long n_paths)
boolean
writeFile(java.lang.String fileID, PTEID_ByteArray oData)
Write a file to the card.boolean
writeFile(java.lang.String fileID, PTEID_ByteArray oData, long ulOffset)
Write a file to the card.
-
-
-
Method Detail
-
delete
public void delete()
- Overrides:
delete
in classPTEID_Object
-
PTEID_SigningDevice_GetInterfaceCPtr
public long PTEID_SigningDevice_GetInterfaceCPtr()
- Specified by:
PTEID_SigningDevice_GetInterfaceCPtr
in 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:
Sign
in 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:
Sign
in 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:
SignSHA256
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
SignSHA256
public PTEID_ByteArray SignSHA256(PTEID_ByteArray data) throws PTEID_Exception
Deprecated.Use PTEID_Card::Sign instead.- Specified by:
SignSHA256
in 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:
SignXades
in 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:
SignXades
in 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:
SignXadesT
in 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:
SignXadesA
in 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:
SignXadesIndividual
in 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:
SignXadesTIndividual
in 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:
SignXadesAIndividual
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
SignASiC
public void SignASiC(java.lang.String path, PTEID_SignatureLevel level)
- Specified by:
SignASiC
in interfacePTEID_SigningDevice
-
SignASiC
public void SignASiC(java.lang.String path)
- Specified by:
SignASiC
in 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:
SignPDF
in 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:
SignPDF
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getCertificates
public PTEID_Certificates getCertificates() throws PTEID_Exception
- Specified by:
getCertificates
in 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:
getCert
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getRoot
public PTEID_Certificate getRoot() throws PTEID_Exception
- Specified by:
getRoot
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getCA
public PTEID_Certificate getCA() throws PTEID_Exception
- Specified by:
getCA
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getSignature
public PTEID_Certificate getSignature() throws PTEID_Exception
- Specified by:
getSignature
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getAuthentication
public PTEID_Certificate getAuthentication() throws PTEID_Exception
- Specified by:
getAuthentication
in interfacePTEID_SigningDevice
- Throws:
PTEID_Exception
-
getDeviceType
public PTEID_SigningDeviceType getDeviceType()
- Specified by:
getDeviceType
in 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_Exception
Write 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_Exception
Write 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_Exception
Init 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
-
-