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


Java ContainerRequestContext.getProperty方法代碼示例

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


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

示例1: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
        throws IOException {
    String origin = requestContext.getHeaderString(ORIGIN);
    if (origin == null || requestContext.getMethod().equalsIgnoreCase("OPTIONS")
            || requestContext.getProperty("cors.failure") != null) {
        // don't do anything if origin is null, its an OPTIONS request, or cors.failure is set
        return;
    }
    responseContext.getHeaders().putSingle(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
    if (allowCredentials)
        responseContext.getHeaders().putSingle(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");

    if (exposedHeaders != null) {
        responseContext.getHeaders().putSingle(ACCESS_CONTROL_EXPOSE_HEADERS, exposedHeaders);
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:18,代碼來源:CorsFilter.java

示例2: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext) {
    if (requestContext instanceof ContainerRequest) {

        final Principal principal = (Principal) requestContext.getProperty("Principal");
        if (principal == null) {
            requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build());
            return;
        }

        final PermissionRequired annotation = resourceInfo.getResourceMethod().getDeclaredAnnotation(PermissionRequired.class);

        try (AlpineQueryManager qm = new AlpineQueryManager()) {
            if (principal instanceof LdapUser) {
                final LdapUser user = qm.getLdapUser(((LdapUser) principal).getUsername());

                final String[] permissions = annotation.value();
                for (String permission: permissions) {
                    // todo check if user has one of these required permissions
                }
            }
        }
    }
}
 
開發者ID:stevespringett,項目名稱:Alpine,代碼行數:25,代碼來源:AuthorizationFilter.java

示例3: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
    if (!shouldFilter(requestContext, resourceInfo)) {
        // do nothing if the filter doesn't apply
        return;
    }

    try {
        Span span = (Span) requestContext.getProperty(SERVER_SPAN_CONTEXT_KEY);
        if (span != null) {
            span.setTag(Tags.HTTP_STATUS.getKey(), responseContext.getStatus());
            span.finish();
        }
    } catch (Exception e) {
        LOGGER.error("Server Response Filter failed", e);
    }
}
 
開發者ID:ExpediaDotCom,項目名稱:haystack-client-java,代碼行數:18,代碼來源:ServerFilter.java

示例4: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public void filter(
    ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws
    IOException {
  MDC.remove(mdcName);
  String correlationId = (String) requestContext.getProperty(mdcName);
  if (correlationId == null) { // Can happen if there are oauth issues.
    correlationId = UUID.randomUUID().toString();
  }
  responseContext.getHeaders().add(headerName, correlationId);
}
 
開發者ID:cerner,項目名稱:beadledom,代碼行數:12,代碼來源:CorrelationIdFilter.java

示例5: get

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public Object get(final String name,
    final ObjectFactory<?> objectFactory) {

    final ContainerRequestContext containerRequest = containerRequestHolder.get();
    Object scopedObject = containerRequest.getProperty(name);
    if (scopedObject == null) {
        scopedObject = objectFactory.getObject();
        containerRequest.setProperty(name, scopedObject);
    }
    return scopedObject;
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:13,代碼來源:ContainerRequestScope.java

示例6: remove

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public Object remove(final String name) {

    final ContainerRequestContext containerRequest = containerRequestHolder.get();
    final Object scopedObject = containerRequest.getProperty(name);
    if (scopedObject != null) {
        containerRequest.removeProperty(name);

        getDestructionCallbacks(containerRequest).remove(name);
        return scopedObject;
    } else {
        return null;
    }
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:15,代碼來源:ContainerRequestScope.java

示例7: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@SuppressWarnings("nls")
@Override
public void filter(ContainerRequestContext context) throws IOException
{
	ResourceMethodInvoker invoker = (ResourceMethodInvoker) context.getProperty(ResourceMethodInvoker.class
		.getName());
	Class<?> clazz = invoker.getResourceClass();
	Institutional.Type instType = Institutional.Type.INSTITUTIONAL;
	Institutional instanno = clazz.getAnnotation(Institutional.class);
	if( instanno != null )
	{
		instType = instanno.value();
	}
	boolean hasInst = CurrentInstitution.get() != null;
	if( instType != Institutional.Type.BOTH && (hasInst != (instType == Institutional.Type.INSTITUTIONAL)) )
	{
		throw new NotFoundException();
	}
	// Class or calling method system restricted?
	SecureOnCallSystem system = clazz.getAnnotation(SecureOnCallSystem.class);
	if( system == null )
	{
		system = invoker.getMethod().getAnnotation(SecureOnCallSystem.class);
	}
	if( system != null && !CurrentUser.getUserState().isSystem() )
	{
		throw new AccessDeniedException("You do not have the privileges to access this endpoint");
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:30,代碼來源:InstitutionSecurityFilter.java

示例8: filter

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ContainerRequestContext request) {
    MDC.put(USERNAME, getUsername(servletRequest));

    if (request.getProperty(START_TIME) == null) {
        request.setProperty(START_TIME, System.currentTimeMillis());
    } else {
        log.warn("{} is already set -- possible configuration error", START_TIME);
    }
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:11,代碼來源:SimpleAccessLoggingFilter.java

示例9: getDestructionCallbacks

import javax.ws.rs.container.ContainerRequestContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private static Map<String, Runnable> getDestructionCallbacks(@NotNull final ContainerRequestContext containerRequest) {

    return (Map<String, Runnable>) containerRequest.getProperty(DESTRUCTION_CALLBACK_PROPERTY);
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:6,代碼來源:ContainerRequestScope.java


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