}
// Create the importer
if(props.getProperty("importer.classpath") == null){
throw new IllegalAdminCommandException("Error, the property importer.classpath isn't set in the propertyfile " + args[1]);
}
IHardTokenImporter importer = (IHardTokenImporter) Thread.currentThread().getContextClassLoader().loadClass(props.getProperty("importer.classpath")).newInstance();
importer.startImport(props);
HardTokenData htd;
try{
while((htd = importer.readHardTokenData()) != null){
try{
ejb.getHardTokenSession().addHardToken(getAdmin(), htd.getTokenSN(), htd.getUsername(), significantIssuerDN, htd.getTokenType(), htd.getHardToken(), null, htd.getCopyOf());
getLogger().info("Token with SN " + htd.getTokenSN() + " were added to the database.");
}catch(HardTokenExistsException e){
if(force){
ejb.getHardTokenSession().removeHardToken(getAdmin(), htd.getTokenSN());
ejb.getHardTokenSession().addHardToken(getAdmin(), htd.getTokenSN(), htd.getUsername(), significantIssuerDN, htd.getTokenType(), htd.getHardToken(), null, htd.getCopyOf());
getLogger().info("Token with SN " + htd.getTokenSN() + " already existed in the database but was OVERWRITTEN.");
}else{
getLogger().error("Token with SN " + htd.getTokenSN() + " already exists in the database and is NOT imported.");
}
}
}
}finally{
importer.endImport();
}
} catch (Exception e) {
throw new ErrorAdminCommandException(e);
}
}