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