title: Distribute Software Tokens using RSA SecurID API/SDK for JAVA
body: <p>I'm developing a system to assign the next available software token for a user, issue and distribute it using RSA Authentication Manager 7.1 Developer's Guide and accordingly this JAVA API reference.</p>
  
  <p>The problem is that some points are unclear for me regarding sub types of software token generated and file format to export.</p>
  
  <p>Below is the source code that I have produced and my doubts rely on comments.</p>
  
  <pre><code>private void assignNextAvailableTokenToUser(String userGuid, String admGuid)
          throws CommandException, IOException {
          GetNextAvailableTokenCommand cmd = new GetNextAvailableTokenCommand();
  
          try {
              cmd.execute();  
          } catch (DataNotFoundException e) {
              System.out.println("ERROR: No tokens available");
              return;
          }
  
          String[] tokens = new String[] { cmd.getToken().getId() };
          // how can I guarantee that only software tokens will be assign to the user ???
          LinkTokensWithPrincipalCommand cmd2 = new LinkTokensWithPrincipalCommand(tokens, userGuid);
          cmd2.execute();
          System.out.println("Assigned next available SecurID token to user " + USER_NAME);
  
          IssueSoftwareTokensCommand issueCmd = new IssueSoftwareTokensCommand();
  
          DistributeSoftTokenRequest  disToken = new DistributeSoftTokenRequest();
  
          SoftTokenDeviceInfoDTO  softwareTokenDeviceDTO = new SoftTokenDeviceInfoDTO();
  
          softwareTokenDeviceDTO.setAlgorithm(SoftTokenDeviceInfoDTO.ST_FILE_FORMAT_SDTID3);
          softwareTokenDeviceDTO.setMaxTokensPerFile(SoftTokenDeviceInfoDTO.ST_MAX_PER_FILE_UNLIMITED);        
          softwareTokenDeviceDTO.setFileFormat(SoftTokenDeviceInfoDTO.ST_FILE_FORMAT_SDTID3);
          // how to link the information above with IssueSoftwareTokensCommand ??
  
          String[] tokensGuid = new String[]{cmd.getToken().getId()};
  
          disToken.setTokenGuids(tokensGuid);
          disToken.setProtectedMethod(DistributeSoftTokenRequest.ST_PROTECTED_BY_PASSWORD);
          disToken.setPassword("xpto");
          disToken.setCopyProtected(true);
          disToken.setDeviceType("?????????"); //how to fill this parameter for android or ios ??        
          disToken.setDeviceTypePluginModuleName("???????"); //how to fill this parameter for android or ios ?? 
          disToken.setOutputMethod(DistributeSoftTokenRequest.ST_OUTPUT_ONE_PER_FILE);
          disToken.setRegenerateSeed(true);        
          disToken.setPinAdded(true);
          disToken.setOtpAlgorithm(DistributeSoftTokenRequest.OTPAlgorithm.EVENT);
          disToken.setOtpInterval(DistributeSoftTokenRequest.OTPInterval.SIXTY_SECONDS);
          disToken.setOtpLength(DistributeSoftTokenRequest.OTPLength.SIX_DIGITS);
  
          issueCmd.setRequest(disToken);
  
          ConnectionFactory.executeCommand(admGuid, issueCmd);
  
          String fileName = issueCmd.getFileId();
  
          GetSoftwareTokenFileCommand getSoftwareTokenFileCommand = new GetSoftwareTokenFileCommand(fileName);
  
          getSoftwareTokenFileCommand.execute();
  
          byte[] fileContent = getSoftwareTokenFileCommand.getFileContent();
  
          FileOutputStream stream = new FileOutputStream("C:\\tokens\\" + fileName);
          try {
              stream.write(fileContent);
          } finally {
              stream.close();
          }
  
      }
  </code></pre>