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


Java ContainerRequest.getMethod方法代码示例

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


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

示例1: 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

示例2: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest req) {
	
	if (log.isTraceEnabled()) {
		String baseUri = req.getBaseUri().getPath();
		String method = req.getMethod();
		String path = req.getPath();
		MediaType mediaType = req.getMediaType();
		
		String dbg = Strings.of("\r\nRESTEndPoint: {}"  +														
				  				"\r\n---------------------------------------------------------------------"  +				
				  				"\r\n       Method: {}"  +
				  				"\r\n        Path: {}" + 
				  				"\r\nContent-Type: {}" +
				  				"\r\n---------------------------------------------------------------------")
				  			.customizeWith(baseUri,
				  					       method,
				  					       path,
				  					       mediaType != null ? mediaType
				  					    		   			 : "not specified")
				  			.asString();
		log.trace(dbg);
	}
	return req;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:26,代码来源:RESTLogRequestFilter.java

示例3: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.info(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.info(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:lemo2,代码行数:21,代码来源:RequestLoggingFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(ContainerRequest containerRequest) {
    String method = containerRequest.getMethod();
    Object isAgent = httpServletRequest.getAttribute(X_MONASCA_AGENT);
    String pathInfo = httpServletRequest.getPathInfo();

    // X_MONASCA_AGENT is only set if the only valid role for this user is an agent role
    if (isAgent != null) {
        if (!(method.equals("POST") && validPath(pathInfo, VALID_MONASCA_AGENT_POST_PATHS)) && 
            !(method.equals("GET") && validPath(pathInfo, VALID_MONASCA_AGENT_GET_PATHS))) { 
            logger.warn("User {} is missing a required role to {} on {}",
                                                httpServletRequest.getAttribute(AuthConstants.AUTH_USER_NAME),
                                                method, pathInfo);
            throw Exceptions.badRequest("User is missing a required role to perform this request");
        }
    }
    return containerRequest;
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:19,代码来源:RoleAuthorizationFilter.java

示例5: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
@Override
public ContainerRequest filter(final ContainerRequest request) {
	if (logger.isInfoEnabled()) {
		String requestInfo = request.getPath() + " (" + request.getMethod() +
				(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
		logger.debug(requestInfo);

		StringBuilder parameters = new StringBuilder("Params: ");
		Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
		for (Entry<String, List<String>> parameter : entrySet) {
			parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
		}
		if (!entrySet.isEmpty()) {
			parameters.setLength(parameters.length() - ", ".length());
			logger.debug(parameters.toString());
		}

	}
	return request;
}
 
开发者ID:LemoProject,项目名称:Lemo-Data-Management-Server,代码行数:21,代码来源:RequestLoggingFilter.java

示例6: filter

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
/**
 * Apply the authentication filter to the incoming ContainerRequest
 * @param request is the incoming ContainerRequest
 * @return
 */
@Override
public ContainerRequest filter(ContainerRequest containerRequest) {

    System.out.println("AuthFilterController: Filtering request for Basic authorization....");

    /// Store the request method (e.g. GET, POST, PUT, or DELETE)
    String method = containerRequest.getMethod();

    /// Store the request path (e.g. "/vert/song/upload")
    String path = containerRequest.getPath(true);

    System.out.println("AuthFilterController: Method=" + method + " Path=" + path);

    /// Allow access to the WADL (Web Application Description Language) which
    /// describes the structure of the web application's resources.
    if (method.equals("GET") && (path.equals("application.wadl") || path.equals("application.wadl/xsd0.xsd"))) {
        System.out.println("AuthFilterController: Access granted to WADL");
        return containerRequest;
    } else if (method.equals("POST") && path.endsWith("data/users")) {
        System.out.println("AuthFilterController: Access granted to registering User");
        return containerRequest;
    } else if (method.equals("POST") && path.endsWith("data/session")) {
        System.out.println("AuthFilterController: Access granted to login for user");
        return containerRequest;
    } else if (method.equals("GET") && path.contains("data/activates")) {
        System.out.println("AuthFilterController: Access granted to user account activation");
        return containerRequest;
    } else if (method.equals("GET") && path.contains("file/song")) {
        System.out.println("AuthFilterController: Access granted to file download/streaming");
        return containerRequest;
    }

    /// Get the authentication passed in the HTTP headers, if it does not
    /// exist then throw an unauthorized exception
    String auth = containerRequest.getHeaderValue("authorization");
    String[] loginInfo = BasicAuth.decode(auth);
    if (loginInfo == null || loginInfo.length != 2) {
        System.out.println("AuthFilterController: Unauthorized access - no login info found");
        throw new WebApplicationException(Status.UNAUTHORIZED);
    }

    /// Retrieve user from the database, and check if one exists under the provided auth info
    User user = userService.authenticate(loginInfo[0], loginInfo[1]);
    if (user == null) {
        System.out.println("AuthFilterController: Unauthorized access - no match for user/password");
        throw new WebApplicationException(Status.UNAUTHORIZED);
    }

    /// Set user context in HttpServletRequest
    servletRequest.setAttribute(User.LOGGED_USER, user);
    System.out.println("AuthFilterController: Authorized access - " + user);
    return containerRequest;
}
 
开发者ID:VertMusic,项目名称:vert_backend,代码行数:59,代码来源:AuthFilterController.java

示例7: build

import com.sun.jersey.spi.container.ContainerRequest; //导入方法依赖的package包/类
public static CacheRequestContext build(ContainerRequest request, Set<String> vary, boolean includeBody) {
    try {
        MessageDigest digest = MessageDigest.getInstance("SHA-1");

        for (String header : vary) {
            List<String> headerValues = request.getRequestHeader(header);

            if (headerValues != null && headerValues.size() > 0) {
                digest.update(header.getBytes(Charsets.UTF_8));
                digest.update((byte) 0xFD);

                for (String value : headerValues) {
                    digest.update(value.getBytes(Charsets.UTF_8));
                    digest.update((byte) 0xFE);
                }

                digest.update((byte) 0xFF);
            }
        }

        if (includeBody) {
            byte[] requestBody = request.getEntity(byte[].class);

            if (requestBody == null) {
                requestBody = new byte[0];
            }

            if (requestBody.length > 0) {
                digest.update("Body".getBytes(Charsets.UTF_8));
                digest.update((byte) 0xFD);

                digest.update(requestBody);
                digest.update((byte) 0xFF);
            }

            request.setEntityInputStream(new ByteArrayInputStream(requestBody));
        }

        String hash = new String(Base64.encode(digest.digest()), Charsets.US_ASCII);
        return new CacheRequestContext(request.getMethod(), request.getRequestUri(), request.getRequestHeaders(), hash);
    } catch (NoSuchAlgorithmException ex) {
        // This error should not occur since SHA-1 must be included with every java distribution
        throw Throwables.propagate(ex);
    }
}
 
开发者ID:bazaarvoice,项目名称:dropwizard-caching-bundle,代码行数:46,代码来源:CacheRequestContext.java


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