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


Java ContainerRequest.getHeaderValue方法代碼示例

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


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

示例1: addResponseHeaders

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
 * 全てのレスポンスに共通するレスポンスヘッダーを追加する.
 * Access-Control-Allow-Origin, Access-Control-Allow-Headers<br/>
 * X-Personium-Version<br/>
 * @param request
 * @param response
 */
private void addResponseHeaders(final ContainerRequest request, final ContainerResponse response) {
    MultivaluedMap<String, Object> mm = response.getHttpHeaders();
    String acrh = request.getHeaderValue(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS);
    if (acrh != null) {
        mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, acrh);
    } else {
        mm.remove(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS);
    }
    mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.Value.ASTERISK);
    // X-Personium-Version
    mm.putSingle(HttpHeaders.X_PERSONIUM_VERSION, PersoniumUnitConfig.getCoreVersion());
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:20,代碼來源:PersoniumCoreContainerFilter.java

示例2: responseOptionsMethod

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
 * 認証なしOPTIONメソッドのレスポンスを返卻する.
 * @param request フィルタ前リクエスト
 */
private void responseOptionsMethod(ContainerRequest request) {
    String authValue = request.getHeaderValue(org.apache.http.HttpHeaders.AUTHORIZATION);
    String methodName = request.getMethod();
    if (authValue == null && HttpMethod.OPTIONS.equals(methodName)) {
        Response res = PersoniumCoreUtils.responseBuilderForOptions(
                HttpMethod.GET,
                HttpMethod.POST,
                HttpMethod.PUT,
                HttpMethod.DELETE,
                HttpMethod.HEAD,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MERGE,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MKCOL,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.MOVE,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPFIND,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.PROPPATCH,
                io.personium.common.utils.PersoniumCoreUtils.HttpMethod.ACL
                ).build();

        // 例外を発行することでServletへ製禦を渡さない
        throw new WebApplicationException(res);
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:27,代碼來源:PersoniumCoreContainerFilter.java

示例3: checkRequestHeader

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
 * リクエストヘッダーの値をチェックする.
 * 現在は、Acceptヘッダーのみ(US-ASCII文字以外かどうか)をチェックする
 * @param request フィルター前リクエスト
 */
private void checkRequestHeader(ContainerRequest request) {
    // ヘッダーのキー名に全角文字が含まれる場合は、その文字を含めたキー名となるため、実際にはこの指定は無視される。
    // Jersey1.10では、Acceptヘッダーのキー名と値にUS-ASCII文字以外が含まれる場合に異常終了するため以下を対処
    // (Acceptを含む他のヘッダーにも同様の処理が行われるが、上記理由により動作上は問題ないと判斷)
    // -キー名に含まれる場合は、その指定を無効(Accept:*/*)とする(Jerseryで組み込み済み)。
    // -値に含まれる場合は、400エラーとする。
    InBoundHeaders newHeaders = new InBoundHeaders();
    MultivaluedMap<String, String> headers = request.getRequestHeaders();
    for (String header : headers.keySet()) {
        if (header.contains(org.apache.http.HttpHeaders.ACCEPT)
                && !acceptHeaderValueRegex.matcher(header).matches()) {
            continue;
        } else {
            newHeaders.put(header, request.getRequestHeader(header));
        }
    }
    request.setHeaders(newHeaders);
    String acceptValue = request.getHeaderValue(org.apache.http.HttpHeaders.ACCEPT);
    if (acceptValue != null && !acceptHeaderValueRegex.matcher(acceptValue).matches()) {
        PersoniumCoreException exception = PersoniumCoreException.OData.BAD_REQUEST_HEADER_VALUE.params(
                org.apache.http.HttpHeaders.ACCEPT, acceptValue);
        throw exception;
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:30,代碼來源:PersoniumCoreContainerFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response)
{
	if (!isCorsNeeded(request))
		return response;

	MultivaluedMap<String, Object> headers = response.getHttpHeaders();

	headers.add("Access-Control-Allow-Origin", "*");
	headers.add("Access-Control-Allow-Methods", "GET, POST, OPTIONS");

	String acrh = request.getHeaderValue("Access-Control-Request-Headers");
	if (acrh != null && !acrh.isEmpty())
		headers.add("Access-Control-Allow-Headers", acrh);

	return response;
}
 
開發者ID:zach-m,項目名稱:gae-jersey-guice-jsf,代碼行數:18,代碼來源:CorsFilter.java

示例5: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(ContainerRequest request) {
	// Get session id from request header
	final String sessionId = request.getHeaderValue("session-id");

	SessionUser user = null;
	Session session = null;

	if (sessionId != null && sessionId.length() > 0) {
		// Load session object from repository
		// session = sessionRepository.findOne(sessionId);

		// Load associated user from session
		// if (session != null) {
		// // user = userRepository.findOne(session.getUserId());
		// }
	}

	request.setSecurityContext(new ElabSecurityContext(session, user));
	return request;
}
 
開發者ID:HuygensING,項目名稱:elaborate4-backend,代碼行數:22,代碼來源:SecurityContextFilterFactory.java

示例6: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest req,
		ContainerResponse contResp) {

	ResponseBuilder resp = Response.fromResponse(contResp.getResponse());
	resp.header("Access-Control-Allow-Origin", "*").header(
			"Access-Control-Allow-Methods", "GET, POST, OPTIONS");

	String reqHead = req.getHeaderValue("Access-Control-Request-Headers");

	if (null != reqHead && !reqHead.equals(null)) {
		resp.header("Access-Control-Allow-Headers", reqHead);
	}

	contResp.setResponse(resp.build());
	return contResp;
}
 
開發者ID:srdc,項目名稱:semanticMDR,代碼行數:18,代碼來源:ResponseCorsFilter.java

示例7: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    String incomingOrigin = request.getHeaderValue(CorsHeaders.ORIGIN);
    if (incomingOrigin == null) {
        return response;
    }

    MultivaluedMap<String, Object> h = response.getHttpHeaders();
    putIfNotPresent(h, CorsHeaders.ALLOW_ORIGIN, allowOrigin);
    putIfNotPresent(h, CorsHeaders.MAX_AGE, Integer.toString(maxAge));
    if (!allowMethods.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.ALLOW_METHODS, allowMethods);
    }
    if (!allowHeaders.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.ALLOW_HEADERS, allowHeaders);
    }
    if (allowCredentials) {
        putIfNotPresent(h, CorsHeaders.ALLOW_CREDENTIALS, Boolean.toString(allowCredentials));
    }
    return response;
}
 
開發者ID:palominolabs,項目名稱:jersey-cors-filter,代碼行數:22,代碼來源:CorsPreflightResponseResourceFilter.java

示例8: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    String incomingOrigin = request.getHeaderValue(CorsHeaders.ORIGIN);
    if (incomingOrigin == null) {
        return response;
    }

    MultivaluedMap<String, Object> h = response.getHttpHeaders();
    putIfNotPresent(h, CorsHeaders.ALLOW_ORIGIN, allowOrigin);
    if (!exposeHeaders.isEmpty()) {
        putIfNotPresent(h, CorsHeaders.EXPOSE_HEADERS, exposeHeaders);
    }
    if (allowCredentials) {
        putIfNotPresent(h, CorsHeaders.ALLOW_CREDENTIALS, Boolean.toString(allowCredentials));
    }
    return response;
}
 
開發者ID:palominolabs,項目名稱:jersey-cors-filter,代碼行數:18,代碼來源:CorsResourceResponseResourceFilter.java

示例9: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest request,
		ContainerResponse response) {

	ResponseBuilder responseBuilder = Response.fromResponse(response
			.getResponse());
	responseBuilder.header("Access-Control-Allow-Origin", "*").header(
			"Access-Control-Allow-Methods",
			"GET, POST, PUT, DELETE, OPTIONS");

	String requestHead = request
			.getHeaderValue("Access-Control-Request-Headers");

	if (null != requestHead && !requestHead.equals(null)) {
		responseBuilder.header("Access-Control-Allow-Headers", requestHead);
	}

	response.setResponse(responseBuilder.build());
	return response;
}
 
開發者ID:trustathsh,項目名稱:visitmeta,代碼行數:21,代碼來源:CrossOriginResourceSharingFilter.java

示例10: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(ContainerRequest req, ContainerResponse contResp) {
 
    ResponseBuilder resp = Response.fromResponse(contResp.getResponse());
    resp.header("Access-Control-Allow-Origin", "*")
        .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
 
    String reqHead = req.getHeaderValue("Access-Control-Request-Headers");
 
    if(null != reqHead && !reqHead.equals("")){
        resp.header("Access-Control-Allow-Headers", reqHead);
    }
 
    contResp.setResponse(resp.build());
    return contResp;
}
 
開發者ID:nextreports,項目名稱:nextreports-server,代碼行數:17,代碼來源:ResponseCorsFilter.java

示例11: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
    public ContainerRequest filter(ContainerRequest containerRequest) throws WebApplicationException {

//        String method = containerRequest.getMethod();
//        String path = containerRequest.getPath(true);
 
        String auth = containerRequest.getHeaderValue("authorization");
        if(auth == null){
            throw new WebApplicationException(Status.UNAUTHORIZED);
        }
 
        String[] credentials = decode(auth);
 
        if(credentials == null || credentials.length != 2){
            throw new WebApplicationException(Status.UNAUTHORIZED);
        }
 
        String uid = UserAuthentication.authenticate(credentials[0], credentials[1]);
 
        if(uid == null){
            throw new WebApplicationException(Status.UNAUTHORIZED);
        }
 
        containerRequest.getRequestHeaders().add("uid", uid);
        
        return containerRequest;
    }
 
開發者ID:NLPReViz,項目名稱:emr-nlp-server,代碼行數:28,代碼來源:AuthFilter.java

示例12: uriOverride

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
/**
 * Uriのオーバーライド処理.
 * @param request 加工するリクエスト
 */
private void uriOverride(final ContainerRequest request) {
    String xForwardedProto = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PROTO);
    String xForwardedHost = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_HOST);
    String xForwardedPath = request.getHeaderValue(PersoniumCoreUtils.HttpHeaders.X_FORWARDED_PATH);

    UriBuilder bub = request.getBaseUriBuilder();
    UriBuilder rub = request.getRequestUriBuilder();

    if (xForwardedProto != null) {
        bub.scheme(xForwardedProto);
        rub.scheme(xForwardedProto);
    }
    if (xForwardedHost != null) {
        bub.host(xForwardedHost);
        rub.host(xForwardedHost);
    }
    if (xForwardedPath != null) {
        bub.replacePath("/");
        // クエリを含んでいる場合は、クエリを削除してリクエストパスに設定する
        if (xForwardedPath.contains("?")) {
            xForwardedPath = xForwardedPath.substring(0, xForwardedPath.indexOf("?"));
        }
        rub.replacePath(xForwardedPath);
    }
    request.setUris(bub.build(), rub.build());
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:31,代碼來源:PersoniumCoreContainerFilter.java

示例13: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerResponse filter(final ContainerRequest req, final ContainerResponse cres) {
    Response.ResponseBuilder resp = Response.fromResponse(cres.getResponse());
    resp.header("Access-Control-Allow-Origin", "*")
            .header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");

    String reqHead = req.getHeaderValue("Access-Control-Request-Headers");
    System.out.println("Head:" + reqHead);
    if(null != reqHead && !reqHead.equals("")){
        resp.header("Access-Control-Allow-Headers", reqHead);
    }

    cres.setResponse(resp.build());
    return cres;
}
 
開發者ID:btrplace,項目名稱:playd,代碼行數:16,代碼來源:CORSFilter.java

示例14: supportsRequestedVersion

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public boolean supportsRequestedVersion(boolean headerRequired, float minVersion, float maxVersion, ContainerRequest request) {
    boolean isSupported = true;
    String versionHeader = request.getHeaderValue(versionHeaderName);
    if (headerRequiredButNotPresent(headerRequired, versionHeader) || headerPresentButNotSupported(minVersion, maxVersion, versionHeader)) {
        isSupported = false;
    }
    return isSupported;
}
 
開發者ID:rridgley1,項目名稱:agon,代碼行數:10,代碼來源:DefaultApiVersionMatcher.java

示例15: filter

import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(ContainerRequest request) {
	// OPTIONS calls don't need authorization, apparently
	if ("OPTIONS".equals(request.getMethod())) {
		return request;
	}

	// Authentication via header or cookie
	String authentication = request.getHeaderValue(HEADER);
	if (StringUtils.isBlank(authentication)) {
		Cookie cookie = request.getCookies().get(HEADER);
		if (cookie != null) {
			authentication = cookie.getValue();
		}
	}
	// Log.info("authentication={}", authentication);
	if (StringUtils.isNotBlank(authentication)) {
		List<String> parts = Lists.newArrayList(Splitter.on(" ").split(authentication));
		if (parts.size() == 2) {
			String scheme = parts.get(0);
			String key = parts.get(1);
			try {
				SecurityContext securityContext = sessionService.getSecurityContext(scheme, key);
				if (securityContext != null) {
					request.setSecurityContext(securityContext);
					return request;
				}
			} catch (nl.knaw.huygens.security.client.UnauthorizedException e) {
				throw new UnauthorizedException(e.getMessage());
			}
		}
	} else {

	}
	throw new UnauthorizedException("No valid " + HEADER + " header in request");
}
 
開發者ID:HuygensING,項目名稱:elaborate4-backend,代碼行數:37,代碼來源:AuthenticationResourceFilter.java


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