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