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