• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java WebSubjectContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.shiro.web.subject.WebSubjectContext的典型用法代码示例。如果您正苦于以下问题:Java WebSubjectContext类的具体用法?Java WebSubjectContext怎么用?Java WebSubjectContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebSubjectContext类属于org.apache.shiro.web.subject包,在下文中一共展示了WebSubjectContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createSubject

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
public Subject createSubject(SubjectContext context) {
    if (!(context instanceof WebSubjectContext)) {
        return super.createSubject(context);
    }
    WebSubjectContext wsc = (WebSubjectContext) context;
    SecurityManager securityManager = wsc.resolveSecurityManager();
    Session session = wsc.resolveSession();
    boolean sessionEnabled = wsc.isSessionCreationEnabled();
    PrincipalCollection principals = wsc.resolvePrincipals();
    boolean authenticated = wsc.resolveAuthenticated();
    String host = wsc.resolveHost();
    ServletRequest request = wsc.resolveServletRequest();
    ServletResponse response = wsc.resolveServletResponse();

    return new WebDelegatingSubject(principals, authenticated, host, session, sessionEnabled,
            request, response, securityManager);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:18,代码来源:DefaultWebSubjectFactory.java


示例2: createSessionContext

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
@Override
protected SessionContext createSessionContext(SubjectContext subjectContext) {
    SessionContext sessionContext = super.createSessionContext(subjectContext);
    if (subjectContext instanceof WebSubjectContext) {
        WebSubjectContext wsc = (WebSubjectContext) subjectContext;
        ServletRequest request = wsc.resolveServletRequest();
        ServletResponse response = wsc.resolveServletResponse();
        DefaultWebSessionContext webSessionContext = new DefaultWebSessionContext(sessionContext);
        if (request != null) {
            webSessionContext.setServletRequest(request);
        }
        if (response != null) {
            webSessionContext.setServletResponse(response);
        }

        sessionContext = webSessionContext;
    }
    return sessionContext;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:20,代码来源:DefaultWebSecurityManager.java


示例3: createSessionContext

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
@Override
protected SessionContext createSessionContext(SubjectContext subjectContext) {
	SessionContext sessionContext = super
			.createSessionContext(subjectContext);
	if (subjectContext instanceof WebSubjectContext) {
		WebSubjectContext wsc = (WebSubjectContext) subjectContext;
		ServletRequest request = wsc.resolveServletRequest();
		ServletResponse response = wsc.resolveServletResponse();
		DefaultWebSessionContext webSessionContext = new DefaultWebSessionContext(
				sessionContext);
		if (request != null) {
			webSessionContext.setServletRequest(request);
		}
		if (response != null) {
			webSessionContext.setServletResponse(response);
		}

		sessionContext = webSessionContext;
	}
	return sessionContext;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:22,代码来源:SimpleWebSecurityManager.java


示例4: createSubject

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
/**
 * {@inheritDoc} <br />
 * Original code taken from {@link DefaultWebSubjectFactory} and modified
 * in order to return {@link SodaWebDelegatingSubject} instances.
 */
@Override
public Subject createSubject( SubjectContext context ) {
	if ( !(context instanceof WebSubjectContext) ) {
		return super.createSubject( context );
	}
	WebSubjectContext wsc = (WebSubjectContext) context;
	SecurityManager securityManager = wsc.resolveSecurityManager();
	Session session = wsc.resolveSession();
	boolean sessionEnabled = wsc.isSessionCreationEnabled();
	PrincipalCollection principals = wsc.resolvePrincipals();
	boolean authenticated = wsc.resolveAuthenticated();
	String host = wsc.resolveHost();
	ServletRequest request = wsc.resolveServletRequest();
	ServletResponse response = wsc.resolveServletResponse();

	return new SodaWebDelegatingSubject( principals, authenticated, host, session, sessionEnabled, request, response, securityManager );
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:23,代码来源:SodaSubjectFactory.java


示例5: createSubject

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
@Override
public Subject createSubject(SubjectContext context) {
    WebSubjectContext wsc = (WebSubjectContext) context;
    AuthenticationInfo info = wsc.getAuthenticationInfo();

    AccountProfile profile = null;
    AccountSubject subject = null;
    if (info instanceof AccountAuthenticationInfo) {
    	profile = ((AccountAuthenticationInfo) info).getProfile();
        subject = doCreate(wsc, profile);
        subject.getSession(true).setAttribute("profile", profile);
    }else{
        Session session = wsc.getSession();
        if(session != null){
        	profile = (AccountProfile)session.getAttribute("profile");
        }
        subject = doCreate(wsc, profile);
        boolean isRemembered = subject.isRemembered();
        if (session == null) {
            wsc.setSessionCreationEnabled(true);
            subject.getSession(true);
        }
        if (isRemembered && profile == null) {
            Object username = subject.getPrincipal();
            profile = userService.getProfileByName((String) username);
            
            subject.getSession(true).setTimeout(30 * 60 * Consts.TIME_MIN);
            subject.getSession(true).setAttribute("profile", profile);
        }
    }
    

    return doCreate(wsc, profile);
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:35,代码来源:AccountSubjectFactory.java


示例6: isIdentityRemoved

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
private boolean isIdentityRemoved(WebSubjectContext subjectContext) {
    ServletRequest request = subjectContext.resolveServletRequest();
    if (request != null) {
        Boolean removed = (Boolean) request.getAttribute(ShiroHttpServletRequest.IDENTITY_REMOVED_KEY);
        return removed != null && removed;
    }
    return false;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:9,代码来源:CookieRememberMeManager.java


示例7: copy

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
@Override
protected SubjectContext copy(SubjectContext subjectContext) {
    if (subjectContext instanceof WebSubjectContext) {
        return new DefaultWebSubjectContext((WebSubjectContext) subjectContext);
    }
    return super.copy(subjectContext);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:8,代码来源:DefaultWebSecurityManager.java


示例8: copy

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
@Override
protected SubjectContext copy(SubjectContext subjectContext) {
	if (subjectContext instanceof WebSubjectContext) {
		return new DefaultWebSubjectContext(
				(WebSubjectContext) subjectContext);
	}
	return super.copy(subjectContext);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:9,代码来源:SimpleWebSecurityManager.java


示例9: doCreate

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
private AccountSubject doCreate(WebSubjectContext wsc, AccountProfile profile) {
    return new AccountSubject(wsc.resolvePrincipals(), wsc.resolveAuthenticated(), wsc.resolveHost(),
            wsc.resolveSession(), wsc.isSessionCreationEnabled(), wsc.resolveServletRequest(),
            wsc.resolveServletResponse(), wsc.resolveSecurityManager(), profile);
}
 
开发者ID:ThomasYangZi,项目名称:mblog,代码行数:6,代码来源:AccountSubjectFactory.java


示例10: DefaultWebSubjectContext

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
public DefaultWebSubjectContext(WebSubjectContext context) {
    super(context);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:4,代码来源:DefaultWebSubjectContext.java


示例11: getRememberedSerializedIdentity

import org.apache.shiro.web.subject.WebSubjectContext; //导入依赖的package包/类
/**
 * Returns a previously serialized identity byte array or {@code null} if the byte array could not be acquired.
 * This implementation retrieves an HTTP cookie, Base64-decodes the cookie value, and returns the resulting byte
 * array.
 * <p/>
 * The {@code SubjectContext} instance is expected to be a {@link WebSubjectContext} instance with an HTTP
 * Request/Response pair so an HTTP cookie can be retrieved from the incoming request.  If it is not a
 * {@code WebSubjectContext} or that {@code WebSubjectContext} does not have an HTTP Request/Response pair, this
 * implementation returns {@code null}.
 *
 * @param subjectContext the contextual data, usually provided by a {@link Subject.Builder} implementation, that
 *                       is being used to construct a {@link Subject} instance.  To be used to assist with data
 *                       lookup.
 * @return a previously serialized identity byte array or {@code null} if the byte array could not be acquired.
 */
protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) {

    if (!WebUtils.isHttp(subjectContext)) {
        if (log.isDebugEnabled()) {
            String msg = "SubjectContext argument is not an HTTP-aware instance.  This is required to obtain a " +
                    "servlet request and response in order to retrieve the rememberMe cookie. Returning " +
                    "immediately and ignoring rememberMe operation.";
            log.debug(msg);
        }
        return null;
    }

    WebSubjectContext wsc = (WebSubjectContext) subjectContext;
    if (isIdentityRemoved(wsc)) {
        return null;
    }

    HttpServletRequest request = WebUtils.getHttpRequest(wsc);
    HttpServletResponse response = WebUtils.getHttpResponse(wsc);

    String base64 = getCookie().readValue(request, response);
    // Browsers do not always remove cookies immediately (SHIRO-183)
    // ignore cookies that are scheduled for removal
    if (Cookie.DELETED_COOKIE_VALUE.equals(base64)) return null;

    if (base64 != null) {
        base64 = ensurePadding(base64);
        if (log.isTraceEnabled()) {
            log.trace("Acquired Base64 encoded identity [" + base64 + "]");
        }
        byte[] decoded = Base64.decode(base64);
        if (log.isTraceEnabled()) {
            log.trace("Base64 decoded byte array length: " + (decoded != null ? decoded.length : 0) + " bytes.");
        }
        return decoded;
    } else {
        //no cookie set - new site visitor?
        return null;
    }
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:56,代码来源:CookieRememberMeManager.java



注:本文中的org.apache.shiro.web.subject.WebSubjectContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Sine类代码示例发布时间:2022-05-22
下一篇:
Java Util类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap