List of usage examples for java.net URI URI
public URI(String str) throws URISyntaxException
From source file:edu.stanford.junction.extra.Capsizer.java
public static void main(String[] args) { try {/*from ww w . j ava 2s . c om*/ SwitchboardConfig switchboardConfig = new XMPPSwitchboardConfig("prpl.stanford.edu"); JunctionMaker maker = JunctionMaker.getInstance(switchboardConfig); URI uri = new URI("junction://prpl.stanford.edu/capsizer"); maker.newJunction(uri, mActor); synchronized (mActor) { mActor.wait(); } System.out.println("Exiting."); } catch (Exception e) { e.printStackTrace(); } }
From source file:jdbc.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); java.net.CookieManager cm = new java.net.CookieManager(); java.net.CookieHandler.setDefault(cm); try {/* w ww. j a v a 2s.c o m*/ HttpGet httpget = new HttpGet("http://www.cophieu68.vn/export/excel.php?id=AAA"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post() .setUri(new URI("http://www.cophieu68.vn/export/excel.php?id=AAA")) .addParameter("username", "hello_nguyenson@live.com").addParameter("tpassword", "19931994") .build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:com.cloudera.RenameTest.java
public static void main(String[] args) throws Exception { System.out.println("running RenameTest: tests rename " + "behaviors in Hadoop...\n"); if (args.length < 1) { System.err.println("You must specify a single argument: the URI " + "of a directory to test.\n" + "Examples: file:///tmp, hdfs:///\n"); System.exit(1);// w w w .j a va2s. co m } String uri = args[0]; testFileSystemRename(new URI(uri)); }
From source file:com.thed.zapi.cloud.sample.sampleJwtGenerator.java
/** * @param args// w ww . j a v a2 s. c om * @author Created by swapna.vemula on 12-Dec-2016. * @throws URISyntaxException * @throws JobProgressException * @throws JSONException * @throws IOException * @throws IllegalStateException */ public static void main(String[] args) throws URISyntaxException, IllegalStateException, IOException { // Replace Zephyr BaseUrl with the <ZAPI_CLOUD_URL> shared with ZAPI Cloud Installation String zephyrBaseUrl = "<ZAPI_CLOUD_URL>"; // zephyr accessKey , we can get from Addons >> zapi section String accessKey = "YjE2MjdjMGEtNzExNy0zYjY1LWFkMzQtNjcwMDM3IGFkbWluIGFkbWlu"; // zephyr secretKey , we can get from Addons >> zapi section String secretKey = "qufnbimi96Ob2hq3ISF08yZ8nUvDRHmQwHGeGlk"; // Jira UserName String userName = "admin"; ZFJCloudRestClient client = ZFJCloudRestClient.restBuilder(zephyrBaseUrl, accessKey, secretKey, userName) .build(); JwtGenerator jwtGenerator = client.getJwtGenerator(); // API to which the JWT token has to be generated String createCycleUri = zephyrBaseUrl + "/public/rest/api/1.0/cycle?expand=&clonedCycleId="; URI uri = new URI(createCycleUri); int expirationInSec = 360; String jwt = jwtGenerator.generateJWT("GET", uri, expirationInSec); // Print the URL and JWT token to be used for making the REST call System.out.println("FINAL API : " + uri.toString()); System.out.println("JWT Token : " + jwt); }
From source file:DesktopDemo.java
public static void main(String[] args) { if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); } else {/*from w ww.j a v a 2s. c o m*/ System.out.println("Desktop class is not supported"); System.exit(1); } JMenuItem openItem = new JMenuItem("Open"); JMenuItem editItem = new JMenuItem("Edit"); JMenuItem printItem = new JMenuItem("Print"); JMenuItem browseToItem = new JMenuItem("Go to www.java2s.com"); JMenuItem mailToItem = new JMenuItem("Email to a@java.com"); JMenu fileMenu = new JMenu("File"); JMenu mailMenu = new JMenu("Email"); JMenu browseMenu = new JMenu("Browser"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { desktop.open(chooser.getSelectedFile().getAbsoluteFile()); } catch (Exception ex) { ex.printStackTrace(); } } } }); fileMenu.add(openItem); editItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { desktop.edit(chooser.getSelectedFile().getAbsoluteFile()); } catch (Exception ex) { ex.printStackTrace(); } } } }); fileMenu.add(editItem); printItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { desktop.print(chooser.getSelectedFile().getAbsoluteFile()); } catch (Exception ex) { ex.printStackTrace(); } } } }); fileMenu.add(printItem); browseToItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { URI browseURI = new URI("www.java2s.com"); desktop.browse(browseURI); } catch (Exception ex) { System.out.println(ex.getMessage()); } } }); browseMenu.add(browseToItem); mailToItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { URI mailURI = new URI("mailto:support@java.com"); desktop.mail(mailURI); } catch (Exception ex) { System.out.println(ex.getMessage()); } } }); mailMenu.add(mailToItem); JMenuBar jMenuBar = new JMenuBar(); jMenuBar.add(fileMenu); jMenuBar.add(browseMenu); jMenuBar.add(mailMenu); JFrame frame = new JFrame(); frame.setTitle("Desktop Helper Applications"); frame.setSize(300, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(jMenuBar); frame.setVisible(true); }
From source file:it.polito.tellmefirst.web.rest.TMFServer.java
/** * TMF starting point. From rest directory, launch this command: * mvn exec:java -Dexec.mainClass="it.polito.temefirst.web.rest.TMFServer" -Dexec.args="<path_to_TMF_installation>/conf/server.properties" * or use the run.sh file in bin directory *//*from www . j ava2 s . co m*/ public static void main(String[] args) throws TMFConfigurationException, TMFIndexesWarmUpException, URISyntaxException, InterruptedException, IOException { LOG.debug("[main] - BEGIN"); URI serverURI = new URI("http://localhost:2222/rest/"); String configFileName = args[0]; new TMFVariables(configFileName); // XXX I put the code of IndexUtil.init() here, because, for now, I need a reference of SimpleSearchers for the Enhancer // build italian searcher Directory contextIndexDirIT = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_IT)); LOG.info("Corpus index used for italian: " + contextIndexDirIT); LuceneManager contextLuceneManagerIT = new LuceneManager(contextIndexDirIT); contextLuceneManagerIT .setLuceneDefaultAnalyzer(new ItalianAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_IT)); ITALIAN_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerIT); // build english searcher Directory contextIndexDirEN = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_EN)); LOG.info("Corpus index used for english: " + contextIndexDirEN); LuceneManager contextLuceneManagerEN = new LuceneManager(contextIndexDirEN); contextLuceneManagerEN .setLuceneDefaultAnalyzer(new EnglishAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_EN)); ENGLISH_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerEN); // build kb italian searcher String kbDirIT = TMFVariables.KB_IT; String residualKbDirIT = TMFVariables.RESIDUAL_KB_IT; ITALIAN_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirIT, residualKbDirIT); // build kb english searcher String kbDirEN = TMFVariables.KB_EN; String residualKbDirEN = TMFVariables.RESIDUAL_KB_EN; ENGLISH_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirEN, residualKbDirEN); enhancer = new Enhancer(ITALIAN_CORPUS_INDEX_SEARCHER, ENGLISH_CORPUS_INDEX_SEARCHER, ITALIAN_KB_INDEX_SEARCHER, ENGLISH_KB_INDEX_SEARCHER); italianClassifier = new Classifier("it", ITALIAN_CORPUS_INDEX_SEARCHER); englishClassifier = new Classifier("en", ENGLISH_CORPUS_INDEX_SEARCHER); //The following is adapted from DBpedia Spotlight (https://github.com/dbpedia-spotlight/dbpedia-spotlight) final Map<String, String> initParams = new HashMap<String, String>(); initParams.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core." + "PackagesResourceConfig"); initParams.put("com.sun.jersey.config.property.packages", "it.polito.tellmefirst.web.rest.services"); initParams.put("com.sun.jersey.config.property.WadlGeneratorConfig", "it.polito.tellmefirst.web.rest.wadl." + "ExternalUriWadlGeneratorConfig"); SelectorThread threadSelector = GrizzlyWebContainerFactory.create(serverURI, initParams); threadSelector.start(); System.err.println("Server started in " + System.getProperty("user.dir") + " listening on " + serverURI); Thread warmUp = new Thread() { public void run() { } }; warmUp.start(); while (running) { Thread.sleep(100); } threadSelector.stopEndpoint(); System.exit(0); LOG.debug("[main] - END"); }
From source file:cn.anthony.util.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {/* w w w.jav a 2 s . c om*/ HttpGet httpget = new HttpGet("https://someportal/"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("https://someportal/")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:com.lxf.spider.client.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); try {/*w w w .j a v a2 s. c o m*/ HttpGet httpget = new HttpGet("http://127.0.0.1:8080/pdqx.jc.web"); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("http://127.0.0.1:8080/pdqx.jc.web")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:ee.ria.xroad.proxy.clientproxy.FastestConnectionSelectingSSLSocketFactoryIntegrationTest.java
public static void main(String[] args) throws Exception { URI[] addresses = { new URI("https://localhost:8081"), new URI("https://localhost:8082"), new URI("https://localhost:8080") }; logFH();/*from w w w .j a v a 2 s. c om*/ testWithSender(addresses); //testFastestSocketSelector(addresses); }
From source file:com.vmware.photon.controller.auth.Main.java
/** * Bootstrap the executor.//from w w w . java 2 s .c o m * Usage: auth-tool [-h] {get-token,gt,register-client,rc} ... */ public static void main(String[] args) { try { AuthToolCmdLine authToolCmdLine = AuthToolCmdLine.parseCmdLineArguments(args); switch (authToolCmdLine.getCommand()) { case GET_ACCESS_TOKEN: { initializeLogging(AUTH_TOKEN_LOG_FILE_NAME); OIDCTokens tokens = getAuthTokens(authToolCmdLine); printAccessToken(tokens.getAccessToken()); break; } case GET_REFRESH_TOKEN: { initializeLogging(AUTH_TOKEN_LOG_FILE_NAME); OIDCTokens tokens = getAuthTokens(authToolCmdLine); printRefreshToken(tokens.getRefreshToken()); break; } case REGISTER_CLIENT: { initializeLogging(CLIENT_REGISTRATION_LOG_FILE_NAME); ClientRegistrationArguments arguments = (ClientRegistrationArguments) authToolCmdLine .getArguments(); AuthOIDCClient oidcClient = new AuthOIDCClient(arguments.getAuthServerAddress(), arguments.getAuthServerPort(), arguments.getTenant()); AuthClientHandler authClientHandler = oidcClient.getClientHandler(arguments.getUsername(), arguments.getPassword()); AuthClientHandler.ImplicitClient implicitClient = authClientHandler.registerImplicitClient( new URI(arguments.getLoginRedirectEndpoint()), new URI(arguments.getLogoutRedirectEndpoint())); printClientRegistrationInfo(implicitClient); break; } default: throw new RuntimeException("Not supported auth tool command."); } } catch (ArgumentParserException e) { System.err.println("Error: " + e.getMessage()); System.err.println(); AuthToolCmdLine.usage(); System.exit(1); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); if (e.getCause() != null) { System.err.println(e.getCause().getMessage()); } System.exit(1); } }