List of usage examples for java.lang Exception toString
public String toString()
From source file:at.ac.ait.ubicity.fileloader.FileLoader.java
/** * /*w w w.j av a 2 s . c o m*/ * This method is here for demo purposes only. It is not part of the required functionality for this class. * * * @param args arg 0 = file, arg #1 = keyspace, arg #2 = server host name, arg #3 = batch size, arg #4 = number of time units to wait, arg #5 = time unit ( minute, second, hour,.. ) * ( For now, tacitly assume we are on the default Cassandra 9160 port ). Clustering is not yet supported. */ public final static void main(String[] args) throws Exception { if (!(args.length == 6)) { usage(); System.exit(1); } try { final File _f = new File(args[0]); URI uri = _f.toURI(); String keySpaceName = args[1]; final String host = args[2]; final int batchSize = Integer.parseInt(args[3]); final int timeUnitCount = Integer.parseInt(args[4]); Delay timeUnit = timeUnitsFromCmdLine(args[5].toUpperCase()); if (timeUnit == null) timeUnit = Delay.SECOND; long millisToWait = timeUnitCount * timeUnit.getMilliSeconds(); useCache = true; while (true) { try { invigilate(uri, keySpaceName, host, batchSize, millisToWait); Thread.sleep(millisToWait); } catch (InterruptedException | Error any) { Thread.interrupted(); } finally { } } } catch (Exception e) { logger.log(Level.SEVERE, e.toString()); } }
From source file:org.apache.uima.examples.as.GetMetaRequest.java
/** * retrieve meta information for a UIMA-AS Service attached to a broker * It uses the port 1099 as the JMX port on the broker, unless overridden * by defining the system property activemq.broker.jmx.port with a value of another port number * It uses the default JMX ActiveMQ Domain "org.apache.activemq", unless overridden * by defining the system property activemq.broker.jmx.domain with a value of the domain to use * This normally never needs to be done unless multiple brokers are run on the same node * as is sometimes done for unit tests. * @param args - brokerUri serviceName [-verbose] *///from ww w . j a v a 2 s .co m public static void main(String[] args) { if (args.length < 2) { System.err.println("Need arguments: brokerURI serviceName [-verbose]"); System.exit(1); } String brokerURI = args[0]; String queueName = args[1]; boolean printReply = false; if (args.length > 2) { if (args[2].equalsIgnoreCase("-verbose")) { printReply = true; } else { System.err.println("Unknown argument: " + args[2]); System.exit(1); } } final Connection connection; Session producerSession = null; Queue producerQueue = null; MessageProducer producer; MessageConsumer consumer; Session consumerSession = null; TemporaryQueue consumerDestination = null; long startTime = 0; // Check if JMX server port number was specified jmxPort = System.getProperty("activemq.broker.jmx.port"); if (jmxPort == null || jmxPort.trim().length() == 0) { jmxPort = "1099"; // default } try { // First create connection to a broker ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerURI); connection = factory.createConnection(); connection.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { try { if (connection != null) { connection.close(); } if (jmxc != null) { jmxc.close(); } } catch (Exception ex) { } } })); URI target = new URI(brokerURI); String brokerHost = target.getHost(); attachToRemoteBrokerJMXServer(brokerURI); if (isQueueAvailable(queueName) == QueueState.exists) { System.out.println("Queue " + queueName + " found on " + brokerURI); System.out.println("Sending getMeta..."); } else if (isQueueAvailable(queueName) == QueueState.existsnot) { System.err.println("Queue " + queueName + " does not exist on " + brokerURI); System.exit(1); } else { System.out.println("Cannot see queues on JMX port " + brokerHost + ":" + jmxPort); System.out.println("Sending getMeta anyway..."); } producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); producerQueue = producerSession.createQueue(queueName); producer = producerSession.createProducer(producerQueue); consumerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); consumerDestination = consumerSession.createTemporaryQueue(); // ----------------------------------------------------------------------------- // Create message consumer. The consumer uses a selector to filter out messages other // then GetMeta replies. Currently UIMA AS service returns two messages for each request: // ServiceInfo message and GetMeta message. The ServiceInfo message is returned by the // service immediately upon receiving a message from a client. This serves dual purpose, // 1) to make sure the client reply destination exists // 2) informs the client which service is processing its request // ----------------------------------------------------------------------------- consumer = consumerSession.createConsumer(consumerDestination, "Command=2001"); TextMessage msg = producerSession.createTextMessage(); msg.setStringProperty(AsynchAEMessage.MessageFrom, consumerDestination.getQueueName()); msg.setStringProperty(UIMAMessage.ServerURI, brokerURI); msg.setIntProperty(AsynchAEMessage.MessageType, AsynchAEMessage.Request); msg.setIntProperty(AsynchAEMessage.Command, AsynchAEMessage.GetMeta); msg.setJMSReplyTo(consumerDestination); msg.setText(""); producer.send(msg); startTime = System.nanoTime(); System.out.println("Sent getMeta request to " + queueName + " at " + brokerURI); System.out.println("Waiting for getMeta reply..."); ActiveMQTextMessage reply = (ActiveMQTextMessage) consumer.receive(); long waitTime = (System.nanoTime() - startTime) / 1000000; System.out.println( "Reply from " + reply.getStringProperty("ServerIP") + " received in " + waitTime + " ms"); if (printReply) { System.out.println("Reply MessageText: " + reply.getText()); } } catch (Exception e) { System.err.println(e.toString()); } System.exit(0); }
From source file:edu.internet2.middleware.changelogconsumer.googleapps.GoogleAppsFullSync.java
public static void main(String[] args) { if (args.length == 0) { System.console().printf("Google Change Log Consumer Name must be provided\n"); System.console().printf("*nix: googleAppsFullSync.sh consumerName [--dry-run]\n"); System.console().printf("Windows: googleAppsFullSync.bat consumerName [--dry-run]\n"); System.exit(-1);/*from w w w . j a v a 2 s .co m*/ } try { GoogleAppsFullSync googleAppsFullSync = new GoogleAppsFullSync(args[0]); googleAppsFullSync.process(args.length > 1 && args[1].equalsIgnoreCase("--dry-run")); } catch (Exception e) { System.console().printf(e.toString() + ": \n"); e.printStackTrace(); } System.exit(0); }
From source file:com.continuent.tungsten.common.security.KeystoreManagerCtrl.java
/** * Password Manager entry point/*from www.j a v a2 s. c o m*/ * * @param argv * @throws Exception */ public static void main(String argv[]) throws Exception { keystoreManager = new KeystoreManagerCtrl(); // --- Options --- CommandLine line = null; try { CommandLineParser parser = new GnuParser(); // --- Parse the command line arguments --- // --- Help line = parser.parse(keystoreManager.helpOptions, argv, true); if (line.hasOption(_HELP)) { DisplayHelpAndExit(EXIT_CODE.EXIT_OK); } // --- Program command line options line = parser.parse(keystoreManager.options, argv); // --- Compulsory arguments : Get options --- if (line.hasOption(_KEYSTORE_LOCATION)) keystoreManager.keystoreLocation = line.getOptionValue(_KEYSTORE_LOCATION); if (line.hasOption(_KEY_ALIAS)) keystoreManager.keyAlias = line.getOptionValue(_KEY_ALIAS); if (line.hasOption(_KEY_TYPE)) { String keyType = line.getOptionValue(_KEY_TYPE); // This will throw an exception if the type is not recognised KEYSTORE_TYPE certificateTYpe = KEYSTORE_TYPE.fromString(keyType); keystoreManager.keyType = certificateTYpe; } if (line.hasOption(_KEYSTORE_PASSWORD)) keystoreManager.keystorePassword = line.getOptionValue(_KEYSTORE_PASSWORD); if (line.hasOption(_KEY_PASSWORD)) keystoreManager.keyPassword = line.getOptionValue(_KEY_PASSWORD); } catch (ParseException exp) { logger.error(exp.getMessage()); DisplayHelpAndExit(EXIT_CODE.EXIT_ERROR); } catch (Exception e) { // Workaround for Junit test if (e.toString().contains("CheckExitCalled")) { throw e; } else // Normal behaviour { logger.error(e.getMessage()); Exit(EXIT_CODE.EXIT_ERROR); } } // --- Perform commands --- // ######### Check password ########## if (line.hasOption(_CHECK)) { try { if (keystoreManager.keystorePassword == null || keystoreManager.keyPassword == null) { // --- Get passwords from stdin if not given on command line List<String> listPrompts = Arrays.asList("Keystore password:", MessageFormat.format("Password for key {0}:", keystoreManager.keyAlias)); List<String> listUserInput = keystoreManager.getUserInputFromStdin(listPrompts); if (listUserInput.size() == listPrompts.size()) { keystoreManager.keystorePassword = listUserInput.get(0); keystoreManager.keyPassword = listUserInput.get(1); } else { throw new NoSuchElementException(); } } try { // --- Check that all keys in keystore use the keystore // password logger.info(MessageFormat.format("Using keystore:{0}", keystoreManager.keystoreLocation)); SecurityHelper.checkKeyStorePasswords(keystoreManager.keystoreLocation, keystoreManager.keyType, keystoreManager.keystorePassword, keystoreManager.keyAlias, keystoreManager.keyPassword); logger.info(MessageFormat.format("OK : Identical password for Keystore and key={0}", keystoreManager.keyAlias)); } catch (UnrecoverableKeyException uke) { logger.error(MessageFormat.format("At least 1 key has a wrong password.{0}", uke.getMessage())); Exit(EXIT_CODE.EXIT_ERROR); } catch (Exception e) { logger.error(MessageFormat.format("{0}", e.getMessage())); Exit(EXIT_CODE.EXIT_ERROR); } } catch (NoSuchElementException nse) { logger.error(nse.getMessage()); Exit(EXIT_CODE.EXIT_ERROR); } catch (Exception e) { logger.error(MessageFormat.format("Error while running the program: {0}", e.getMessage())); Exit(EXIT_CODE.EXIT_ERROR); } } Exit(EXIT_CODE.EXIT_OK); }
From source file:ch.admin.hermes.etl.load.HermesETLApplication.java
/** * Hauptprogramm/*from www . j av a 2 s . c o m*/ * @param args Commandline Argumente */ public static void main(String[] args) { JFrame frame = null; try { // Crawler fuer Zugriff auf HERMES 5 Online Loesung initialiseren */ crawler = new HermesOnlineCrawler(); // CommandLine Argumente aufbereiten parseCommandLine(args); // Methoden Export (Variante Zuehlke) extrahieren System.out.println("load library " + model); ModelExtract root = new ModelExtract(); root.extract(model); frame = createProgressDialog(); // wird das XML Model von HERMES Online geholt - URL der Templates korrigieren if (scenario != null) { List<Workproduct> workproducts = (List<Workproduct>) root.getObjects().get("workproducts"); for (Workproduct wp : workproducts) for (Template t : wp.getTemplate()) { // Template beinhaltet kompletten URL - keine Aenderung if (t.getUrl().toLowerCase().startsWith("http") || t.getUrl().toLowerCase().startsWith("file")) continue; // Model wird ab Website geholte if (model.startsWith("http")) t.setUrl(crawler.getTemplateURL(scenario, t.getUrl())); // Model ist lokal - Path aus model und relativem Path Template zusammenstellen else { File m = new File(model); t.setUrl(m.getParentFile() + "/" + t.getUrl()); } } } // JavaScript - fuer Import in Fremdsystem if (script.endsWith(".js")) { final JavaScriptEngine js = new JavaScriptEngine(); js.setObjects(root.getObjects()); js.put("progress", progress); js.eval("function log( x ) { println( x ); progress.setString( x ); }"); progress.setString("call main() in " + script); js.put(ScriptEngine.FILENAME, script); js.call(new InputStreamReader(new FileInputStream(script)), "main", new Object[] { site, user, passwd }); } // FreeMarker - fuer Umwandlungen nach HTML else if (script.endsWith(".ftl")) { FileOutputStream out = new FileOutputStream( new File(script.substring(0, script.length() - 3) + "html ")); int i = script.indexOf("templates"); if (i >= 0) script = script.substring(i + "templates".length()); MethodTransform transform = new MethodTransform(); transform.transform(root.getObjects(), script, out); out.close(); } } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString(), "Fehlerhafte Verarbeitung", JOptionPane.WARNING_MESSAGE); e.printStackTrace(); } if (frame != null) { frame.setVisible(false); frame.dispose(); } System.exit(0); }
From source file:neembuu.uploader.cmd.Main.java
/** * @param args the command line arguments *///from ww w . j a va2 s . co m public static void main(String args[]) throws Exception { Application.init(); NULogger.initializeFileHandler(Application.getNeembuuHome().resolve("nu.log").normalize().toString()); Settings settings = Application.get(Settings.class); logging(settings); translation(); try { nuInstanceAndRelated(); updatesAndExternalPluginManager(); //checkBoxes(); unessential firstLaunchAndAccountCheck(); //checkTamil(); //Finally start the update checking thread. } catch (Exception ex) { ex.printStackTrace(); NULogger.getLogger().severe(ex.toString()); } work(args); }
From source file:ffdammit.SkyProcMain.java
public static void main(String[] args) { try {//from ww w .j av a 2 s . co m SPGlobal.createGlobalLog(); SUMGUI.open(new SkyProcMain(), args); } catch (Exception e) { // If a major error happens, print it everywhere and display a message box. System.err.println(e.toString()); SPGlobal.logException(e); JOptionPane.showMessageDialog(null, "There was an exception thrown during program execution: '" + e + "' Check the debug logs or contact the author."); SPGlobal.closeDebug(); } }
From source file:de.dfki.dmas.owls2wsdl.core.OWLS2WSDL.java
public static void main(String[] args) { // http://jakarta.apache.org/commons/cli/usage.html System.out.println("ARG COUNT: " + args.length); OWLS2WSDLSettings.getInstance();/* w w w .ja va2 s. co m*/ Options options = new Options(); Option help = new Option("help", "print help message"); options.addOption(help); // create the parser CommandLineParser parser = new GnuParser(); CommandLine cmdLine = null; for (int i = 0; i < args.length; i++) { System.out.println("ARG: " + args[i].toString()); } if (args.length > 0) { if (args[args.length - 1].toString().endsWith(".owl")) { // -kbdir d:\tmp\KB http://127.0.0.1/ontology/ActorDefault.owl Option test = new Option("test", "parse only, don't save"); @SuppressWarnings("static-access") Option kbdir = OptionBuilder.withArgName("dir").hasArg() .withDescription("knowledgebase directory; necessary").create("kbdir"); options.addOption(test); options.addOption(kbdir); try { cmdLine = parser.parse(options, args); if (cmdLine.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl [options] FILE.owl", options); System.exit(0); } } catch (ParseException exp) { // oops, something went wrong System.out.println("Error: Parsing failed, reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl", options, true); } if (args.length == 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl [options] FILE.owl", options); System.out.println("Error: Option -kbdir is missing."); System.exit(0); } else { String ontURI = args[args.length - 1].toString(); String persistentName = "KB_" + ontURI.substring(ontURI.lastIndexOf("/") + 1, ontURI.lastIndexOf(".")) + "-MAP.xml"; try { if (cmdLine.hasOption("kbdir")) { String kbdirValue = cmdLine.getOptionValue("kbdir"); if (new File(kbdirValue).isDirectory()) { DatatypeParser p = new DatatypeParser(); p.parse(args[args.length - 1].toString()); p.getAbstractDatatypeKBData(); if (!cmdLine.hasOption("test")) { System.out.println("AUSGABE: " + kbdirValue + File.separator + persistentName); FileOutputStream ausgabeStream = new FileOutputStream( kbdirValue + File.separator + persistentName); AbstractDatatypeKB.getInstance().marshallAsXML(ausgabeStream, true); // System.out); } } } } catch (java.net.MalformedURLException murle) { System.err.println("MalformedURLException: " + murle.getMessage()); System.err.println("Try something like: http://127.0.0.1/ontology/my_ontology.owl"); } catch (Exception e) { System.err.println("Exception: " + e.toString()); } } } else if (args[args.length - 1].toString().endsWith(".xml")) { // -owlclass http://127.0.0.1/ontology/Student.owl#HTWStudent // -xsd -d 1 -h D:\tmp\KB\KB_Student-MAP.xml Option xsd = new Option("xsd", "generate XML Schema"); Option info = new Option("info", "print datatype information"); @SuppressWarnings("static-access") Option owlclass = OptionBuilder.withArgName("class").hasArg() .withDescription("owl class to translate; necessary").create("owlclass"); Option keys = new Option("keys", "list all owlclass keys"); options.addOption(keys); options.addOption(owlclass); options.addOption(info); options.addOption(xsd); options.addOption("h", "hierarchy", false, "use hierarchy pattern"); options.addOption("d", "depth", true, "set recursion depth"); options.addOption("b", "behavior", true, "set inheritance bevavior"); options.addOption("p", "primitive", true, "set default primitive type"); try { cmdLine = parser.parse(options, args); if (cmdLine.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl [options] FILE.xml", options); System.exit(0); } } catch (ParseException exp) { // oops, something went wrong System.out.println("Error: Parsing failed, reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl", options, true); } if (args.length == 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl [options] FILE.xml", options); System.exit(0); } else if (cmdLine.hasOption("keys")) { File f = new File(args[args.length - 1].toString()); try { AbstractDatatypeMapper.getInstance().loadAbstractDatatypeKB(f); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); System.exit(1); } AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().printRegisteredDatatypes(); System.exit(0); } else if (!cmdLine.hasOption("owlclass")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("owls2wsdl [options] FILE.xml", "", options, "Info: owl class not set.\n e.g. -owlclass http://127.0.0.1/ontology/Student.owl#Student"); System.exit(0); } else { File f = new File(args[args.length - 1].toString()); try { AbstractDatatypeMapper.getInstance().loadAbstractDatatypeKB(f); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); System.exit(1); } String owlclassString = cmdLine.getOptionValue("owlclass"); if (!AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().containsKey(owlclassString)) { System.err.println("Error: Key " + owlclassString + " not in knowledgebase."); System.exit(1); } if (cmdLine.hasOption("info")) { AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().get(owlclassString) .printDatatype(); } if (cmdLine.hasOption("xsd")) { boolean hierachy = false; int depth = 0; String inheritanceBehavior = AbstractDatatype.InheritanceByNone; String defaultPrimitiveType = "http://www.w3.org/2001/XMLSchema#string"; if (cmdLine.hasOption("h")) { hierachy = true; } if (cmdLine.hasOption("d")) { depth = Integer.parseInt(cmdLine.getOptionValue("d")); } if (cmdLine.hasOption("b")) { System.out.print("Set inheritance behaviour to: "); if (cmdLine.getOptionValue("b") .equals(AbstractDatatype.InheritanceByParentsFirstRDFTypeSecond)) { System.out.println(AbstractDatatype.InheritanceByParentsFirstRDFTypeSecond); inheritanceBehavior = AbstractDatatype.InheritanceByNone; } else if (cmdLine.getOptionValue("b") .equals(AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond)) { System.out.println(AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond); inheritanceBehavior = AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond; } else if (cmdLine.getOptionValue("b") .equals(AbstractDatatype.InheritanceByRDFTypeOnly)) { System.out.println(AbstractDatatype.InheritanceByRDFTypeOnly); inheritanceBehavior = AbstractDatatype.InheritanceByRDFTypeOnly; } else if (cmdLine.getOptionValue("b") .equals(AbstractDatatype.InheritanceBySuperClassOnly)) { System.out.println(AbstractDatatype.InheritanceBySuperClassOnly); inheritanceBehavior = AbstractDatatype.InheritanceBySuperClassOnly; } else { System.out.println(AbstractDatatype.InheritanceByNone); inheritanceBehavior = AbstractDatatype.InheritanceByNone; } } if (cmdLine.hasOption("p")) { defaultPrimitiveType = cmdLine.getOptionValue("p"); if (defaultPrimitiveType.split("#")[0].equals("http://www.w3.org/2001/XMLSchema")) { System.err.println("Error: Primitive Type not valid: " + defaultPrimitiveType); System.exit(1); } } XsdSchemaGenerator xsdgen = new XsdSchemaGenerator("SCHEMATYPE", hierachy, depth, inheritanceBehavior, defaultPrimitiveType); try { AbstractDatatypeKB.getInstance().toXSD(owlclassString, xsdgen, System.out); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } } } } else { try { cmdLine = parser.parse(options, args); if (cmdLine.hasOption("help")) { printDefaultHelpMessage(); } } catch (ParseException exp) { // oops, something went wrong System.out.println("Error: Parsing failed, reason: " + exp.getMessage()); printDefaultHelpMessage(); } } } else { OWLS2WSDLGui.createAndShowGUI(); } // for(Iterator it=options.getOptions().iterator(); it.hasNext(); ) { // String optString = ((Option)it.next()).getOpt(); // if(cmdLine.hasOption(optString)) { // System.out.println("Option set: "+optString); // } // } }
From source file:com.cloud.consoleproxy.ConsoleProxy.java
public static void main(String[] argv) { standaloneStart = true;// w ww.j a v a 2 s. c o m configLog4j(); Logger.setFactory(new ConsoleProxyLoggerFactory()); InputStream confs = ConsoleProxy.class.getResourceAsStream("/conf/consoleproxy.properties"); Properties conf = new Properties(); if (confs == null) { s_logger.info("Can't load consoleproxy.properties from classpath, will use default configuration"); } else { try { conf.load(confs); } catch (Exception e) { s_logger.error(e.toString(), e); } } start(conf); }
From source file:com.microsoft.windowsazure.services.media.samples.contentprotection.playreadywidevine.Program.java
public static void main(String[] args) { try {// w w w . j a v a2 s .c o m // Set up the MediaContract object to call into the Media Services account Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(mediaServiceUri, oAuthUri, clientId, clientSecret, scope); mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - PlayReady & Widevine Dynamic Encryption Sample"); // Upload a local file to a media asset. AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv"); System.out.println("Uploaded Asset Id: " + uploadAsset.getId()); // Transform the asset. AssetInfo encodedAsset = encode(uploadAsset); System.out.println("Encoded Asset Id: " + encodedAsset.getId()); // Create the ContentKey ContentKeyInfo contentKeyInfo = createCommonTypeContentKey(encodedAsset); System.out.println("Common Encryption Content Key: " + contentKeyInfo.getId()); // Create the ContentKeyAuthorizationPolicy String tokenTemplateString = null; if (tokenRestriction) { tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType); } else { addOpenAuthorizationPolicy(contentKeyInfo); } // Create the AssetDeliveryPolicy createAssetDeliveryPolicy(encodedAsset, contentKeyInfo); if (tokenTemplateString != null) { // Deserializes a string containing the XML representation of the TokenRestrictionTemplate TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer .deserialize(tokenTemplateString); // Generate a test token based on the the data in the given // TokenRestrictionTemplate. // Note: You need to pass the key id Guid because we specified // TokenClaim.ContentKeyIdentifierClaim in during the creation // of TokenRestrictionTemplate. UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length())); // Token expiration: 1-year Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.YEAR, 1); // Generate token String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey, date.getTime(), null); System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken); } // Create the Streaming Origin Locator String url = getStreamingOriginLocator(encodedAsset); System.out.println("Origin Locator Url: " + url); System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } }