`
karlhell
  • 浏览: 106564 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Spring Security 2 配置精讲 下

    博客分类:
  • SSH
阅读更多
  2. 在系统启动的时候,把所有的资源load到内存作为缓存

  由于资源信息对于每个项目来说,相对固定,所以我们可以将他们在系统启动的时候就load到内存作为缓存。这里做法很多,我给出的示例是将资源的存放在servletContext中。

  Java代码

public class ServletContextLoaderListener implements ServletContextListener {   
  
    /* (non-Javadoc)  
     * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)  
     */  
    public void contextInitialized(ServletContextEvent servletContextEvent) {   
        ServletContext servletContext = servletContextEvent.getServletContext();   
        SecurityManager securityManager = this.getSecurityManager(servletContext);   
           
        Map<String, String> urlAuthorities = securityManager.loadUrlAuthorities();   
        servletContext.setAttribute("urlAuthorities", urlAuthorities);   
    }   
  
       
    /* (non-Javadoc)  
     * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)  
     */  
    public void contextDestroyed(ServletContextEvent servletContextEvent) {   
        servletContextEvent.getServletContext().removeAttribute("urlAuthorities");   
    }   
  
    /**  
     * Get SecurityManager from ApplicationContext  
     *   
     * @param servletContext  
     * @return  
     */  
    protected SecurityManager getSecurityManager(ServletContext servletContext) {   
       return (SecurityManager) WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("securityManager");    
    }   
  
}  

public class ServletContextLoaderListener implements ServletContextListener {

    /* (non-Javadoc)
     * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        ServletContext servletContext = servletContextEvent.getServletContext();
        SecurityManager securityManager = this.getSecurityManager(servletContext);
        
        Map<String, String> urlAuthorities = securityManager.loadUrlAuthorities();
        servletContext.setAttribute("urlAuthorities", urlAuthorities);
    }

    
    /* (non-Javadoc)
     * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        servletContextEvent.getServletContext().removeAttribute("urlAuthorities");
    }

    /**
     * Get SecurityManager from ApplicationContext
     * 
     * @param servletContext
     * @return
     */
    protected SecurityManager getSecurityManager(ServletContext servletContext) {
       return (SecurityManager) WebApplicationContextUtils.getWebApplicationContext(servletContext).getBean("securityManager"); 
    }

}


  这里,我们看到了SecurityManager,这是一个接口,用于权限相关的逻辑处理。还记得之前我们使用数据库管理User的时候所使用的一个实现类SecurityManagerSupport嘛?我们不妨依然借用这个类,让它实现SecurityManager接口,来同时完成url的读取工作。

  Java代码
@Service("securityManager")   
public class SecurityManagerSupport extends HibernateDaoSupport implements UserDetailsService, SecurityManager {   
       
    /**  
     * Init sessionFactory here because the annotation of Spring 2.5 can not support override inject  
     *    
     * @param sessionFactory  
     */  
    @Autowired  
    public void init(SessionFactory sessionFactory) {   
        super.setSessionFactory(sessionFactory);   
    }   
       
    /* (non-Javadoc)  
     * @see org.springframework.security.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)  
     */  
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException, DataAccessException {   
        List<User> users = getHibernateTemplate().find("FROM User user WHERE user.name = ? AND user.disabled = false", userName);   
        if(users.isEmpty()) {   
            throw new UsernameNotFoundException("User " + userName + " has no GrantedAuthority");   
        }   
        return users.get(0);   
    }   
       
    /* (non-Javadoc)  
     * @see com.javaeye.sample.security.SecurityManager#loadUrlAuthorities()  
     */  
    public Map<String, String> loadUrlAuthorities() {   
        Map<String, String> urlAuthorities = new HashMap<String, String>();   
        List<Resource> urlResources = getHibernateTemplate().find("FROM Resource resource WHERE resource.type = ?", "URL");   
        for(Resource resource : urlResources) {   
            urlAuthorities.put(resource.getValue(), resource.getRoleAuthorities());   
        }   
        return urlAuthorities;   
    }      
}  

@Service("securityManager")
public class SecurityManagerSupport extends HibernateDaoSupport implements UserDetailsService, SecurityManager {
    
    /**
     * Init sessionFactory here because the annotation of Spring 2.5 can not support override inject
     *  
     * @param sessionFactory
     */
    @Autowired
    public void init(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }
    
    /* (non-Javadoc)
     * @see org.springframework.security.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
     */
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException, DataAccessException {
        List<User> users = getHibernateTemplate().find("FROM User user WHERE user.name = ? AND user.disabled = false", userName);
        if(users.isEmpty()) {
            throw new UsernameNotFoundException("User " + userName + " has no GrantedAuthority");
        }
        return users.get(0);
    }
    
    /* (non-Javadoc)
     * @see com.javaeye.sample.security.SecurityManager#loadUrlAuthorities()
     */
    public Map<String, String> loadUrlAuthorities() {
        Map<String, String> urlAuthorities = new HashMap<String, String>();
        List<Resource> urlResources = getHibernateTemplate().find("FROM Resource resource WHERE resource.type = ?", "URL");
        for(Resource resource : urlResources) {
            urlAuthorities.put(resource.getValue(), resource.getRoleAuthorities());
        }
        return urlAuthorities;
    }   
}


  3. 编写自己的FilterInvocationDefinitionSource实现类,对资源进行认证

  Java代码

public class SecureResourceFilterInvocationDefinitionSource implements FilterInvocationDefinitionSource, InitializingBean {   
       
    private UrlMatcher urlMatcher;   
  
    private boolean useAntPath = true;   
       
    private boolean lowercaseComparisons = true;   
       
    /**  
     * @param useAntPath the useAntPath to set  
     */  
    public void setUseAntPath(boolean useAntPath) {   
        this.useAntPath = useAntPath;   
    }   
       
    /**  
     * @param lowercaseComparisons  
     */  
    public void setLowercaseComparisons(boolean lowercaseComparisons) {   
        this.lowercaseComparisons = lowercaseComparisons;   
    }   
       
    /* (non-Javadoc)  
     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()  
     */  
    public void afterPropertiesSet() throws Exception {   
           
        // default url matcher will be RegexUrlPathMatcher   
        this.urlMatcher = new RegexUrlPathMatcher();   
           
        if (useAntPath) {  // change the implementation if required   
            this.urlMatcher = new AntUrlPathMatcher();   
        }   
           
        // Only change from the defaults if the attribute has been set   
        if ("true".equals(lowercaseComparisons)) {   
            if (!this.useAntPath) {   
                ((RegexUrlPathMatcher) this.urlMatcher).setRequiresLowerCaseUrl(true);   
            }   
        } else if ("false".equals(lowercaseComparisons)) {   
            if (this.useAntPath) {   
                ((AntUrlPathMatcher) this.urlMatcher).setRequiresLowerCaseUrl(false);   
            }   
        }   
           
    }   
       
    /* (non-Javadoc)  
     * @see org.springframework.security.intercept.ObjectDefinitionSource#getAttributes(java.lang.Object)  
     */  
    public ConfigAttributeDefinition getAttributes(Object filter) throws IllegalArgumentException {   
           
        FilterInvocation filterInvocation = (FilterInvocation) filter;   
        String requestURI = filterInvocation.getRequestUrl();   
        Map<String, String> urlAuthorities = this.getUrlAuthorities(filterInvocation);   
           
        String grantedAuthorities = null;   
        for(Iterator<Map.Entry<String, String>> iter = urlAuthorities.entrySet().iterator(); iter.hasNext();) {   
            Map.Entry<String, String> entry = iter.next();   
            String url = entry.getKey();   
               
            if(urlMatcher.pathMatchesUrl(url, requestURI)) {   
                grantedAuthorities = entry.getValue();   
                break;   
            }   
               
        }   
           
        if(grantedAuthorities != null) {   
            ConfigAttributeEditor configAttrEditor = new ConfigAttributeEditor();   
            configAttrEditor.setAsText(grantedAuthorities);   
            return (ConfigAttributeDefinition) configAttrEditor.getValue();   
        }   
           
        return null;   
    }   
  
    /* (non-Javadoc)  
     * @see org.springframework.security.intercept.ObjectDefinitionSource#getConfigAttributeDefinitions()  
     */  
    @SuppressWarnings("unchecked")   
    public Collection getConfigAttributeDefinitions() {   
        return null;   
    }   
  
    /* (non-Javadoc)  
     * @see org.springframework.security.intercept.ObjectDefinitionSource#supports(java.lang.Class)  
     */  
    @SuppressWarnings("unchecked")   
    public boolean supports(Class clazz) {   
        return true;   
    }   
       
    /**  
     *   
     * @param filterInvocation  
     * @return  
     */  
    @SuppressWarnings("unchecked")   
    private Map<String, String> getUrlAuthorities(FilterInvocation filterInvocation) {   
        ServletContext servletContext = filterInvocation.getHttpRequest().getSession().getServletContext();   
        return (Map<String, String>)servletContext.getAttribute("urlAuthorities");   
    }   
  
}  

public class SecureResourceFilterInvocationDefinitionSource implements FilterInvocationDefinitionSource, InitializingBean {
    
    private UrlMatcher urlMatcher;

    private boolean useAntPath = true;
    
    private boolean lowercaseComparisons = true;
    
    /**
     * @param useAntPath the useAntPath to set
     */
    public void setUseAntPath(boolean useAntPath) {
        this.useAntPath = useAntPath;
    }
    
    /**
     * @param lowercaseComparisons
     */
    public void setLowercaseComparisons(boolean lowercaseComparisons) {
        this.lowercaseComparisons = lowercaseComparisons;
    }
    
    /* (non-Javadoc)
     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
     */
    public void afterPropertiesSet() throws Exception {
        
        // default url matcher will be RegexUrlPathMatcher
        this.urlMatcher = new RegexUrlPathMatcher();
        
        if (useAntPath) {  // change the implementation if required
            this.urlMatcher = new AntUrlPathMatcher();
        }
        
        // Only change from the defaults if the attribute has been set
        if ("true".equals(lowercaseComparisons)) {
            if (!this.useAntPath) {
                ((RegexUrlPathMatcher) this.urlMatcher).setRequiresLowerCaseUrl(true);
            }
        } else if ("false".equals(lowercaseComparisons)) {
            if (this.useAntPath) {
                ((AntUrlPathMatcher) this.urlMatcher).setRequiresLowerCaseUrl(false);
            }
        }
        
    }
    
    /* (non-Javadoc)
     * @see org.springframework.security.intercept.ObjectDefinitionSource#getAttributes(java.lang.Object)
     */
    public ConfigAttributeDefinition getAttributes(Object filter) throws IllegalArgumentException {
        
        FilterInvocation filterInvocation = (FilterInvocation) filter;
        String requestURI = filterInvocation.getRequestUrl();
        Map<String, String> urlAuthorities = this.getUrlAuthorities(filterInvocation);
        
        String grantedAuthorities = null;
        for(Iterator<Map.Entry<String, String>> iter = urlAuthorities.entrySet().iterator(); iter.hasNext();) {
            Map.Entry<String, String> entry = iter.next();
            String url = entry.getKey();
            
            if(urlMatcher.pathMatchesUrl(url, requestURI)) {
                grantedAuthorities = entry.getValue();
                break;
            }
            
        }
        
        if(grantedAuthorities != null) {
            ConfigAttributeEditor configAttrEditor = new ConfigAttributeEditor();
            configAttrEditor.setAsText(grantedAuthorities);
            return (ConfigAttributeDefinition) configAttrEditor.getValue();
        }
        
        return null;
    }

    /* (non-Javadoc)
     * @see org.springframework.security.intercept.ObjectDefinitionSource#getConfigAttributeDefinitions()
     */
    @SuppressWarnings("unchecked")
 public Collection getConfigAttributeDefinitions() {
        return null;
    }

    /* (non-Javadoc)
     * @see org.springframework.security.intercept.ObjectDefinitionSource#supports(java.lang.Class)
     */
    @SuppressWarnings("unchecked")
 public boolean supports(Class clazz) {
        return true;
    }
    
    /**
     * 
     * @param filterInvocation
     * @return
     */
    @SuppressWarnings("unchecked")
 private Map<String, String> getUrlAuthorities(FilterInvocation filterInvocation) {
        ServletContext servletContext = filterInvocation.getHttpRequest().getSession().getServletContext();
        return (Map<String, String>)servletContext.getAttribute("urlAuthorities");
    }

}


  4. 配置文件修改

  接下来,我们来修改一下Spring Security的配置文件,把我们自定义的这个过滤器插入到过滤器链中去。

  Xml代码

<beans:beans xmlns="http://www.springframework.org/schema/security"  
    xmlns:beans="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">  
       
    <beans:bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener" />  
       
    <http access-denied-page="/403.jsp" >  
        <intercept-url pattern="/static/**" filters="none" />  
        <intercept-url pattern="/template/**" filters="none" />  
        <intercept-url pattern="/" filters="none" />  
        <intercept-url pattern="/login.jsp" filters="none" />  
        <form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" default-target-url="/index" />  
        <logout logout-success-url="/login.jsp"/>  
        <http-basic />  
    </http>  
  
    <authentication-manager alias="authenticationManager"/>  
       
    <authentication-provider user-service-ref="securityManager">  
        <password-encoder hash="md5"/>  
    </authentication-provider>  
       
    <beans:bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">  
        <beans:property name="allowIfAllAbstainDecisions" value="false"/>  
        <beans:property name="decisionVoters">  
            <beans:list>  
                <beans:bean class="org.springframework.security.vote.RoleVoter"/>  
                <beans:bean class="org.springframework.security.vote.AuthenticatedVoter"/>  
            </beans:list>  
        </beans:property>  
    </beans:bean>  
       
    <beans:bean id="resourceSecurityInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">  
        <beans:property name="authenticationManager" ref="authenticationManager"/>  
        <beans:property name="accessDecisionManager" ref="accessDecisionManager"/>  
        <beans:property name="objectDefinitionSource" ref="secureResourceFilterInvocationDefinitionSource" />  
        <beans:property name="observeOncePerRequest" value="false" />  
        <custom-filter after="LAST" />  
    </beans:bean>  
       
    <beans:bean id="secureResourceFilterInvocationDefinitionSource" class="com.javaeye.sample.security.interceptor.SecureResourceFilterInvocationDefinitionSource" />  
       
</beans:beans>  

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
 
 <beans:bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener" />
 
 <http access-denied-page="/403.jsp" >
  <intercept-url pattern="/static/**" filters="none" />
  <intercept-url pattern="/template/**" filters="none" />
  <intercept-url pattern="/" filters="none" />
  <intercept-url pattern="/login.jsp" filters="none" />
     <form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" default-target-url="/index" />
     <logout logout-success-url="/login.jsp"/>
     <http-basic />
 </http>

 <authentication-manager alias="authenticationManager"/>
 
 <authentication-provider user-service-ref="securityManager">
  <password-encoder hash="md5"/>
 </authentication-provider>
 
 <beans:bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
     <beans:property name="allowIfAllAbstainDecisions" value="false"/>
     <beans:property name="decisionVoters">
         <beans:list>
             <beans:bean class="org.springframework.security.vote.RoleVoter"/>
             <beans:bean class="org.springframework.security.vote.AuthenticatedVoter"/>
         </beans:list>
     </beans:property>
 </beans:bean>
 
 <beans:bean id="resourceSecurityInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
  <beans:property name="authenticationManager" ref="authenticationManager"/>
     <beans:property name="accessDecisionManager" ref="accessDecisionManager"/>
     <beans:property name="objectDefinitionSource" ref="secureResourceFilterInvocationDefinitionSource" />
     <beans:property name="observeOncePerRequest" value="false" />
     <custom-filter after="LAST" />
 </beans:bean>
 
 <beans:bean id="secureResourceFilterInvocationDefinitionSource" class="com.javaeye.sample.security.interceptor.SecureResourceFilterInvocationDefinitionSource" />
 
</beans:beans>


  请注意,由于我们所实现的,是FilterSecurityInterceptor中的一个开放接口,所以我们实际上定义了一个新的bean,并通过<custom-filter after="LAST" />插入到过滤器链中去。

  Spring Security对象的访问

  1. 访问当前登录用户

  Spring Security提供了一个线程安全的对象:SecurityContextHolder,通过这个对象,我们可以访问当前的登录用户。我写了一个类,可以通过静态方法去读取:

  Java代码

public class SecurityUserHolder {   
  
    /**  
     * Returns the current user  
     *   
     * @return  
     */  
    public static User getCurrentUser() {   
        return (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();   
    }   
  
}  

public class SecurityUserHolder {

 /**
  * Returns the current user
  * 
  * @return
  */
 public static User getCurrentUser() {
  return (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
 }

}


  2. 访问当前登录用户所拥有的权限

  通过上面的分析,我们知道,用户所拥有的所有权限,其实是通过UserDetails接口中的getAuthorities()方法获得的。只要实现这个接口,就能实现需求。在我的代码中,不仅实现了这个接口,还在上面做了点小文章,这样我们可以获得一个用户所拥有权限的字符串表示:

  Java代码

/* (non-Javadoc)  
 * @see org.springframework.security.userdetails.UserDetails#getAuthorities()  
 */  
public GrantedAuthority[] getAuthorities() {   
    List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>(roles.size());   
    for(Role role : roles) {   
        grantedAuthorities.add(new GrantedAuthorityImpl(role.getName()));   
    }   
       return grantedAuthorities.toArray(new GrantedAuthority[roles.size()]);   
}   
  
/**  
 * Returns the authorites string  
 *   
 * eg.   
 *    downpour --- ROLE_ADMIN,ROLE_USER  
 *    robbin --- ROLE_ADMIN  
 *   
 * @return  
 */  
public String getAuthoritiesString() {   
    List<String> authorities = new ArrayList<String>();   
    for(GrantedAuthority authority : this.getAuthorities()) {   
        authorities.add(authority.getAuthority());   
    }   
    return StringUtils.join(authorities, ",");   
}  

 /* (non-Javadoc)
  * @see org.springframework.security.userdetails.UserDetails#getAuthorities()
  */
 public GrantedAuthority[] getAuthorities() {
  List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>(roles.size());
     for(Role role : roles) {
      grantedAuthorities.add(new GrantedAuthorityImpl(role.getName()));
     }
        return grantedAuthorities.toArray(new GrantedAuthority[roles.size()]);
 }
 
 /**
  * Returns the authorites string
  * 
  * eg. 
  *    downpour --- ROLE_ADMIN,ROLE_USER
  *    robbin --- ROLE_ADMIN
  * 
  * @return
  */
 public String getAuthoritiesString() {
     List<String> authorities = new ArrayList<String>();
     for(GrantedAuthority authority : this.getAuthorities()) {
         authorities.add(authority.getAuthority());
     }
     return StringUtils.join(authorities, ",");
 }


  3. 访问当前登录用户能够访问的资源

  这就涉及到用户(User),权限(Role)和资源(Resource)三者之间的对应关系。我同样在User对象中实现了一个方法:

  Java代码

/**  
 * @return the roleResources  
 */  
public Map<String, List<Resource>> getRoleResources() {   
    // init roleResources for the first time   
    if(this.roleResources == null) {               
        this.roleResources = new HashMap<String, List<Resource>>();   
               
        for(Role role : this.roles) {   
            String roleName = role.getName();   
            Set<Resource> resources = role.getResources();   
            for(Resource resource : resources) {   
                String key = roleName + "_" + resource.getType();   
                    if(!this.roleResources.containsKey(key)) {   
                        this.roleResources.put(key, new ArrayList<Resource>());   
                }   
                    this.roleResources.get(key).add(resource);                     
            }   
        }   
               
    }   
    return this.roleResources;   
}  

/**
 * @return the roleResources
 */
public Map<String, List<Resource>> getRoleResources() {
 // init roleResources for the first time
 if(this.roleResources == null) {   
  this.roleResources = new HashMap<String, List<Resource>>();
   
  for(Role role : this.roles) {
   String roleName = role.getName();
   Set<Resource> resources = role.getResources();
   for(Resource resource : resources) {
    String key = roleName + "_" + resource.getType();
     if(!this.roleResources.containsKey(key)) {
      this.roleResources.put(key, new ArrayList<Resource>());
    }
     this.roleResources.get(key).add(resource);     
   }
  }
   
 }
 return this.roleResources;
}



  这里,会在User对象中设置一个缓存机制,在第一次取的时候,通过遍历User所有的Role,获取相应的Resource信息。

分享到:
评论

相关推荐

    Spring Security 2 配置精讲

    Spring Security 2 配置精讲

    Spring Security+OAuth2 精讲,打造企业级认证与授权

    本课程"Spring Security+OAuth2 精讲,打造企业级认证与授权"深入浅出地讲解了这两个框架的使用和集成,旨在帮助开发者构建安全、高效的应用系统。 Spring Security是Spring生态系统中的一个强大安全框架,它提供了...

    Spring Security+OAuth2 精讲,打造企业级认证与授权2022升级

    Spring Security+OAuth2 精讲,打造企业级认证与授权(2022升级版) 1、企业级认证授权专项解决方案 系统解锁后端开发者必备的"安全"技能 2、主流安全框架核心一网打尽,只学实用的

    Spring Security OAuth2认证授权示例详解

    Spring Security OAuth2是一个强大的安全框架,它为Web应用程序提供了安全认证和授权的功能。OAuth2则是一种开放标准,允许用户授权第三方应用访问他们存储在另一服务提供商的数据,而无需分享他们的用户名和密码。...

    spring security oauth2.0 (讲义+代码)

    Spring Security OAuth2.0 提供了 `ResourceServerConfigurerAdapter`,可以配置资源服务器的保护规则,如哪些URL需要令牌,以及如何验证令牌。 此外,Spring Security OAuth2.0 还支持自定义权限控制。通过实现`...

    视频配套笔记_Spring Security OAuth2.0认证授权_v1.1.rar

    在Spring Security OAuth2.0的配置中,开发者需要定义这些组件的行为,例如设置授权类型、定义客户端信息、配置资源服务器等。同时,还需要处理各种授权流,如授权码流、密码流、客户端凭据流等,每种流都有其特定的...

    非常珍贵的Spring Security企业级认证与授权全套视频(自鉴过后,良心推荐)

    SpringSecurity 全套开发,设计源码解读,整个拦截器链分析,QQ登录,微信登录,短信验证,短信登录,在security基础上学习写一个自定义验证授权设计模式,整套视频讲解的分享细致认真,非常值得学习。不管小白还是...

    SpringSecurity和OAuth2实战精讲视频.zip

    15-自定义配置-SpringSecurity的默认配置 16-自定义配置-添加用户功能的实现 17-自定义配置-添加用户功能的测试 18-自定义配置-密码加密算法 19-自定义配置-密码加密测试 20-自定义配置-DelegatingPasswordEncoder ...

    spring security 优秀中文资料+例子(包含多个中文资料,很全)

    首先,"Spring Security 2 配置精讲 - Spring - Java - JavaEye论坛.mht" 文件可能是JavaEye论坛上关于Spring Security 2的一个讨论帖子,精讲了框架的配置细节。Spring Security的配置是其核心部分,涉及到用户认证...

    Spring Security技术栈开发企业级认证与授权

    Spring Security技术栈开发企业级认证与授权, 使用Spring MVC开发RESTful API 使用Spring Security开发基于表单的登录 使用Spring Social开发第三方登录 Spring Security OAuth开发APP认证框架 使用Spring ...

    springBoot+security+oauth2 资源和认证分离的密码模式

    Spring Boot、Spring Security和OAuth2的结合提供了一种强大且灵活的方式来保护应用程序资源,实现资源服务器(Resource Server)与认证服务器(Authorization Server)的分离。这种分离模式有助于提高系统的可扩展...

    JavaEE精讲之Spring框架实战 ——学习笔记.zip

    4. **Spring AOP事务管理**:Spring提供了声明式事务管理,允许开发者在不编写事务管理代码的情况下,通过配置控制事务的边界。这大大减少了处理事务时的复杂性。 5. **Spring JDBC和ORM支持**:Spring提供了JDBC...

    spring-security-fundamentals

    《Spring Security基础精讲》 在Java开发领域,Spring Security是一个强大的、高度可配置的安全框架,用于保护基于Spring的应用程序。本课程将深入探讨Spring Security的基础知识,帮助开发者理解其核心概念,为...

    SSM框架-详细整合教程(Spring+SpringMVC+MyBatis).pdf

    SSM框架,即Spring、SpringMVC和...在实际项目中,还可以根据需求添加缓存、安全、国际化的配置,以及对其他服务的集成,如Spring Security、Spring Data JPA等。不断学习和实践,才能更好地掌握SSM框架及其应用。

    javaspring的文档.zip

    3. **Spring-Security-2-权限配置精讲.doc**:Spring Security是Spring的一个模块,提供认证和授权功能。文档可能详细讲解了如何配置Spring Security来保护Web应用,包括用户身份验证、访问控制、权限分配等。 4. *...

Global site tag (gtag.js) - Google Analytics