- 23 Oct 2024
- 2 Minutes à lire
- SombreLumière
Obtain the signature file with the "g" method
- Mis à jour le 23 Oct 2024
- 2 Minutes à lire
- SombreLumière
The g method returns the version of the signature file.
Syntax
Android
publicstatic G g(String c)
iOS
+(g*) g: (NSData*) c
Parameters
Obtain the signature file version parameters lists the parameters for this function:
Obtain the signature file version parameters | |||
Parameter name | Data type | Use | Description |
---|---|---|---|
c | String/NSData* | I (mandatory) | Signature file content. |
Return values
This method returns the G response object, which contains the following:
A return code that indicates the result of the analysis.
The version of the signature file in case of success.
An exception if an unknown error occurs.
Exceptions
Obtain the signature file version exceptions lists the possible error codes for this function.
Obtain the signature file version exceptions | ||
Name | Value | Error message |
---|---|---|
n | 0 | Indicates that the version has been successfully retrieved. |
z | –4600 | Indicates an unknown error. |
e | –4602 | Indicates that the signature file is null. |
l | –4603 | Indicates that the signature file length is incorrect—it must be at least 256 characters. |
f | –4604 | Indicates that the signature file format is incorrect—only hexadecimal characters are allowed. |
i | –4605 | Indicates that the signature file is invalid: wrong signature or XML parsing error. |
Examples
This section illustrates how to integrate and use the g method to retrieve the signature file version. For more information, refer to the Root Detection SDK sample project in the OneSpan Mobile Security Suite package.
Once deployed, the application will be installed under the name OneSpan Root Detection SDK Sample.
Android
original code example: this works in PDF but doesn't include the copy code feature on the CP:
// Retrieve the signature file
InputStream ins = assetManager.open(path);
// Get signature file version
G response = P.g(convertInsToString(ins));
int returnCode = response.r();
// Check if the version has been successfully retrieved
if (returnCode == O.n)
{
System.out.println("Signature File version " + response.v());
}
else
{
System.out.println(getMsgFromReturnCode(returnCode));
System.out.println("Error code: " + returnCode);
}
MadCap Flare code snippet:
// Retrieve the signature file
InputStream ins = assetManager.open(path);
// Get signature file version
G response = P.g(convertInsToString(ins));
int returnCode = response.r();
// Check if the version has been successfully retrieve
if (returnCode == O.n){
System.out.println("Signature File version " + response.v());
}
else
{
System.out.println(getMsgFromReturnCode(returnCode));
System.out.println("Error code: " + returnCode);
}
Formatted with "pre" tag - this works in CP but not in PDF:
// Retrieve the signature file
InputStream ins = assetManager.open(path);
// Get signature file version
G response = P.g(convertInsToString(ins));
int returnCode = response.r();
// Check if the version has been successfully retrieveif (returnCode == O.n){
System.out.println("Signature File version " + response.v());
}
else
{
System.out.println(getMsgFromReturnCode(returnCode));
System.out.println("Error code: " + returnCode);
}
iOS
original code example:
//Load signature file
NSString * filePath = [[NSBundlemainBundle] pathForResource:@"signature" ofType:nil];
//Get NSData from file
NSData * d = [NSData dataWithContentsOfFile:filePath];
// Call the g method: check the signature file version
G response = [P g:d];
NSString * resultText = @"";
//Parse result
switch(response.r){
case P_n:
resultText = [NSStringstringWithFormat:@"** Version ** \r ** %s ** ", response.v];
...
formatted with <pre>:
//Load signature file
NSString * filePath = [[NSBundlemainBundle]
pathForResource:@"signature" ofType:nil];
//Get NSData from file
NSData * d = [NSData dataWithContentsOfFile:filePath];
// Call the g method: check the signature file version
G response = [P g:d];
NSString * resultText = @"";
//Parse resultswitch(response.r){
case P_n:
resultText = [NSStringstringWithFormat:@"** Version ** \r ** %s ** ",
response.v];
...