當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。