Java Code Examples for java.net.URI.getRawAuthority()

The following are Jave code examples for showing how to use getRawAuthority() of the java.net.URI class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Hotspot-master-devp   File: URIBuilder.java   View Source Code Vote up 5 votes
private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), Charset.forName(HTTP.UTF_8));
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
Example 2
Project: lams   File: URIBuilder.java   View Source Code Vote up 5 votes
private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
Example 3
Project: FirefoxData-android   File: URIBuilder.java   View Source Code Vote up 5 votes
private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
Example 4
Project: openjdk-jdk10   File: UnixFileSystemProvider.java   View Source Code Vote up 5 votes
private void checkUri(URI uri) {
    if (!uri.getScheme().equalsIgnoreCase(getScheme()))
        throw new IllegalArgumentException("URI does not match this provider");
    if (uri.getRawAuthority() != null)
        throw new IllegalArgumentException("Authority component present");
    String path = uri.getPath();
    if (path == null)
        throw new IllegalArgumentException("Path component is undefined");
    if (!path.equals("/"))
        throw new IllegalArgumentException("Path component should be '/'");
    if (uri.getRawQuery() != null)
        throw new IllegalArgumentException("Query component present");
    if (uri.getRawFragment() != null)
        throw new IllegalArgumentException("Fragment component present");
}
 
Example 5
Project: openjdk-jdk10   File: WindowsFileSystemProvider.java   View Source Code Vote up 5 votes
private void checkUri(URI uri) {
    if (!uri.getScheme().equalsIgnoreCase(getScheme()))
        throw new IllegalArgumentException("URI does not match this provider");
    if (uri.getRawAuthority() != null)
        throw new IllegalArgumentException("Authority component present");
    String path = uri.getPath();
    if (path == null)
        throw new IllegalArgumentException("Path component is undefined");
    if (!path.equals("/"))
        throw new IllegalArgumentException("Path component should be '/'");
    if (uri.getRawQuery() != null)
        throw new IllegalArgumentException("Query component present");
    if (uri.getRawFragment() != null)
        throw new IllegalArgumentException("Fragment component present");
}
 
Example 6
Project: BUbiNG   File: ParsingThread.java   View Source Code Vote up 5 votes
private static boolean sameSchemeAuthority(final byte[] schemeAuthority, final URI url) {
	final String scheme = url.getScheme();
	int schemeLength = scheme.length();
	if (schemeAuthority.length < schemeLength + 3) return false;
	for(int i = schemeLength; i-- != 0;) if (schemeAuthority[i] != (byte)scheme.charAt(i)) return false;
	if (schemeAuthority[schemeLength++] != (byte)':') return false;
	if (schemeAuthority[schemeLength++] != (byte)'/') return false;
	if (schemeAuthority[schemeLength++] != (byte)'/') return false;

	final String authority = url.getRawAuthority();
	if (schemeAuthority.length != schemeLength + authority.length()) return false;
	for(int i = authority.length(); i-- != 0;) if (schemeAuthority[schemeLength + i] != (byte)authority.charAt(i)) return false;
	return true;
}
 
Example 7
Project: hadoop   File: AzureNativeFileSystemStore.java   View Source Code Vote up 4 votes
/**
 * Method to extract the account name from an Azure URI.
 * 
 * @param uri
 *          -- WASB blob URI
 * @returns accountName -- the account name for the URI.
 * @throws URISyntaxException
 *           if the URI does not have an authority it is badly formed.
 */
private String getAccountFromAuthority(URI uri) throws URISyntaxException {

  // Check to make sure that the authority is valid for the URI.
  //
  String authority = uri.getRawAuthority();
  if (null == authority) {
    // Badly formed or illegal URI.
    //
    throw new URISyntaxException(uri.toString(),
        "Expected URI with a valid authority");
  }

  // Check if authority container the delimiter separating the account name from the
  // the container.
  //
  if (!authority.contains(WASB_AUTHORITY_DELIMITER)) {
    return authority;
  }

  // Split off the container name and the authority.
  //
  String[] authorityParts = authority.split(WASB_AUTHORITY_DELIMITER, 2);

  // Because the string contains an '@' delimiter, a container must be
  // specified.
  //
  if (authorityParts.length < 2 || "".equals(authorityParts[0])) {
    // Badly formed WASB authority since there is no container.
    //
    final String errMsg = String
        .format(
            "URI '%s' has a malformed WASB authority, expected container name. "
                + "Authority takes the form wasb://[<container name>@]<account name>",
            uri.toString());
    throw new IllegalArgumentException(errMsg);
  }

  // Return with the account name. It is possible that this name is NULL.
  //
  return authorityParts[1];
}
 
Example 8
Project: hadoop   File: AzureNativeFileSystemStore.java   View Source Code Vote up 4 votes
/**
 * Method to extract the container name from an Azure URI.
 * 
 * @param uri
 *          -- WASB blob URI
 * @returns containerName -- the container name for the URI. May be null.
 * @throws URISyntaxException
 *           if the uri does not have an authority it is badly formed.
 */
private String getContainerFromAuthority(URI uri) throws URISyntaxException {

  // Check to make sure that the authority is valid for the URI.
  //
  String authority = uri.getRawAuthority();
  if (null == authority) {
    // Badly formed or illegal URI.
    //
    throw new URISyntaxException(uri.toString(),
        "Expected URI with a valid authority");
  }

  // The URI has a valid authority. Extract the container name. It is the
  // second component of the WASB URI authority.
  if (!authority.contains(WASB_AUTHORITY_DELIMITER)) {
    // The authority does not have a container name. Use the default container by
    // setting the container name to the default Azure root container.
    //
    return AZURE_ROOT_CONTAINER;
  }

  // Split off the container name and the authority.
  String[] authorityParts = authority.split(WASB_AUTHORITY_DELIMITER, 2);

  // Because the string contains an '@' delimiter, a container must be
  // specified.
  if (authorityParts.length < 2 || "".equals(authorityParts[0])) {
    // Badly formed WASB authority since there is no container.
    final String errMsg = String
        .format(
            "URI '%s' has a malformed WASB authority, expected container name."
                + "Authority takes the form wasb://[<container name>@]<account name>",
            uri.toString());
    throw new IllegalArgumentException(errMsg);
  }

  // Set the container name from the first entry for the split parts of the
  // authority.
  return authorityParts[0];
}
 
Example 9
Project: openjdk-jdk10   File: WindowsUriSupport.java   View Source Code Vote up 4 votes
/**
 * Converts given URI to a Path
 */
static WindowsPath fromUri(WindowsFileSystem fs, URI uri) {
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getRawFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getRawQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String path = uri.getPath();
    if (path.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // UNC
    String auth = uri.getRawAuthority();
    if (auth != null && !auth.equals("")) {
        String host = uri.getHost();
        if (host == null)
            throw new IllegalArgumentException("URI authority component has undefined host");
        if (uri.getUserInfo() != null)
            throw new IllegalArgumentException("URI authority component has user-info");
        if (uri.getPort() != -1)
            throw new IllegalArgumentException("URI authority component has port number");

        // IPv6 literal
        // 1. drop enclosing brackets
        // 2. replace ":" with "-"
        // 3. replace "%" with "s" (zone/scopeID delimiter)
        // 4. Append .ivp6-literal.net
        if (host.startsWith("[")) {
            host = host.substring(1, host.length()-1)
                       .replace(':', '-')
                       .replace('%', 's');
            host += IPV6_LITERAL_SUFFIX;
        }

        // reconstitute the UNC
        path = "\\\\" + host + path;
    } else {
        if ((path.length() > 2) && (path.charAt(2) == ':')) {
            // "/c:/foo" --> "c:/foo"
            path = path.substring(1);
        }
    }
    return WindowsPath.parse(fs, path);
}
 
Example 10
Project: openjdk-jdk10   File: File.java   View Source Code Vote up 3 votes
/**
 * Creates a new {@code File} instance by converting the given
 * {@code file:} URI into an abstract pathname.
 *
 * <p> The exact form of a {@code file:} URI is system-dependent, hence
 * the transformation performed by this constructor is also
 * system-dependent.
 *
 * <p> For a given abstract pathname <i>f</i> it is guaranteed that
 *
 * <blockquote><code>
 * new File(</code><i>&nbsp;f</i><code>.{@link #toURI()
 * toURI}()).equals(</code><i>&nbsp;f</i><code>.{@link #getAbsoluteFile() getAbsoluteFile}())
 * </code></blockquote>
 *
 * so long as the original abstract pathname, the URI, and the new abstract
 * pathname are all created in (possibly different invocations of) the same
 * Java virtual machine.  This relationship typically does not hold,
 * however, when a {@code file:} URI that is created in a virtual machine
 * on one operating system is converted into an abstract pathname in a
 * virtual machine on a different operating system.
 *
 * @param  uri
 *         An absolute, hierarchical URI with a scheme equal to
 *         {@code "file"}, a non-empty path component, and undefined
 *         authority, query, and fragment components
 *
 * @throws  NullPointerException
 *          If {@code uri} is {@code null}
 *
 * @throws  IllegalArgumentException
 *          If the preconditions on the parameter do not hold
 *
 * @see #toURI()
 * @see java.net.URI
 * @since 1.4
 */
public File(URI uri) {

    // Check our many preconditions
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getRawAuthority() != null)
        throw new IllegalArgumentException("URI has an authority component");
    if (uri.getRawFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getRawQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String p = uri.getPath();
    if (p.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // Okay, now initialize
    p = fs.fromURIPath(p);
    if (File.separatorChar != '/')
        p = p.replace('/', File.separatorChar);
    this.path = fs.normalize(p);
    this.prefixLength = fs.prefixLength(this.path);
}
 
Example 11
Project: BUbiNG   File: BURL.java   View Source Code Vote up 2 votes
/** Returns the concatenated {@linkplain URI#getScheme()} and {@link URI#getRawAuthority() raw authority} of a BUbiNG URL.
 *
 * @param url a BUbiNG URL.
 * @return the concatenated {@linkplain URI#getScheme()} and {@link URI#getRawAuthority() raw authority} of <code>uri</code>.
 */
public static String schemeAndAuthority(final URI url) {
	return url.getScheme() + "://" + url.getRawAuthority();
}