The g method returns the version of the signature file.

Syntax

Android

public static 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:

  1. // Retrieve the signature file
  2. InputStream ins = assetManager.open(path);
  3.  
  4. // Get signature file version
  5. G response = P.g(convertInsToString(ins));
  6. int returnCode = response.r();
  7.  
  8. // Check if the version has been successfully retrieved
  9. if (returnCode == O.n)
  10. {
  11.   System.out.println("Signature File version " + response.v());
  12. }
  13. else
  14. {
  15.   System.out.println(getMsgFromReturnCode(returnCode));
  16.   System.out.println("Error code: " + returnCode);
  17. }

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 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);
}

iOS

original code example:

  1. //Load signature file
  2. NSString * filePath = [[NSBundlemainBundle] pathForResource:@"signature" ofType:nil];
  3.  
  4. //Get NSData from file
  5. NSData * d = [NSData dataWithContentsOfFile:filePath];
  6.  
  7. // Call the g method: check the signature file version
  8. G response = [P g:d];
  9.  
  10. NSString * resultText = @"";
  11.  
  12. //Parse result
  13. switch(response.r){
  14.  
  15. case P_n:
  16.   resultText = [NSStringstringWithFormat:@"** Version ** \r ** %s ** ", response.v];
  17.   ...

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 result
switch(response.r){
 
case P_n:
  resultText = [NSStringstringWithFormat:@"** Version ** \r ** %s ** ",
 response.v];
  ...