AnsweredAssumed Answered

Failed to import token file record into RSA SecureID Software Token for Android due to an "invalid token record"

Question asked by Ran Yohai on Feb 28, 2018

********** Last edited on 01/03/18 **********

 

Hi!

 

I need some help with creating a valid token file record (of SDTID format).

Currently I manage to create one, but on both, Android RSA app and Token Converter 3.1.0, I failed to load it because it is an "invalid token record".

 

The error in Token Converter 3.1.0 starts with:

[Fatal Error] :1:1: Content is not allowed in prolog.

 

Here is an example of my code:

 

// Get token
PrincipalDTO principal = lookupUser(userId);
ListTokenDTO[] tokensArray = getUserTokens(principal);
String tokenSerialNumber = tokensArray[0].getSerialNumber();
LookupTokenCommand LTC = new LookupTokenCommand();
LTC.setSerialNumber(tokenSerialNumber);
LTC.execute();
TokenDTO token = LTC.getToken();

// Set software token profile attributes values
LookupSoftTokenProfileCommand profile = new LookupSoftTokenProfileCommand();
profile.setSoftTokenProfileGuid(token.getSoftTokenProfileId());
profile.execute();
SoftTokenProfileDTO profileObj = profile.getSoftTokenProfileDTO();
AMTokenAttributeValueDTO[] profileAttributes = getTokenAttributeValues(...);

if (profileAttributes.length > 0) {
    token.setSoftTokenProfileAttrValueDTOs(profileAttributes);
}

// Set software token device type attributes values
String deviceTypeId = token.getSoftTokenDeviceTypeId();
LookupSoftTokenDeviceTypeCommand devType = new LookupSoftTokenDeviceTypeCommand();
devType.setSoftTokenDeviceTypeGuid(deviceTypeId);
devType.setLookupType(LookupSoftTokenDeviceTypeCommand.BY_SELF_GUID);
devType.execute();
SoftTokenDeviceTypeDTO deviceTypeObj = devType.getSoftTokenDeviceTypeDTO();
AMTokenAttributeValueDTO[] deviceTypeAttributes = getTokenAttributeValues(...);

if (deviceTypeAttributes.length > 0) {
    token.setSoftTokenDeviceTypeAttrValueDTOs(deviceTypeAttributes);
}

// Update new token attributes values on server
UpdateTokenCommand update = new UpdateTokenCommand();
update.setToken(token);
update.execute();

// Distribute token
DistributeSoftTokenRequest req = new DistributeSoftTokenRequest();
req.setSoftTokenProfileGuid(profileObj.getGuid());
req.setTokenGuids(new String[] { token.getId() });
req.setProtectedMethod(IssueSoftTokenRequestBase.ST_PROTECTED_NONE);
req.setOutputMethod(IssueSoftTokenRequestBase.ST_OUTPUT_ONE_PER_FILE);
req.setDeviceTypeGuid(token.getSoftTokenDeviceTypeId());
req.setDeviceTypePluginModuleName(deviceTypeObj.getPluginModuleName());
IssueSoftwareTokensCommand issueCmd = new IssueSoftwareTokensCommand(req);
issueCmd.execute(session);

// Get SDTID file content
String fileId = issueCmd.getFileId();
GetSoftwareTokenFileCommand getSoftwareTokenFileCommand = new GetSoftwareTokenFileCommand(fileId);
getSoftwareTokenFileCommand.execute();
byte[] fileContent = getSoftwareTokenFileCommand.getFileContent();

// Forward file
if (isSaveOnDisk) {
    String folderPath = subOptions.getFolderPathToSaveIn();
    String fileName = userId + "." + getSoftwareTokenFileCommand.getFileId() + SDTID_FILE_EXTENSION;
    String filePath = combine(folderPath, fileName);
    saveFile(filePath, fileContent);

} else if (isSendByEmail) {
    sendEmail(subOptions.getEmailToSendTo(), fileContent);
}

 

************* Update - 01/03/18 *************

 

I found out that when distributing a token using the web interface, the SDTID output file is in XML format (textual file).

BUT, using the my code section above, distributing a token creates a binary output file.

I'm almost sure that here is my problem, but STILL I don't have any idea how to get it textual and in XML format.

I need your help, please.

 

************************************************

 

 

Thanks in advance for any help!

 

BR,

Ran

Outcomes