当前位置: 首页>>代码示例>>Java>>正文


Java URL.getAuthority方法代码示例

本文整理汇总了Java中java.net.URL.getAuthority方法的典型用法代码示例。如果您正苦于以下问题:Java URL.getAuthority方法的具体用法?Java URL.getAuthority怎么用?Java URL.getAuthority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.URL的用法示例。


在下文中一共展示了URL.getAuthority方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processOpen

import java.net.URL; //导入方法依赖的package包/类
public void processOpen(String method, URL url, String origin, boolean async, long connectTimeout) throws Exception {
    LOG.entering(CLASS_NAME, "processOpen", new Object[]{method, url, origin, async});

    this.async = async;
    connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod(method);
    connection.setInstanceFollowRedirects(false);
    connection.setConnectTimeout((int) connectTimeout);

    if (!origin.equalsIgnoreCase("null") && !origin.startsWith("privileged")) {
        URL originUrl = new URL(origin);
        origin = originUrl.getProtocol() + "://" + originUrl.getAuthority();
    }

    // connection.addRequestProperty("X-Origin", origin);
    connection.addRequestProperty("Origin", origin);
    setReadyState(State.OPENED);

    listener.opened(new OpenEvent());
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:21,代码来源:HttpRequestDelegateImpl.java

示例2: toURI

import java.net.URL; //导入方法依赖的package包/类
public static java.net.URI toURI(URL url) {
    String protocol = url.getProtocol();
    String auth = url.getAuthority();
    String path = url.getPath();
    String query = url.getQuery();
    String ref = url.getRef();
    if (path != null && !(path.startsWith("/")))
        path = "/" + path;

    //
    // In java.net.URI class, a port number of -1 implies the default
    // port number. So get it stripped off before creating URI instance.
    //
    if (auth != null && auth.endsWith(":-1"))
        auth = auth.substring(0, auth.length() - 3);

    java.net.URI uri;
    try {
        uri = createURI(protocol, auth, path, query, ref);
    } catch (java.net.URISyntaxException e) {
        uri = null;
    }
    return uri;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:ParseUtil.java

示例3: browse

import java.net.URL; //导入方法依赖的package包/类
/**
 * Browse the given URL
 *
 * @param url url
 * @param name title
 */
public static void browse(final URL url, final String name) {
	if (Desktop.isDesktopSupported()) {
		try {
			// need this strange code, because the URL.toURI() method have
			// some trouble dealing with UTF-8 encoding sometimes
			final URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), url.getRef());
			Desktop.getDesktop().browse(uri);
		} catch (final Exception e) {
			LOGGER.error(e.getMessage(), e);
			JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name));
		}
	} else {
		JOptionPane.showMessageDialog(null, Resources.getLabel("error.open.url", name));
	}
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:22,代码来源:Util.java

示例4: if

import java.net.URL; //导入方法依赖的package包/类
/**
 * Skalering af andre billeder. Denne her virker til begge ovenstående, samt til skalering af andre biller, så den gemmer vi, selvom den ikke bliver brugt p.t.
 */
public static String skalérAndenBilledeUrl(String url, int bredde, int højde) {
  if (url == null || url.length() == 0 || "null".equals(url)) return null;
  try {
    URL u = new URL(url);
    String skaleretUrl = "http://dr.dk/drdkimagescale/imagescale.drxml?server=" + u.getAuthority() + "&file=" + u.getPath() + "&w=" + bredde + "&h=" + højde + "&scaleafter=crop";

    Log.d("skalérAndenBilledeUrl url1 = " + url);
    Log.d("skalérAndenBilledeUrl url2 = " + u);
    Log.d("skalérAndenBilledeUrl url3 = " + skaleretUrl);
    return skaleretUrl;
  } catch (Exception e) {
    Log.e("url=" + url, e);
    return null;
  }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:19,代码来源:Basisfragment.java

示例5: createURLRegex

import java.net.URL; //导入方法依赖的package包/类
private String createURLRegex(String url) {
    String baseURL;
    try {
        URL u = new URL(url);
        baseURL = u.getProtocol()+":"+
            ((u.getAuthority() != null && u.getAuthority().length() > 0) ?
                "//"+u.getAuthority() : "")+
            ((u.getPath() != null) ?
                u.getPath() : "");
    } catch (MalformedURLException ex) {
        baseURL = url;
        int i = url.indexOf('?');
        if (i > 0) {
            baseURL = baseURL.substring(0, i);
        }
        i = url.indexOf('#');
        if (i > 0) {
            baseURL = baseURL.substring(0, i);
        }
    }
    // Escape regex special characters:
    baseURL = baseURL.replace("\\", "\\\\");
    baseURL = baseURL.replace(".", "\\.");
    baseURL = baseURL.replace("*", "\\*");
    baseURL = baseURL.replace("+", "\\+");
    baseURL = baseURL.replace("(", "\\(");
    baseURL = baseURL.replace(")", "\\)");
    baseURL = baseURL.replace("{", "\\{");
    baseURL = baseURL.replace("}", "\\}");
    baseURL = baseURL.replace("|", "\\|");
    //System.err.println("Escaped baseURL = '"+baseURL+"'");
    return "^"+baseURL+".*";
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Debugger.java

示例6: createProvider

import java.net.URL; //导入方法依赖的package包/类
/**
 * This provider expects URIs in the following form :
 * kms://<PROTO>@<AUTHORITY>/<PATH>
 *
 * where :
 * - PROTO = http or https
 * - AUTHORITY = <HOSTS>[:<PORT>]
 * - HOSTS = <HOSTNAME>[;<HOSTS>]
 * - HOSTNAME = string
 * - PORT = integer
 *
 * If multiple hosts are provider, the Factory will create a
 * {@link LoadBalancingKMSClientProvider} that round-robins requests
 * across the provided list of hosts.
 */
@Override
public KeyProvider createProvider(URI providerUri, Configuration conf)
    throws IOException {
  URL origUrl = new URL(extractKMSPath(providerUri).toString());
  String authority = origUrl.getAuthority();
  // check for ';' which delimits the backup hosts
  if (Strings.isNullOrEmpty(authority)) {
    throw new IOException(
        "No valid authority in kms uri [" + origUrl + "]");
  }
  // Check if port is present in authority
  // In the current scheme, all hosts have to run on the same port
  int port = -1;
  String hostsPart = authority;
  if (authority.contains(":")) {
    String[] t = authority.split(":");
    try {
      port = Integer.parseInt(t[1]);
    } catch (Exception e) {
      throw new IOException(
          "Could not parse port in kms uri [" + origUrl + "]");
    }
    hostsPart = t[0];
  }
  return createProvider(providerUri, conf, origUrl, port, hostsPart);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:42,代码来源:KMSClientProvider.java

示例7: addURL

import java.net.URL; //导入方法依赖的package包/类
private void addURL(final List<URL> list, final String uriString) {
    try {
        // Build URI by components to facilitate proper encoding of querystring
        // e.g. http://example.com:8085/ca?action=crl&issuer=CN=CAS Test User CA
        final URL url = new URL(uriString);
        final URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(), null);
        list.add(uri.toURL());
    } catch (final Exception e) {
        logger.warn("{} is not a valid distribution point URI.", uriString);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:12,代码来源:CRLDistributionPointRevocationChecker.java

示例8: run

import java.net.URL; //导入方法依赖的package包/类
@Override
public Object run() {
    RequestContext ctx = RequestContext.getCurrentContext();
    String protocol = ctx.getRequest().getScheme();
    ctx.addZuulRequestHeader(HEADER_SCHEME, protocol);
    String domain = ctx.getRequest().getServerName();
    ctx.addZuulRequestHeader(HEADER_DOMAIN, domain);
    String port = String.valueOf(ctx.getRequest().getServerPort());
    ctx.addZuulRequestHeader(HEADER_PORT, port);

    String tenant = tenantMappingService.getTenants().get(domain);
    if (StringUtils.isBlank(tenant)) {
        log.debug("Domain Proxy Filter: no mapping for domain: {}", domain);
        tenant = DEFAULT_TENANT;
    }
    ctx.addZuulRequestHeader(HEADER_TENANT, tenant);
    String referer = ctx.getRequest().getHeader("referer");
    String webapp = null;
    try {
        URL url = new URL(referer);
        URI uri = new URI(url.getProtocol(), url.getAuthority(), null, null, null);
        webapp = uri.toString();
    } catch (Exception e) {
        log.debug("Error while running", e);
    }
    ctx.addZuulRequestHeader(HEADER_WEBAPP_URL, webapp);

    return null;
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:30,代码来源:DomainRelayFilter.java

示例9: URLtoSocketPermission

import java.net.URL; //导入方法依赖的package包/类
/**
 *  if the caller has a URLPermission for connecting to the
 *  given URL, then return a SocketPermission which permits
 *  access to that destination. Return null otherwise. The permission
 *  is cached in a field (which can only be changed by redirects)
 */
SocketPermission URLtoSocketPermission(URL url) throws IOException {

    if (socketPermission != null) {
        return socketPermission;
    }

    SecurityManager sm = System.getSecurityManager();

    if (sm == null) {
        return null;
    }

    // the permission, which we might grant

    SocketPermission newPerm = new SocketPermission(
        getHostAndPort(url), "connect"
    );

    String actions = getRequestMethod()+":" +
            getUserSetHeaders().getHeaderNamesInList();

    String urlstring = url.getProtocol() + "://" + url.getAuthority()
            + url.getPath();

    URLPermission p = new URLPermission(urlstring, actions);
    try {
        sm.checkPermission(p);
        socketPermission = newPerm;
        return socketPermission;
    } catch (SecurityException e) {
        // fall thru
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:HttpURLConnection.java

示例10: logout

import java.net.URL; //导入方法依赖的package包/类
@RequestMapping(value = "/userlogout", method = GET)
public String logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    URL url = new URL(request.getRequestURL().toString());
    String urlStr = url.getProtocol() + "://" + url.getAuthority();
    return "redirect:" + ssoServiceUrl + "/logout.do?redirect=" + urlStr + "&clientId=" + clientId;
}
 
开发者ID:bijukunjummen,项目名称:oauth-uaa-sample,代码行数:11,代码来源:SampleController.java

示例11: getDomainUrl

import java.net.URL; //导入方法依赖的package包/类
public static String getDomainUrl(String urlStr){
		String domainUrl=urlStr;
		try {
		     URL url = new URL(urlStr);
		     domainUrl=url.getProtocol()+"://"+url.getAuthority();
		} catch (Exception e) {
//			logger.error("getDomainUrl is erro,url :"+urlStr, e);
		}
		return domainUrl;
	}
 
开发者ID:Kuangcp,项目名称:JavaToolKit,代码行数:11,代码来源:URLUtil.java

示例12: createProvider

import java.net.URL; //导入方法依赖的package包/类
/**
 * This provider expects URIs in the following form :
 * kms://<PROTO>@<AUTHORITY>/<PATH>
 *
 * where :
 * - PROTO = http or https
 * - AUTHORITY = <HOSTS>[:<PORT>]
 * - HOSTS = <HOSTNAME>[;<HOSTS>]
 * - HOSTNAME = string
 * - PORT = integer
 *
 * If multiple hosts are provider, the Factory will create a
 * {@link LoadBalancingKMSClientProvider} that round-robins requests
 * across the provided list of hosts.
 */
@Override
public KeyProvider createProvider(URI providerUri, Configuration conf)
    throws IOException {
  if (SCHEME_NAME.equals(providerUri.getScheme())) {
    URL origUrl = new URL(extractKMSPath(providerUri).toString());
    String authority = origUrl.getAuthority();
    // check for ';' which delimits the backup hosts
    if (Strings.isNullOrEmpty(authority)) {
      throw new IOException(
          "No valid authority in kms uri [" + origUrl + "]");
    }
    // Check if port is present in authority
    // In the current scheme, all hosts have to run on the same port
    int port = -1;
    String hostsPart = authority;
    if (authority.contains(":")) {
      String[] t = authority.split(":");
      try {
        port = Integer.parseInt(t[1]);
      } catch (Exception e) {
        throw new IOException(
            "Could not parse port in kms uri [" + origUrl + "]");
      }
      hostsPart = t[0];
    }
    return createProvider(providerUri, conf, origUrl, port, hostsPart);
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:KMSClientProvider.java

示例13: getURLConnectPermission

import java.net.URL; //导入方法依赖的package包/类
private static Permission getURLConnectPermission(URL url) {
    String urlString = url.getProtocol() + "://" + url.getAuthority() + url.getPath();
    return new URLPermission(urlString);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:URLUtil.java


注:本文中的java.net.URL.getAuthority方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。