Java Code Examples for java.net.URI#getRawUserInfo()

The following examples show how to use java.net.URI#getRawUserInfo() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nano-framework   File: URIBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public URIBuilder 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());
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
    return this;
}
 
Example 2
Source Project: es6draft   File: SourceIdentifiers.java    License: MIT License 6 votes vote down vote up
private static boolean hasIllegalComponents(URI moduleName) {
    // All components except for 'path' must be empty.
    if (moduleName.getScheme() != null) {
        return true;
    }
    if (moduleName.getRawAuthority() != null) {
        return true;
    }
    if (moduleName.getRawUserInfo() != null) {
        return true;
    }
    if (moduleName.getHost() != null) {
        return true;
    }
    if (moduleName.getPort() != -1) {
        return true;
    }
    if (moduleName.getRawQuery() != null) {
        return true;
    }
    if (moduleName.getRawFragment() != null) {
        return true;
    }
    return false;
}
 
Example 3
Source Project: keycloak   File: KeycloakUriBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public KeycloakUriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
    if (ssp == null) throw new IllegalArgumentException("schemeSpecificPart was null");

    StringBuilder sb = new StringBuilder();
    if (scheme != null) sb.append(scheme).append(':');
    if (ssp != null)
        sb.append(ssp);
    if (fragment != null && fragment.length() > 0) sb.append('#').append(fragment);
    URI uri = URI.create(sb.toString());

    if (uri.getRawSchemeSpecificPart() != null && uri.getRawPath() == null) {
        this.ssp = uri.getRawSchemeSpecificPart();
    } else {
        this.ssp = null;
        userInfo = uri.getRawUserInfo();
        host = uri.getHost();
        port = uri.getPort();
        path = uri.getRawPath();
        query = uri.getRawQuery();

    }
    return this;

}
 
Example 4
@Nullable
private String getProfile(URI cdmUri) {
  String profile = null;
  if (cdmUri.getAuthority() != null) {
    profile = cdmUri.getRawUserInfo();
  }
  return profile;
}
 
Example 5
Source Project: java-cfenv   File: UriInfo.java    License: Apache License 2.0 5 votes vote down vote up
private String[] parseUserinfo(URI uri) {
	String userInfo = uri.getRawUserInfo();

	if (userInfo != null) {
		String[] userPass = userInfo.split(":");
		if (userPass.length != 2) {
			throw new IllegalArgumentException("Bad userinfo in URI: " + uri);
		}
		return userPass;
	}

	return new String[]{null, null};
}
 
Example 6
Source Project: mirror   File: ImplicitResponseUrl.java    License: Apache License 2.0 5 votes vote down vote up
ImplicitResponseUrl(URI uri) {
    this(uri.getScheme(),
            uri.getHost(),
            uri.getPort(),
            uri.getRawPath(),
            uri.getRawFragment(),
            uri.getRawQuery(),
            uri.getRawUserInfo());
}
 
Example 7
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());
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
Example 8
Source Project: jrestless   File: CorsFilter.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isValidOrigin(URI origin) {
	return origin != null
			&& origin.getScheme() != null
			&& origin.getHost() != null
			&& isBlank(origin.getRawPath())
			&& origin.getRawQuery() == null
			&& origin.getRawFragment() == null
			&& origin.getRawUserInfo() == null;
}
 
Example 9
ImplicitResponseUrl(URI uri) {
    this(uri.getScheme(),
            uri.getHost(),
            uri.getPort(),
            uri.getRawPath(),
            uri.getRawFragment(),
            uri.getRawQuery(),
            uri.getRawUserInfo());
}
 
Example 10
/**
 * Constructs from a URI.
 *
 * @param uri URI
 * @param verbatim flag, to specify if URL should be used as is (without encoding, decoding and
 *     escaping)
 */
public GenericUrl(URI uri, boolean verbatim) {
  this(
      uri.getScheme(),
      uri.getHost(),
      uri.getPort(),
      uri.getRawPath(),
      uri.getRawFragment(),
      uri.getRawQuery(),
      uri.getRawUserInfo(),
      verbatim);
}
 
Example 11
/**
 * {@inheritDoc}
 *
 * @return same as {@link #getURI() getURI().toString()} with obfuscated user info
 */
@Override
@NotNull
public String toString() {
    final URI uri = getURI();
    final String userInfo = uri.getRawUserInfo();
    if (userInfo != null) {
        return uri.toString().replace(userInfo, "******:******");
    } else {
        return uri.toString();
    }
}
 
Example 12
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());
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}
 
Example 13
Source Project: plugin-socket.io   File: Url.java    License: Apache License 2.0 5 votes vote down vote up
public static URL parse(URI uri) throws MalformedURLException {
    String protocol = uri.getScheme();
    if (protocol == null || !protocol.matches("^https?|wss?$")) {
        protocol = "https";
    }

    int port = uri.getPort();
    if (port == -1) {
        if (PATTERN_HTTP.matcher(protocol).matches()) {
            port = 80;
        } else if (PATTERN_HTTPS.matcher(protocol).matches()) {
            port = 443;
        }
    }

    String path = uri.getRawPath();
    if (path == null || path.length() == 0) {
        path = "/";
    }

    String userInfo = uri.getRawUserInfo();
    String query = uri.getRawQuery();
    String fragment = uri.getRawFragment();
    return new URL(protocol + "://"
            + (userInfo != null ? userInfo + "@" : "")
            + uri.getHost()
            + (port != -1 ? ":" + port : "")
            + path
            + (query != null ? "?" + query : "")
            + (fragment != null ? "#" + fragment : ""));
}
 
Example 14
Source Project: plugin-socket.io   File: Url.java    License: Apache License 2.0 5 votes vote down vote up
public static URL parse(URI uri) throws MalformedURLException {
    String protocol = uri.getScheme();
    if (protocol == null || !protocol.matches("^https?|wss?$")) {
        protocol = "https";
    }

    int port = uri.getPort();
    if (port == -1) {
        if (PATTERN_HTTP.matcher(protocol).matches()) {
            port = 80;
        } else if (PATTERN_HTTPS.matcher(protocol).matches()) {
            port = 443;
        }
    }

    String path = uri.getRawPath();
    if (path == null || path.length() == 0) {
        path = "/";
    }

    String userInfo = uri.getRawUserInfo();
    String query = uri.getRawQuery();
    String fragment = uri.getRawFragment();
    return new URL(protocol + "://"
            + (userInfo != null ? userInfo + "@" : "")
            + uri.getHost()
            + (port != -1 ? ":" + port : "")
            + path
            + (query != null ? "?" + query : "")
            + (fragment != null ? "#" + fragment : ""));
}
 
Example 15
Source Project: spring-cloud-connectors   File: UriInfo.java    License: Apache License 2.0 5 votes vote down vote up
private String[] parseUserinfo(URI uri) {
	String userInfo = uri.getRawUserInfo();

	if (userInfo != null) {
		String[] userPass = userInfo.split(":");
		if (userPass.length == 1) {
			return new String[]{userPass[0], null};
		} else if (userPass.length != 2) {
			throw new IllegalArgumentException("Bad userinfo in URI: " + uri);
		}
		return userPass;
	}

	return new String[]{null, null};
}
 
Example 16
Source Project: RoboZombie   File: URIBuilder.java    License: Apache License 2.0 5 votes vote down vote up
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 17
Source Project: netbeans   File: HgURL.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param urlString
 * @param username
 * @param password value is cloned, if you want to null the field, call {@link #clearPassword()}
 * @throws URISyntaxException
 */
public HgURL(String urlString, String username, char[] password) throws URISyntaxException {
    URI originalUri;

    if (urlString == null) {
        throw new IllegalArgumentException("<null> URL string");    //NOI18N
    }

    if (urlString.length() == 0) {
        throw new IllegalArgumentException("empty URL string");     //NOI18N
    }

    if (looksLikePlainFilePath(urlString)) {
        originalUri = new File(urlString).toURI();
        scheme = Scheme.FILE;
    } else {
        originalUri = new URI(urlString).parseServerAuthority();
        String originalScheme = originalUri.getScheme();
        scheme = (originalScheme != null) ? determineScheme(originalScheme)
                                          : null;
    }

    if (scheme == null) {
        throw new URISyntaxException(
                urlString,
                NbBundle.getMessage(HgURL.class,
                                    "MSG_UNSUPPORTED_PROTOCOL",     //NOI18N
                                    originalUri.getScheme()));
    }

    verifyUserInfoData(scheme, username, password);

    if (username != null) {
        this.username = username;
        this.password = password == null ? null : (char[])password.clone();
    } else {
        String rawUserInfo = originalUri.getRawUserInfo();
        if (rawUserInfo == null) {
            this.username = null;
            this.password = null;
        } else {
            int colonIndex = rawUserInfo.indexOf(':');
            if (colonIndex == -1) {
                this.username = rawUserInfo;
                this.password = null;
            } else {
                this.username = rawUserInfo.substring(0, colonIndex);
                this.password = rawUserInfo.substring(colonIndex + 1).toCharArray();
            }
        }
    }

    host = originalUri.getHost();
    port = originalUri.getPort();
    rawPath     = originalUri.getRawPath();
    rawQuery    = originalUri.getRawQuery();
    rawFragment = originalUri.getRawFragment();

    path = originalUri.getPath();
}
 
Example 18
Source Project: emodb   File: EmoUriBuilder.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public UriBuilder schemeSpecificPart(String ssp) {
    if (ssp == null) {
        throw new IllegalArgumentException("Scheme specific part parameter is null");
    }

    // TODO encode or validate scheme specific part
    // This will not work for template variables present in the spp
    StringBuilder sb = new StringBuilder();
    if (scheme != null) {
        sb.append(scheme).append(':');
    }
    if (ssp != null) {
        sb.append(ssp);
    }
    if (fragment != null && fragment.length() > 0) {
        sb.append('#').append(fragment);
    }
    URI uri = createURI(sb.toString());

    if (uri.getRawSchemeSpecificPart() != null && uri.getRawPath() == null) {
        this.ssp = uri.getRawSchemeSpecificPart();
    } else {
        this.ssp = null;

        if (uri.getRawAuthority() != null) {
            if (uri.getRawUserInfo() == null && uri.getHost() == null && uri.getPort() == -1) {
                authority = uri.getRawAuthority();
                userInfo = null;
                host = null;
                port = -1;
            } else {
                authority = null;
                userInfo = uri.getRawUserInfo();
                host = uri.getHost();
                port = uri.getPort();
            }
        }

        path.setLength(0);
        path.append(replaceNull(uri.getRawPath()));

        query.setLength(0);
        query.append(replaceNull(uri.getRawQuery()));
    }
    return this;
}
 
Example 19
/**
 * use {@link URI#getRawUserInfo()} so the user info is not decoded - connections decode it again, which
 * causes problems with the plus sign, see CLO-8885
 */
public AbstractAuthority(URI uri) {
	this(uri.getScheme(), uri.getRawUserInfo(), uri.getHost(), uri.getPort());
}
 
Example 20
/**
 * use {@link URI#getRawUserInfo()} so the user info is not decoded - connections decode it again, which
 * causes problems with the plus sign, see CLO-8885
 */
public DefaultAuthority(URI uri, String proxy) {
	this(uri.getScheme(), uri.getRawUserInfo(), uri.getHost(), uri.getPort(), proxy);
}