當前位置: 首頁>>代碼示例>>Java>>正文


Java URI.getUserInfo方法代碼示例

本文整理匯總了Java中java.net.URI.getUserInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java URI.getUserInfo方法的具體用法?Java URI.getUserInfo怎麽用?Java URI.getUserInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.URI的用法示例。


在下文中一共展示了URI.getUserInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHarAuth

import java.net.URI; //導入方法依賴的package包/類
/**
 * Create a har specific auth 
 * har-underlyingfs:port
 * @param underLyingUri the uri of underlying
 * filesystem
 * @return har specific auth
 */
private String getHarAuth(URI underLyingUri) {
  String auth = underLyingUri.getScheme() + "-";
  if (underLyingUri.getHost() != null) {
    if (underLyingUri.getUserInfo() != null) {
      auth += underLyingUri.getUserInfo();
      auth += "@";
    }
    auth += underLyingUri.getHost();
    if (underLyingUri.getPort() != -1) {
      auth += ":";
      auth +=  underLyingUri.getPort();
    }
  }
  else {
    auth += ":";
  }
  return auth;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:26,代碼來源:HarFileSystem.java

示例2: withHost

import java.net.URI; //導入方法依賴的package包/類
public MethodLine withHost(String host) {
    try {
        if (!host.matches("[a-z]{1,6}://.*")) {
            host = "http://" + host;
        }
        URI hostURI = URI.create(host);
        URI newURI = new URI(hostURI.getScheme(),
                hostURI.getUserInfo(),
                hostURI.getHost(),
                hostURI.getPort(),
                uri.getPath(), uri.getQuery(), uri.getFragment());
        return new MethodLine(method, newURI, httpVersion);
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid host format" + Optional.ofNullable(
                e.getMessage()).map(s -> ": " + s).orElse(""));
    }
}
 
開發者ID:renatoathaydes,項目名稱:rawhttp,代碼行數:18,代碼來源:MethodLine.java

示例3: client

import java.net.URI; //導入方法依賴的package包/類
public AmazonS3 client(URI uri) throws IOException {
    String accessKey = null;
    String secretKey = null;
    if (uri.getHost() == null) {
        throw new IllegalArgumentException(INVALID_URI_MSG);
    }
    if (uri.getUserInfo() != null) {
        String[] userInfoParts = uri.getUserInfo().split(":");
        try {
            accessKey = userInfoParts[0];
            secretKey = userInfoParts[1];
        } catch (ArrayIndexOutOfBoundsException e) {
            // ignore
        }
    // if the URI contains '@' and ':', a UserInfo is in fact given, but could not
    // be parsed properly because the URI is not valid (e.g. not properly encoded).
    } else if (uri.toString().contains("@") && uri.toString().contains(":")) {
        throw new IllegalArgumentException(INVALID_URI_MSG);
    }
    return client(accessKey, secretKey);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:22,代碼來源:S3ClientHelper.java

示例4: getPassword

import java.net.URI; //導入方法依賴的package包/類
public static String getPassword(URI uri) {
  String userInfo = uri.getUserInfo();
  if (userInfo != null) {
    return userInfo.split(":", 2)[1];
  }
  return null;
}
 
開發者ID:x7-framework,項目名稱:x7,代碼行數:8,代碼來源:JedisURIHelper.java

示例5: removePort

import java.net.URI; //導入方法依賴的package包/類
private URI removePort(URI uri) throws StatusException {
    try {
        return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), -1 /* port */,
                uri.getPath(), uri.getQuery(), uri.getFragment());
    } catch (URISyntaxException e) {
        throw Status.UNAUTHENTICATED
                .withDescription("Unable to construct service URI after removing port")
                .withCause(e).asException();
    }
}
 
開發者ID:hypeapps,項目名稱:black-mirror,代碼行數:11,代碼來源:SpeechService.java

示例6: initialize

import java.net.URI; //導入方法依賴的package包/類
@Override
public void initialize(URI uri, Configuration conf) throws IOException { // get
  super.initialize(uri, conf);
  // get host information from uri (overrides info in conf)
  String host = uri.getHost();
  host = (host == null) ? conf.get(FS_FTP_HOST, null) : host;
  if (host == null) {
    throw new IOException("Invalid host specified");
  }
  conf.set(FS_FTP_HOST, host);

  // get port information from uri, (overrides info in conf)
  int port = uri.getPort();
  port = (port == -1) ? FTP.DEFAULT_PORT : port;
  conf.setInt("fs.ftp.host.port", port);

  // get user/password information from URI (overrides info in conf)
  String userAndPassword = uri.getUserInfo();
  if (userAndPassword == null) {
    userAndPassword = (conf.get("fs.ftp.user." + host, null) + ":" + conf
        .get("fs.ftp.password." + host, null));
  }
  String[] userPasswdInfo = userAndPassword.split(":");
  Preconditions.checkState(userPasswdInfo.length > 1,
                           "Invalid username / password");
  conf.set(FS_FTP_USER_PREFIX + host, userPasswdInfo[0]);
  conf.set(FS_FTP_PASSWORD_PREFIX + host, userPasswdInfo[1]);
  setConf(conf);
  this.uri = uri;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:31,代碼來源:FTPFileSystem.java

示例7: getPassword

import java.net.URI; //導入方法依賴的package包/類
public static String getPassword(URI uri) {
	String userInfo = uri.getUserInfo();
	if (userInfo != null) {
		return userInfo.split(":", 2)[1];
	}
	return null;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:8,代碼來源:JedisURIHelper.java

示例8: createNewUri

import java.net.URI; //導入方法依賴的package包/類
private URI createNewUri(URI nodeAddress, URI opUri) {
    try {
        return new URI(
                nodeAddress.getScheme(), opUri.getUserInfo(), nodeAddress.getHost(),
                nodeAddress.getPort(), opUri.getPath(), opUri.getQuery(), opUri.getFragment());
    } catch (URISyntaxException x) {
        throw new IllegalArgumentException(x.getMessage(), x);
    }
}
 
開發者ID:vmware,項目名稱:xenon-utils,代碼行數:10,代碼來源:GatewayService.java

示例9: main

import java.net.URI; //導入方法依賴的package包/類
public static void main ( String[] args ) {

        if ( args.length < 3 ) {
            System.err.println("Usage " + JBoss.class.getName() + " <uri> <payload> <payload_arg>");
            System.exit(-1);
        }

        URI u = URI.create(args[ 0 ]);

        final Object payloadObject = Utils.makePayloadObject(args[1], args[2]);

        String username = null;
        String password = null;
        if ( u.getUserInfo() != null ) {
            int sep = u.getUserInfo().indexOf(':');
            if ( sep >= 0 ) {
                username = u.getUserInfo().substring(0, sep);
                password = u.getUserInfo().substring(sep + 1);
            }
            else {
                System.err.println("Need <user>:<password>@");
                System.exit(-1);
            }
        }

        doRun(u, payloadObject, username, password);
        Utils.releasePayload(args[1], payloadObject);
    }
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:29,代碼來源:JBoss.java

示例10: main

import java.net.URI; //導入方法依賴的package包/類
public static void main ( String[] args ) {
    
    if ( args.length < 3 ) {
        System.err.println("Usage " + JBoss.class.getName() + " <uri> <payload> <payload_arg>");
        System.exit(-1);
    }

    URI u = URI.create(args[ 0 ]);

    final Object payloadObject = Utils.makePayloadObject(args[1], args[2]);
    
    String username = null;
    String password = null;
    if ( u.getUserInfo() != null ) {
        int sep = u.getUserInfo().indexOf(':');
        if ( sep >= 0 ) {
            username = u.getUserInfo().substring(0, sep);
            password = u.getUserInfo().substring(sep + 1);
        }
        else {
            System.err.println("Need <user>:<password>@");
            System.exit(-1);
        }
    }

    doRun(u, payloadObject, username, password);
    Utils.releasePayload(args[1], payloadObject);
}
 
開發者ID:RickGray,項目名稱:ysoserial-plus,代碼行數:29,代碼來源:JBoss.java

示例11: appendQueryParameter

import java.net.URI; //導入方法依賴的package包/類
@Override
protected URI appendQueryParameter(URI uri, OAuth2AccessToken accessToken) {
    try {
        String query = uri.getRawQuery();
        String queryFragment = this.resource.getTokenName() + "=" + URLEncoder.encode(accessToken.getValue(), "UTF-8");
        if(query == null) {
            query = queryFragment;
        } else {
            query = query + "&" + queryFragment;
        }
        String openid = (String) accessToken
                .getAdditionalInformation().get("openid");
        System.out.println("openid == " + openid);
        String openIdQueryFragment = "openid=" + URLEncoder.encode(openid, "UTF-8");
        query = query + "&" + openIdQueryFragment;
        URI update = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), (String)null, (String)null);
        StringBuffer sb = new StringBuffer(update.toString());
        sb.append("?");
        sb.append(query);
        if(uri.getFragment() != null) {
            sb.append("#");
            sb.append(uri.getFragment());
        }
        System.out.println("appendQueryParameter == " + sb.toString());
        return new URI(sb.toString());
    } catch (URISyntaxException var7) {
        throw new IllegalArgumentException("Could not parse URI", var7);
    } catch (UnsupportedEncodingException var8) {
        throw new IllegalArgumentException("Could not encode URI", var8);
    }
}
 
開發者ID:luotuo,項目名稱:springboot-security-wechat,代碼行數:32,代碼來源:MyOAuth2RestTemplate.java

示例12: rewriteURI

import java.net.URI; //導入方法依賴的package包/類
/**
 * A convenience method that creates a new {@link URI} whose scheme, host, port, path,
 * query are taken from the existing URI, dropping any fragment or user-information.
 * The existing URI is returned unmodified if it has no fragment or user-information.
 *
 * @param uri
 *            original URI.
 * @throws URISyntaxException
 *             If the resulting URI is invalid.
 */
public static URI rewriteURI(final URI uri) throws URISyntaxException {
    if (uri == null) {
        throw new IllegalArgumentException("URI may not be null");
    }
    if (uri.getFragment() != null || uri.getUserInfo() != null) {
        return new URIBuilder(uri).setFragment(null).setUserInfo(null).build();
    } else {
        return uri;
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:URIUtils.java

示例13: digestURI

import java.net.URI; //導入方法依賴的package包/類
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();
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:16,代碼來源:URIBuilder.java

示例14: normalizePortNumbersInUri

import java.net.URI; //導入方法依賴的package包/類
/**
 * Normalizes a URI. If it contains the default port for the used scheme, the method replaces the port with "default".
 * 
 * @param uri
 *            The URI to normalize.
 * 
 * @return A normalized URI.
 * 
 * @throws URISyntaxException
 *             If a URI cannot be created because of wrong syntax.
 */
private static URI normalizePortNumbersInUri(final URI uri) throws URISyntaxException {
    int port = uri.getPort();
    final String scheme = uri.getScheme();

    if (SCHEME_HTTP.equals(scheme) && port == DEFAULT_HTTP_PORT) {
        port = -1;
    }
    if (SCHEME_HTTPS.equals(scheme) && port == DEFAULT_HTTPS_PORT) {
        port = -1;
    }
    
    final URI result = new URI(scheme, uri.getUserInfo(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment());
    return result;
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:26,代碼來源:UriUtils.java

示例15: urlFromSocket

import java.net.URI; //導入方法依賴的package包/類
private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception {
    int listenPort = serverSocket.getLocalPort();

    return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), listenPort, uri.getPath(), uri.getQuery(),
            uri.getFragment());
}
 
開發者ID:messaginghub,項目名稱:pooled-jms,代碼行數:7,代碼來源:SocketProxy.java


注:本文中的java.net.URI.getUserInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。