当前位置: 首页>>代码示例>>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;未经允许,请勿转载。