URI getUserInfo - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for URI getUserInfo method.

This code example shows how to use the following methods:getHost, getPath, getPort, getUserInfo
		    new GenericObjectPoolConfig()); 
	} 
    } 
 
    public JedisPool(final URI uri) {
	String h = uri.getHost();
	int port = uri.getPort();
	String password = uri.getUserInfo().split(":", 2)[1];
	int database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
	this.internalPool = new GenericObjectPool<Jedis>(new JedisFactory(h,
		port, Protocol.DEFAULT_TIMEOUT, password, database, null),
		new GenericObjectPoolConfig()); 
    } 
 
    public JedisPool(final GenericObjectPoolConfig poolConfig,
	    final String host, int port, int timeout, final String password) {
	this(poolConfig, host, port, timeout, password,
		Protocol.DEFAULT_DATABASE, null); 
    } 
 
9
CodeRank
This code example shows how to use the following methods:getHost, getPort, getUserInfo
 
    public  Context getRemoteContext() throws Exception {
        final Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
        URI webUri = managementClient.getWebUri();
        URI namingUri = new URI("http-remoting", webUri.getUserInfo(), webUri.getHost(), webUri.getPort(), "", "" ,"");
        env.put(Context.PROVIDER_URL, namingUri.toString());
        env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
        env.put("jboss.naming.client.security.callback.handler.class", CallbackHandler.class.getName());
        return new InitialContext(env);
    } 
 
    @Test 
    public void testRemoteLookup() throws Exception { 
        Context context = null;
        try { 
            context = getRemoteContext();
            assertEquals("TestValue", context.lookup("test"));
        } finally { 
            if (context != null)
8
CodeRank
This code example shows how to use the following methods:getHost, getScheme, getUserInfo
  /** 
   * @throws IllegalArgumentException if credentials for S3 cannot be 
   * determined. 
   */ 
  public void initialize(URI uri, Configuration conf) {
    if (uri.getHost() == null) {
      throw new IllegalArgumentException("Invalid hostname in URI " + uri);
    } 
     
    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
      int index = userInfo.indexOf(':');
      if (index != -1) {
        accessKey = userInfo.substring(0, index);
        secretAccessKey = userInfo.substring(index + 1);
      } else { 
        accessKey = userInfo;
      } 
    } 
     

8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
  public BaseResource(String uri, boolean rewrite) throws URISyntaxException {
    this(new URI(uri), rewrite);
  } 
 
  public BaseResource(URI uri, boolean rewrite) {
    if (rewrite && uri.getHost().equals("localhost")) {
      // Rewrite localhost URIs to refer to the special Android emulator loopback passthrough interface. 
      Log.d(LOG_TAG, "Rewriting " + uri + " to point to 10.0.2.2.");
      try { 
        this.uri = new URI(uri.getScheme(), uri.getUserInfo(), "10.0.2.2", uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
      } catch (URISyntaxException e) {
        Log.e(LOG_TAG, "Got error rewriting URI for Android emulator.", e);
      } 
    } else { 
      this.uri = uri;
    } 
  } 
 
  public URI getURI() {
    return this.uri;
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
        List<URI> uris = resolveURIs(baseURI, hrefs);
        return filterNonDirectChilds(baseURI, uris);
    } 
 
    private URI addTrailingSlashes(URI uri) throws IOException, URISyntaxException {
        if(uri.getPath() == null){
            uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), "/", uri.getQuery(), uri.getFragment());
        }else if (!uri.getPath().endsWith("/") && !uri.getPath().endsWith(".html")) {
            uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + "/", uri.getQuery(), uri.getFragment());
 
        } 
        return uri;
    } 
 
    private List<String> filterNonDirectChilds(URI baseURI, List<URI> inputURIs) throws MalformedURLException {
        final int baseURIPort = baseURI.getPort();
        final String baseURIHost = baseURI.getHost();
        final String baseURIScheme = baseURI.getScheme();
 
        List<String> uris = new ArrayList<String>();
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPort, getQuery, getScheme
	protected String name;
	protected Level level;
	protected Level effectiveLevel;
 
	protected URI createUriWithPath(final IPath path) throws URISyntaxException {
		return new URI(baseLocation.getScheme(), baseLocation.getUserInfo(),
				baseLocation.getHost(), baseLocation.getPort(),
				path.toString(), baseLocation.getQuery(),
				baseLocation.getFragment());
	} 
 
	public JSONObject toJSON() throws URISyntaxException {
		return jsonSerializer.serialize(this, DEFAULT_RESOURCE_SHAPE);
	} 
 
	@PropertyDescription(name = ProtocolConstants.KEY_NAME) 
	public String getName() {
		return name;
	} 
 
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
 
	/** 
	 * Sets the absolute location of the contents of this project. 
	 */ 
	public void setContentLocation(URI contentURI) {
		if (contentURI.getUserInfo() == null) {
			contentLocation = contentURI;
		} else { 
			try { 
				//strip out credential information 
				contentLocation = new URI(contentURI.getScheme(), null, contentURI.getHost(), contentURI.getPort(), contentURI.getPath(), contentURI.getQuery(), contentURI.getFragment());
			} catch (URISyntaxException e) {
				//should never happen because we are stripping info from a valid URI 
				throw new RuntimeException(e);
			} 
		} 
	} 
	 
	/** 
	 * Sets the workspace id of the workspace that owns this project. 
8
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getQuery
   * @param defaultPort if none is given 
   * @return URI 
   */ 
  public static URI getCanonicalUri(URI uri, int defaultPort) {
    // skip if there is no authority, ie. "file" scheme or relative uri 
    String host = uri.getHost();
    if (host == null) {
      return uri;
    } 
    String fqHost = canonicalizeHost(host);
    int port = uri.getPort();
    // short out if already canonical with a port 
    if (host.equals(fqHost) && port != -1) {
      return uri;
    } 
    // reconstruct the uri with the canonical host and port 
    try { 
      uri = new URI(uri.getScheme(), uri.getUserInfo(),
          fqHost, (port == -1) ? defaultPort : port,
          uri.getPath(), uri.getQuery(), uri.getFragment());

8
CodeRank
This code example shows how to use the following methods:getAuthority, getPort, getUserInfo
        assertEquals("user", uri.getUserInfo());
        assertEquals("host", uri.getHost());
    } 
 
    public void testUserNoPasswordExplicitPort() throws Exception { 
        URI uri = new URI("http://user@host:8080");
        assertEquals("user@host:8080", uri.getAuthority());
        assertEquals("user", uri.getUserInfo());
        assertEquals("host", uri.getHost());
        assertEquals(8080, uri.getPort());
    } 
 
    public void testUserPasswordHostPort() throws Exception { 
        URI uri = new URI("http://user:password@host:8080");
        assertEquals("user:password@host:8080", uri.getAuthority());
        assertEquals("user:password", uri.getUserInfo());
        assertEquals("host", uri.getHost());
        assertEquals(8080, uri.getPort());
    } 
 
7
CodeRank
This code example shows how to use the following methods:getFragment, getHost, getPath, getPort, getRawQuery
 
		try { 
 
			// TODO: there is some duplication with UriUtils here. Probably unavoidable as long as this 
			// method signature uses URI not String. 
			String query = uri.getRawQuery(); // Don't decode anything here
			String queryFragment = resource.getTokenName() + "=" + URLEncoder.encode(accessToken.getValue(), "UTF-8");
			if (query == null) {
				query = queryFragment;
			} 
			else { 
				query = query + "&" + queryFragment;
			} 
 
			// first form the URI without query and fragment parts, so that it doesn't re-encode some query string chars 
			// (SECOAUTH-90) 
			URI update = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), null,
					null); 
			// now add the encoded query string and the then fragment 
			StringBuffer sb = new StringBuffer(update.toString());

7
CodeRank
getUserInfo Method Overview
Returns the decoded user-information component of this URI.
See Code Examples for other Java 8 URI Methods: