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
Abstract base class for all the card types supported.
PTEID_ReaderContext::getCard() method
will return such an object.
PTEID_ReaderContext::getCard() method
will return such an object.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete()getCA()getCert(PTEID_CertifType type) getRoot()getType()Return the type of the cardvoidinitPaceAuthentication(String secret, long length, PTEID_CardPaceSecretType secretType) Init the Pace authentication processlongRead a File from the card.Read a File from the card.Read a File from the card.sendAPDU(PTEID_ByteArray cmd) Send an APDU command to the card and get the result.Sign(PTEID_ByteArray data) Signs a block of data using RSA-PKCS#1 using cards of type PTEID_CARDTYPE_IAS07 or ECDSA using newer cards of type PTEID_CARDTYPE_IAS5
In the ECDSA case the signature is returned in IEEE P1363 format, i.e.Sign(PTEID_ByteArray data, boolean signatureKey) Signs a block of data using RSA-PKCS#1 using cards of type PTEID_CARDTYPE_IAS07 or ECDSA using newer cards of type PTEID_CARDTYPE_IAS5
In the ECDSA case the signature is returned in IEEE P1363 format, i.e.Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType) Signs a block of data using RSA-PKCS#1, RSA-PSS or ECDSA.Sign(PTEID_ByteArray data, PTEID_RSAPaddingType paddingType, boolean signatureKey) Signs a block of data using RSA-PKCS#1, RSA-PSS or ECDSA.voidvoidSignASiC(String path, PTEID_SignatureLevel level) intSignPDF(PTEID_PDFSignature sig_handler, int page, double coord_x, double coord_y, String location, String reason, String outfile_path) intSignPDF(PTEID_PDFSignature sig_handler, int page, int page_sector, boolean is_landscape, String location, String reason, String outfile_path) SignSHA256(PTEID_ByteArray data) Deprecated.Use PTEID_Card::Sign instead.SignSHA256(PTEID_ByteArray data, boolean signatureKey) Deprecated.Use PTEID_Card::Sign instead.SignXades(String output_path, String[] paths, long n_paths, PTEID_SignatureLevel level) SignXadesA(String output_path, String[] paths, long n_paths) voidSignXadesAIndividual(String output_path, String[] paths, long n_paths) voidSignXadesIndividual(String output_path, String[] paths, long n_paths) SignXadesT(String output_path, String[] paths, long n_paths) voidSignXadesTIndividual(String output_path, String[] paths, long n_paths) booleanwriteFile(String fileID, PTEID_ByteArray oData) Write a file to the card.booleanwriteFile(String fileID, PTEID_ByteArray oData, long ulOffset) Write a file to the card.
-
Method Details
-
delete
public void delete()- Overrides:
deletein classPTEID_Object
-
PTEID_SigningDevice_GetInterfaceCPtr
public long PTEID_SigningDevice_GetInterfaceCPtr()- Specified by:
PTEID_SigningDevice_GetInterfaceCPtrin interfacePTEID_SigningDevice
-
getType
Return the type of the card- Throws:
PTEID_Exception
-
sendAPDU
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
Signs a block of data using RSA-PKCS#1 using cards of type PTEID_CARDTYPE_IAS07 or ECDSA using newer cards of type PTEID_CARDTYPE_IAS5
In the ECDSA case the signature is returned in IEEE P1363 format, i.e. the signature is the concatenation of r and s values generated by the algorithm.
In some application contexts encoding the signature into the ASN.1 format described in RFC-5480 may be needed.
- 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
Signs a block of data using RSA-PKCS#1 using cards of type PTEID_CARDTYPE_IAS07 or ECDSA using newer cards of type PTEID_CARDTYPE_IAS5
In the ECDSA case the signature is returned in IEEE P1363 format, i.e. the signature is the concatenation of r and s values generated by the algorithm.
In some application contexts encoding the signature into the ASN.1 format described in RFC-5480 may be needed.
- 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
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 RSA-PKCS#1, RSA-PSS or ECDSA. This method can be used to select the RSA padding algorithm to use with cards
of type PTEID_CARDTYPE_IAS07. When using newer cards of type PTEID_CARDTYPE_IAS5 parameter is ignored and an ECDSA signature is returned.
- 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 RSA-PKCS#1, RSA-PSS or ECDSA. This method can be used to select the RSA padding algorithm to use with cards
of type PTEID_CARDTYPE_IAS07. When using newer cards of type PTEID_CARDTYPE_IAS5 parameter is ignored and an ECDSA signature is returned.
- 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(String output_path, String[] paths, long n_paths, PTEID_SignatureLevel level) throws PTEID_Exception - Specified by:
SignXadesin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXades
public PTEID_ByteArray SignXades(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesT
public PTEID_ByteArray SignXadesT(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesTin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesA
public PTEID_ByteArray SignXadesA(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesAin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesIndividual
public void SignXadesIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesTIndividual
public void SignXadesTIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesTIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignXadesAIndividual
public void SignXadesAIndividual(String output_path, String[] paths, long n_paths) throws PTEID_Exception - Specified by:
SignXadesAIndividualin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
SignASiC
- Specified by:
SignASiCin interfacePTEID_SigningDevice
-
SignASiC
- Specified by:
SignASiCin interfacePTEID_SigningDevice
-
SignPDF
public int SignPDF(PTEID_PDFSignature sig_handler, int page, int page_sector, boolean is_landscape, String location, String reason, 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, String location, String reason, String outfile_path) throws PTEID_Exception - Specified by:
SignPDFin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getCertificates
- Specified by:
getCertificatesin interfacePTEID_SigningDevice- Returns:
- an object to access all the certificates on the card.
- Throws:
PTEID_Exception
-
getCert
- Specified by:
getCertin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getRoot
- Specified by:
getRootin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getCA
- Specified by:
getCAin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getSignature
- Specified by:
getSignaturein interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getAuthentication
- Specified by:
getAuthenticationin interfacePTEID_SigningDevice- Throws:
PTEID_Exception
-
getDeviceType
- Specified by:
getDeviceTypein interfacePTEID_SigningDevice
-
readFile
public PTEID_ByteArray readFile(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
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
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(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
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(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
-