Package org.ejbca.ui.cli.hardtoken.importer

Examples of org.ejbca.ui.cli.hardtoken.importer.IHardTokenImporter


          }
          // 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);           
        }
    }
View Full Code Here

TOP

Related Classes of org.ejbca.ui.cli.hardtoken.importer.IHardTokenImporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.