Hi,
I have to have the ability in Java to distribute a software token (SecureID token), which has already been assigned to a user, using the RSA Authentication Manager 8.1 API.
Here are two of my attempts to do so, without any success:
First attempt
LookupTokenCommand tokenCmd = new LookupTokenCommand();
tokenCmd.setSerialNumber(tokenSerialNumber);
tokenCmd.execute();
String tokenGuid = tokenCmd.getToken().getId();
String[] tokensGuids = new String[1];
tokensGuids[0] = tokenGuid;
AMTokenAttributeValueDTO[] attributes = new AMTokenAttributeValueDTO[2];
attributes[0] = new AMTokenAttributeValueDTO();
attributes[0].setTokenGUID(tokenGuid);
attributes[0].setId("DeviceSerialNumber");
attributes[0].setValue("blablabla");
attributes[1] = new AMTokenAttributeValueDTO();
attributes[1].setTokenGUID(tokenGuid);
attributes[1].setId("Nickname");
attributes[1].setValue("ran test");
DistributeSoftTokenRequest request = new DistributeSoftTokenRequest();
request.setSoftTokenProfileGuid(requiredProfile.getGuid());
request.setTokenGuids(tokensGuids);
request.setProtectedMethod(DistributeSoftTokenRequest.ST_PROTECTED_NONE);
request.setOutputMethod(DistributeSoftTokenRequest.ST_OUTPUT_ONE_PER_FILE);
request.setCopyProtected(true);
request.setRegenerateSeed(true);
request.setDeviceTypeGuid(requiredDeviceType.getGuid());
request.setDeviceType("Android");
request.setTokenAttrValueDTOs(attributes);
IssueSoftwareTokensCommand issueCmd = new IssueSoftwareTokensCommand(request);
issueCmd.execute(); // <- Here I get an error
Error message:
com.rsa.command.exception.InvalidArgumentException: Missing device type
Second attempt
LookupTokenCommand tokenCmd = new LookupTokenCommand();
tokenCmd.setSerialNumber(tokenSerialNumber);
tokenCmd.execute();
String tokenGuid = tokenCmd.getToken().getId();
String[] tokensGuids = new String[1];
tokensGuids[0] = tokenGuid;
IssueSoftwareTokensCommand issueCmd = new IssueSoftwareTokensCommand();
IssueSoftTokenRequest req = new IssueSoftTokenRequest();
req.setTokenGuids(tokensGuids);
req.setProtectedMethod(IssueSoftTokenRequestBase.ST_PROTECTED_NONE);
issueCmd.setRequest(req);
issueCmd.execute(); // <- Here I get an error
Error message:
com.rsa.command.exception.InvalidArgumentException: Missing device type
Thanks in advance for any help!
Ran
Hi Ran - one thing I notice is no call to DistributeSoftTokenRequest.setDeviceTypePluginModuleName().
Also your code snippet does not show how your variable requiredDeviceType was obtained.
Here is some EXAMPLE code that has worked in the past. Hopefully you can incorporate the necessary pieces into your code:
// Get token GUID
LookupTokenCommand LTC = new LookupTokenCommand();
LTC.setSerialNumber("000132251664");
LTC.execute();
TokenDTO token= LTC.getToken();
String GUID = token.getId();
//Get software token profile GUID
ListSoftTokenProfilesCommand LSPC = new ListSoftTokenProfilesCommand();
LSPC.execute();
ListSoftTokenProfilesDTO ProfilesList = LSPC.getSoftTokenProfilesDTO();
SoftTokenProfileDTO[] Profiles = ProfilesList.getSoftTokenProfiles();
String ProfileName="Desktop_PC_5";
String ProfileGUID="";
for (SoftTokenProfileDTO Profile : Profiles)
{
if (Profile.getName().equals(ProfileName))
{
ProfileGUID=Profile.getGuid();
break;
}
}
// Get Token Device Type
LookupSoftTokenDeviceTypeCommand devType = new LookupSoftTokenDeviceTypeCommand();
devType.setSoftTokenDeviceTypeGuid(token.getSoftTokenDeviceTypeId());
devType.execute();
SoftTokenDeviceTypeDTO dt = devType.getSoftTokenDeviceTypeDTO();
// Distribute token
DistributeSoftTokenRequest req = new DistributeSoftTokenRequest();
req.setSoftTokenProfileGuid(ProfileGUID);
req.setTokenGuids(new String[] {GUID});
req.setProtectedMethod(IssueSoftTokenRequestBase.ST_PROTECTED_NONE);
req.setDeviceTypeGuid(token.getSoftTokenDeviceTypeId());
req.setDeviceTypePluginModuleName(dt.getPluginModuleName());
IssueSoftwareTokensCommand issueCmd = new IssueSoftwareTokensCommand(req);
issueCmd.execute(session);