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


Java ContainerRequestContext.getSecurityContext方法代码示例

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


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

示例1: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(final ContainerRequestContext ctx) throws IOException {
    final SecurityContext sec = ctx.getSecurityContext();
    LOGGER.debug("Checking security context: {}", sec.getUserPrincipal());
    if (isNull(sec.getUserPrincipal())) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession());
    } else if (adminUsers.contains(sec.getUserPrincipal().getName())) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession(AdministratorAgent));
    } else if (sec.getUserPrincipal().getName().isEmpty()) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession());
    } else {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession(agentService.asAgent(sec.getUserPrincipal().getName())));
    }
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:15,代码来源:AgentAuthorizationFilter.java

示例2: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(final ContainerRequestContext ctx) throws IOException {

    if (nonNull(ctx.getHeaders().getFirst(HttpHeaders.AUTHORIZATION))) {
        throw new WebApplicationException(unauthorizedHandler.buildResponse(prefix, realm));
    }

    final SecurityContext securityContext = ctx.getSecurityContext();
    final boolean secure = securityContext != null && securityContext.isSecure();

    ctx.setSecurityContext(new SecurityContext() {
        @Override
        public Principal getUserPrincipal() {
            return new PrincipalImpl(Trellis.AnonymousAgent.getIRIString());
        }

        @Override
        public boolean isUserInRole(final String role) {
            return false;
        }

        @Override
        public boolean isSecure() {
            return secure;
        }

        @Override
        public String getAuthenticationScheme() {
            return "NONE";
        }
    });
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:33,代码来源:AnonymousAuthFilter.java

示例3: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
/**
 * Filter method called after a response has been provided for a request.
 * This method will refresh the session of the current token and put in the header with the key Authorization
 *
 * @param requestContext  request context.
 * @param responseContext response context.
 * @throws IOException if an I/O exception occurs.
 */
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {

    if (requestContext.getSecurityContext() != null && requestContext.getSecurityContext().getUserPrincipal() != null) {

        responseContext.getHeaders().add(HttpHeaders.AUTHORIZATION,
                this.jwtService.generateToken((JWTPrincipal) requestContext.getSecurityContext().getUserPrincipal()).getToken());
    }
}
 
开发者ID:Crunchy-Torch,项目名称:coddy,代码行数:18,代码来源:TokenResponseFilter.java

示例4: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext context) throws IOException {
    SecurityContext securityContext = context.getSecurityContext();
    ResteasyProviderFactory.pushContext(Principal.class, securityContext.getUserPrincipal());
}
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:6,代码来源:UserPrincipalContextFilter.java

示例5: provideValue

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public SecurityContext provideValue(Parameter parameter, ContainerRequestContext requestContext, ObjectMapper objectMapper) {
	return requestContext.getSecurityContext();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:5,代码来源:SecurityContextProvider.java


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