Spring3.0 + Security3.1.3 配置

项目中配置了spring Security3 的并发session管理,一直无效 项目中配置了spring Security3 的并发session管理,一直无效,2个相同账户依然可以登录,不知道什么原因,网上搜了很很多都不行,请大牛指点! web.xml    org.springframework.security.web.session.HttpSessionEventPublisher applicationContext-security.xm 阅读详情

http://simon5408.iteye.com/blog/1973836


MyAccessDecisionManager.java:

/**
 * 
 */
package com.simonsw.security;

import java.util.Collection;
import java.util.Iterator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

/**
 * @author Simon Lv
 * @since Oct 31, 2013
 */
public class MyAccessDecisionManager implements AccessDecisionManager {
	private Logger logger = LoggerFactory.getLogger(getClass());
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.AccessDecisionManager#decide(org.
	 * springframework.security.core.Authentication, java.lang.Object,
	 * java.util.Collection)
	 */
	@Override
	public void decide(Authentication authentication, Object obj,
			Collection<ConfigAttribute> configAttributes)
			throws AccessDeniedException, InsufficientAuthenticationException {
		if (configAttributes == null) {
			return;
		}
		// 所请求的资源拥有的权限(一个资源对多个权限)
		Iterator<ConfigAttribute> iterator = configAttributes.iterator();
		while (iterator.hasNext()) {
			ConfigAttribute configAttribute = iterator.next();
			// 访问所请求资源所需要的权限
			String needPermission = configAttribute.getAttribute();
			logger.debug("[MyAccessDecisionManager] needPermission is " + needPermission);
			// 用户所拥有的权限authentication
			for (GrantedAuthority ga : authentication.getAuthorities()) {
				logger.debug("[MyAccessDecisionManager] ga.getAuthority() is " + ga.getAuthority());
				if (needPermission.contains((ga.getAuthority()))) {
					return;
				}
			}
		}
		// 没有权限让我们去捕捉
		throw new AccessDeniedException(" 没有权限访问!");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.AccessDecisionManager#supports(org
	 * .springframework.security.access.ConfigAttribute)
	 */
	@Override
	public boolean supports(ConfigAttribute arg0) {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.AccessDecisionManager#supports(java
	 * .lang.Class)
	 */
	@Override
	public boolean supports(Class<?> arg0) {
		return true;
	}

}

MyAuthenticationManager.java:

/**
 * 
 */
package com.simonsw.security;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.simonsw.base.entity.Resource;
import com.simonsw.base.entity.Role;
import com.simonsw.base.entity.RoleResource;
import com.simonsw.base.entity.UserRole;
import com.simonsw.base.entity.Users;
import com.simonsw.base.service.RoleResourceService;
import com.simonsw.base.service.UserRoleService;
import com.simonsw.base.service.UserService;
import com.simonsw.common.util.StringUtils;

/**
 * @author Simon Lv
 * @since Oct 31, 2013
 */
public class MyAuthenticationManager implements UserDetailsService {
	@Autowired
	private UserService userService;
	@Autowired
	private UserRoleService userRoleService;
	@Autowired
	private RoleResourceService roleResourceService;
	private Logger logger = LoggerFactory.getLogger(getClass());

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.security.core.userdetails.UserDetailsService#
	 * loadUserByUsername(java.lang.String)
	 */
	@Override
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException {
		logger.debug("[MyAuthenticationManager] username ==> " + username);
		if (!StringUtils.isEmpty(username)) {
			throw new UsernameNotFoundException("用户名不能为空!");
		}
		Users user = userService.getUserByName(username);
		Collection<GrantedAuthority> grantedAuths = obtionGrantedAuthorities(user);

		boolean enables = true;
		boolean accountNonExpired = true;
		boolean credentialsNonExpired = true;
		boolean accountNonLocked = true;
		// 封装成spring security的user
		User userdetail = new User(user.getUsername(), user.getPassword(),
				enables, accountNonExpired, credentialsNonExpired,
				accountNonLocked, grantedAuths);
		return userdetail;
	}

	// 取得用户的权限
	private Set<GrantedAuthority> obtionGrantedAuthorities(Users user) {
		Set<GrantedAuthority> authSet = new HashSet<GrantedAuthority>();
		List<Resource> resources = new ArrayList<Resource>();
		Role role;
		List<RoleResource> roleResources;
		List<UserRole> userRoles = userRoleService.getUserRoleByUserId(user);
		for (UserRole userRole : userRoles) {
			role = userRole.getRole();
			roleResources = roleResourceService.getUserRoleByRoleId(role);
			for (RoleResource roleResource : roleResources) {
				resources.add(roleResource.getResource());
			}
		}

		for (Resource res : resources) {
			authSet.add(new SimpleGrantedAuthority(res.getModelname()));
		}
		return authSet;
	}
}

 MyLogoutSuccessHandler.java:

/**
 * 
 */
package com.simonsw.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

/**
 * @author Simon Lv
 * @since Nov 5, 2013
 */
public class MyLogoutSuccessHandler implements LogoutSuccessHandler {
	private Logger logger = LoggerFactory.getLogger(getClass());
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.web.authentication.logout.LogoutSuccessHandler
	 * #onLogoutSuccess(javax.servlet.http.HttpServletRequest,
	 * javax.servlet.http.HttpServletResponse,
	 * org.springframework.security.core.Authentication)
	 */
	@Override
	public void onLogoutSuccess(HttpServletRequest request,
			HttpServletResponse response, Authentication authentication)
			throws IOException, ServletException {
		if (authentication != null) {
			logger.debug(authentication.getName() + "Logout==>");
		}
		response.sendRedirect(request.getContextPath());

	}

}

MySecurityFilter.java:

/**
 * 
 */
package com.simonsw.security;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
import org.springframework.security.access.intercept.InterceptorStatusToken;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;

/**
 * @author Simon Lv
 * @since Oct 31, 2013
 */
public class MySecurityFilter extends AbstractSecurityInterceptor implements
		Filter {
	private Logger logger = LoggerFactory.getLogger(getClass());

	// 与applicationContext-security.xml里的myFilter的属性securityMetadataSource对应,
	// 其他的两个组件,已经在AbstractSecurityInterceptor定义
	private FilterInvocationSecurityMetadataSource securityMetadataSource;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.intercept.AbstractSecurityInterceptor
	 * #obtainSecurityMetadataSource()
	 */
	@Override
	public SecurityMetadataSource obtainSecurityMetadataSource() {
		return this.securityMetadataSource;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
	 * javax.servlet.ServletResponse, javax.servlet.FilterChain)
	 */
	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		FilterInvocation fi = new FilterInvocation(request, response, chain);
		invoke(fi);
	}

	private void invoke(FilterInvocation fi) throws IOException,
			ServletException {
		logger.debug("[MySecurityFilter] 用户发送请求!");
		InterceptorStatusToken token = null;
		token = super.beforeInvocation(fi);
		try {
			fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
		} finally {
			super.afterInvocation(token, null);
		}
	}

	public FilterInvocationSecurityMetadataSource getSecurityMetadataSource() {
		return securityMetadataSource;
	}

	public void setSecurityMetadataSource(
			FilterInvocationSecurityMetadataSource securityMetadataSource) {
		this.securityMetadataSource = securityMetadataSource;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
	 */
	@Override
	public void init(FilterConfig arg0) throws ServletException {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.Filter#destroy()
	 */
	@Override
	public void destroy() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.intercept.AbstractSecurityInterceptor
	 * #getSecureObjectClass()
	 */
	@Override
	public Class<?> getSecureObjectClass() {
		// 下面的MyAccessDecisionManager的supports方面必须放回true,否则会提醒类型错误
		return FilterInvocation.class;
	}

}

MySecurityMetadataSource.java:

/**
 * 
 */
package com.simonsw.security;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityConfig;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;

import com.simonsw.base.entity.Role;
import com.simonsw.base.entity.RoleResource;
import com.simonsw.base.entity.UserRole;
import com.simonsw.base.entity.Users;
import com.simonsw.base.service.RoleResourceService;
import com.simonsw.base.service.UserRoleService;
import com.simonsw.base.service.UserService;

/**
 * @author Simon Lv
 * @since Oct 31, 2013
 */
public class MySecurityMetadataSource implements
		FilterInvocationSecurityMetadataSource {
	@Autowired
	protected UserService userService;
	@Autowired
	protected UserRoleService userRoleService;
	@Autowired
	protected RoleResourceService roleResourceService;

	private Logger logger = LoggerFactory.getLogger(getClass());

	private static LinkedHashMap<String, Collection<ConfigAttribute>> resourceMap = null;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.SecurityMetadataSource#getAttributes
	 * (java.lang.Object)
	 */
	@Override
	public Collection<ConfigAttribute> getAttributes(Object object)
			throws IllegalArgumentException {
		String requestURL = ((FilterInvocation) object).getRequestUrl();

		logger.debug("[MySecurityMetadataSource] 请求地址 ===> "
				+ ((FilterInvocation) object).getRequestUrl());
		if (null == resourceMap) {
			loadResourceDefine();
			logger.debug("[MySecurityMetadataSource] 我需要的认证 ==> "
					+ resourceMap.toString());
		}
		for (Map.Entry<String, Collection<ConfigAttribute>> entry : resourceMap
				.entrySet()) {
			logger.debug("[MySecurityMetadataSource] entry.getKey() ===> "
					+ entry.getKey());
			logger.debug("[MySecurityMetadataSource] request ===> " + requestURL);
			if (entry.getKey().equals(requestURL)) {
				return entry.getValue();
			}
		}
		return null;
	}

	/**
	 * Load all resource
	 */
	private void loadResourceDefine() {
		resourceMap = new LinkedHashMap<String, Collection<ConfigAttribute>>();
		Map<String, String> resource = getResource();
		for (Map.Entry<String, String> entry : resource.entrySet()) {
			Collection<ConfigAttribute> configAttributes = new ArrayList<ConfigAttribute>();
			configAttributes.add(new SecurityConfig(entry.getValue()));
			resourceMap.put(entry.getKey(),
					configAttributes);
		}
	}

	/**
	 * 加载所有资源与权限的关系
	 * 
	 * @return
	 */
	private Map<String, String> getResource() {
		Map<String, String> resourceMap = new HashMap<String, String>();
		List<Users> users = userService.findAll();
		List<UserRole> userRoles;
		Role role;
		List<RoleResource> roleResources;
		userfor: for (Users user : users) {
			logger.debug("userId => " + user.getUserid());
			userRoles = userRoleService.getUserRoleByUserId(user);
			if (userRoles == null) {
				logger.debug("userfor => break!!!!");
				break userfor;
			}
			rolefor: for (UserRole userRole : userRoles) {
				role = userRole.getRole();
				roleResources = roleResourceService.getUserRoleByRoleId(role);
				if (roleResources == null) {
					break rolefor;
				}
				for (RoleResource roleResource : roleResources) {
					String url = roleResource.getResource().getValue();
					if (!resourceMap.containsKey(url)) {
						resourceMap.put(url, role.getName());
					} else {
						String roleName = resourceMap.get(url);
						resourceMap.put(url, roleName + "," + role.getName());
					}
				}
			}
		}
		return resourceMap;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.springframework.security.access.SecurityMetadataSource#
	 * getAllConfigAttributes()
	 */
	@Override
	public Collection<ConfigAttribute> getAllConfigAttributes() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.access.SecurityMetadataSource#supports(java
	 * .lang.Class)
	 */
	@Override
	public boolean supports(Class<?> arg0) {
		// TODO Auto-generated method stub
		return true;
	}

}

 MyUsernamePasswordAuthenticationFilter.java:

/**
 * 
 */
package com.simonsw.security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

import com.simonsw.base.entity.Users;
import com.simonsw.base.service.UserService;
import com.simonsw.common.util.CipherUtil;
import com.simonsw.common.util.StringUtils;

/**
 * @author Simon Lv
 * @since Oct 31, 2013
 */
public class MyUsernamePasswordAuthenticationFilter extends
		UsernamePasswordAuthenticationFilter {
	@Autowired
	protected UserService userService;
	
	private Logger logger = LoggerFactory.getLogger(getClass());

	public static final String VALIDATE_CODE = "validateCode";
	public static final String USERNAME = "username";
	public static final String PASSWORD = "password";

	@Override
	public Authentication attemptAuthentication(HttpServletRequest request,
			HttpServletResponse response) {
		if (!request.getMethod().equals("POST")) {
			throw new AuthenticationServiceException(
					"Authentication method not supported: "
							+ request.getMethod());
		}

		// checkValidateCode(request);

		String username = obtainUsername(request);
		logger.debug("[MyUsernamePasswordAuthenticationFilter] username ==> "+ username);
		String password = CipherUtil.generatePassword(obtainPassword(request));
		logger.debug("[MyUsernamePasswordAuthenticationFilter] password ==> "+ password);
		
		// 验证用户账号与密码是否对应
		username = username.trim();

		Users users = userService.getUserByName(username);

		if (users == null || !users.getPassword().equals(password)) {
			throw new AuthenticationServiceException(
					"password or username is notEquals");
		}

		// UsernamePasswordAuthenticationToken实现 Authentication
		UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
				username, password);
		// Place the last username attempted into HttpSession for views

		// 允许子类设置详细属性
		setDetails(request, authRequest);

		// 运行UserDetailsService的loadUserByUsername 再次封装Authentication
		return this.getAuthenticationManager().authenticate(authRequest);
	}

	protected void checkValidateCode(HttpServletRequest request) {
		HttpSession session = request.getSession();

		String sessionValidateCode = obtainSessionValidateCode(session);
		// 让上一次的验证码失效
		session.setAttribute(VALIDATE_CODE, null);
		String validateCodeParameter = obtainValidateCodeParameter(request);
		if (StringUtils.isEmpty(validateCodeParameter)
				|| !sessionValidateCode.equalsIgnoreCase(validateCodeParameter)) {
			throw new AuthenticationServiceException("validateCode.notEquals");
		}
	}

	private String obtainValidateCodeParameter(HttpServletRequest request) {
		Object obj = request.getParameter(VALIDATE_CODE);
		return null == obj ? "" : obj.toString();
	}

	protected String obtainSessionValidateCode(HttpSession session) {
		Object obj = session.getAttribute(VALIDATE_CODE);
		return null == obj ? "" : obj.toString();
	}

	@Override
	protected String obtainUsername(HttpServletRequest request) {
		Object obj = request.getParameter(USERNAME);
		return null == obj ? "" : obj.toString();
	}

	@Override
	protected String obtainPassword(HttpServletRequest request) {
		Object obj = request.getParameter(PASSWORD);
		return null == obj ? "" : obj.toString();
	}
}

security.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns="http://www.springframework.org/schema/security" 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-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
	<debug />

	<global-method-security pre-post-annotations="enabled" />

	<!-- 此目录下不需要过滤 -->
	<http pattern="/js/**" security="none" />
	<http pattern="/css/**" security="none" />
	<http pattern="/images/**" security="none" />
	<http pattern="/login" security="none" />

	<http use-expressions="true" entry-point-ref="authenticationProcessingFilterEntryPoint">
		<!-- if no limit, go to 403 page -->
		<access-denied-handler error-page="/403" />
		<!-- Logout -->
		<logout invalidate-session="true" logout-url="/logout"
			success-handler-ref="myLogoutSuccessHandler" />
		<!-- 实现免登陆验证 -->
		<remember-me />
		<session-management invalid-session-url="/">
			<concurrency-control max-sessions="10"
				error-if-maximum-exceeded="true" />
		</session-management>

		<custom-filter ref="loginFilter" position="FORM_LOGIN_FILTER" />
		<custom-filter ref="securityFilter" before="FILTER_SECURITY_INTERCEPTOR" />
	</http>

	<!-- 登录验证器 -->
	<beans:bean id="loginFilter"
		class="com.simonsw.security.MyUsernamePasswordAuthenticationFilter">
		<!-- 处理登录 -->
		<beans:property name="filterProcessesUrl" value="/user/login"></beans:property>
		<beans:property name="authenticationSuccessHandler"
			ref="loginLogAuthenticationSuccessHandler"></beans:property>
		<beans:property name="authenticationFailureHandler"
			ref="simpleUrlAuthenticationFailureHandler"></beans:property>
		<beans:property name="authenticationManager" ref="myAuthenticationManager" />
	</beans:bean>

	<beans:bean id="loginLogAuthenticationSuccessHandler"
		class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
		<beans:property name="defaultTargetUrl" value="/"></beans:property>
	</beans:bean>
	<beans:bean id="simpleUrlAuthenticationFailureHandler"
		class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
		<beans:property name="defaultFailureUrl" value="/"></beans:property>
	</beans:bean>

	<!-- 认证过滤器 -->
	<beans:bean id="securityFilter" class="com.simonsw.security.MySecurityFilter">
		<!-- 用户拥有的权限 -->
		<beans:property name="authenticationManager" ref="myAuthenticationManager" />
		<!-- 用户是否拥有所请求资源的权限 -->
		<beans:property name="accessDecisionManager" ref="myAccessDecisionManager" />
		<!-- 资源与权限对应关系 -->
		<beans:property name="securityMetadataSource" ref="mySecurityMetadataSource" />
	</beans:bean>

	<!-- 实现了UserDetailsService的Bean -->
	<authentication-manager alias="myAuthenticationManager">
		<authentication-provider user-service-ref="myAuthenticationManagers" />
	</authentication-manager>

	<beans:bean id="myAccessDecisionManager"
		class="com.simonsw.security.MyAccessDecisionManager"></beans:bean>

	<beans:bean id="mySecurityMetadataSource"
		class="com.simonsw.security.MySecurityMetadataSource">
	</beans:bean>
	<beans:bean id="myAuthenticationManagers"
		class="com.simonsw.security.MyAuthenticationManager">
	</beans:bean>

	<beans:bean id="myLogoutSuccessHandler" class="com.simonsw.security.MyLogoutSuccessHandler" />

	<!-- 未登录的切入点 -->
	<beans:bean id="authenticationProcessingFilterEntryPoint"
		class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
		<beans:property name="loginFormUrl" value="/login"></beans:property>
	</beans:bean>

</beans:beans>

web.xml:

<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring-security.xml</param-value>
	</context-param>

    <!-- Spring Security Session -->
    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>
     
	<!-- Spring security Filter -->
	<filter>
		<filter-name>springSecurityFilterChain</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>springSecurityFilterChain</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

启动Tomcat,登录正常工作。

 

具体想看源代码,请访问GitHub网站上的源代码:

https://github.com/simon5408/DummyProj


Spring Security 3.1.3配置实例 立即下载

相关推荐

双目立体匹配算法:SGBM

SGBM(Semi-Global Block Matching)是一种用于计算双目视觉中视差(disparity)的半全局匹配算法,在OpenCV中的实现为semi-global block matching(SGBM)。它是基于全局匹配算法和局部匹配算法的优缺点,提出了一种折中的方法,既能保证视差图的质量,又能降低计算复杂度。

weixin_45303602的博客 9407

Spring Security3.0入门

在认识Spring Security之前, 所有的权限验证都混杂在业务逻辑中,用户的每个操作可能都需要对用户是否有该权限进行判断。类似这样的验证代码被分散在系统的许多地方,难以维护。正如系统日志,事务管理等这些系统级的服务一样,我们应该将它作为系统的一个单独的“切面”进行管理,以达到业务逻辑与系统级的服务真正分离的目。 Spring Security将系统的安全逻辑从业务中分离出来。 Spr...

互联网 307

华大HC32F460 TCP Server实验

华大HC32F460 TCP Server实验

ZhuoWuKeJi的博客 1270

Spring Security3.0版本

核心: A >>?>> B?代表判断层,由Security实现这是之前的版本浓缩,现在3.0版本添加了更匹配的内容描写,匹配了mvc模式非mvc模式 核心:client(用户)>> filter(过滤器)>> servlet(业务)mvc模式ps:不要在意图片中的英文,有拼错的。

c_yanxin_ru的博客 1652

在linux上本地大模型部署与推理

您的Python脚本(客户端)可能在您的个人电脑上,而模型服务(服务器)在远程Linux服务器上。如果您的服务器有强大的NVIDIA GPU,并且您对性能有更高的要求(例如需要高吞吐量),vLLM是更好的选择。这种方式无需向公网暴露服务器端口,而是通过加密的SSH通道将服务器的端口“映射”到您的本地电脑上。我们将启动一个API服务器,它会加载您指定的模型,并等待您的代码前来调用。如果您直接在SSH窗口运行上面的命令,一旦您关闭窗口,服务就会停止。这是根据您的原始代码修改的版本,适配本地vLLM服务。

frostmelody 全网同名,大家多多关注呀~ 持续分享优质内容! 2054

手把手教你学Simulink——基于电机驱动系统的场景实例:轮毂电机在电动汽车中的分布式驱动控制仿真

本文详细介绍了基于MATLAB/Simulink和Simscape Electrical的电动汽车轮毂电机分布式驱动控制系统建模方法。内容包括系统结构设计(轮毂电机、逆变器、控制器等模块)、完整的建模过程(从基础模块导入到车辆动力学建模)、控制器设计与转矩分配策略实现,以及仿真参数设置与结果分析。通过仿真验证了该分布式驱动系统在速度跟踪、转弯性能等方面的优异表现,为电动汽车驱动系统的研究与开发提供了有效的仿真验证平台。文中还提供了相关代码示例和资料推荐,是学习Simulink电机控制系统建模的实用指南。

MHD0815的博客 4914

Spring Security入门

简介: Spring Security是针对Spring项目的安全框架,也是Spring Boot底层安全模块默认的技术选型,他可以实现强大的Web安全控制,对于安全控制,我们仅需要引入spring-boot-starter-security模块,进行少量的配置,即可实现强大的安全管理! 记住几个类: WebSecurityConfigurerAdapter:自定义Security策略. AuthenticationManagerBuilder:自定义认证策略. @EnableWebSecurit

jxiao_linbei的博客 211

Eplan设计师必会—伺服安全回路的设计方法

本文介绍了在EPLAN中设计伺服STO安全回路的方法。首先需查阅伺服驱动器说明书确定STO接线端子,重点关注双通道配置。设计步骤包括:使用黑盒子功能绘制驱动器外形,正确标注STO接线点,并连接安全继电器或PLC的安全输出。关键注意事项有:必须采用双通道独立布线,确保同步动作,遵循故障安全原则,使用常闭触点串联回路。文中以西门子V90和汇川伺服为例说明具体接线要求,并附有项目实例参考。

Qinmingyue13的博客 436

Spring Security3.0.1版本

这样看太抽象了,换个方向到了这里,站长感觉这个简介也不算难,还真可以通过简介退出结论这期先到这里。

c_yanxin_ru的博客 1055

扫地机器人行业 企业篇-产业总部地理分布

中国扫地机器人产业呈现区域集聚特征,广东省以13家企业领跑全国,其中深圳独占9家(如大疆、云鲸智能等),佛山、广州、东莞各有分布。江苏省6家企业主要集中在苏州(科沃斯、追觅科技等)。北京聚集了石头科技、小米等4家品牌。浙江、山东、湖南等地也有代表性企业分布。国际品牌方面,美国iRobot、韩国三星/LG、日本松下等均在各自国家设立总部,而戴森、飞利浦等欧洲品牌则将中国运营中心设在上海或苏州。值得注意的是,部分品牌如由利、宝家丽虽为外资起源,但主要运营实体已落户中国。

智能硬件研发,欢迎交流 362

ardupilot开发 --- Remote ID 篇

适配ardupilot的Remote ID模块研发,远程标识模块研发。Remote ID模块可以通过蓝牙或wifi向外广播无人机的状态信息、位置信息、任务信息等,并可以通过蜂窝数据向国家无人驾驶航空器一体化综合监管服务平台上报这些信息。Remote ID功能是21年起国家出台的民用无人机适航飞行的基本要求!

记录老板的每次pua,分享领导每天的毒鸡汤... 9607

Spring Authorization Server 1.4.0 使用及详细配置 搭配Spring Boot3.4.0 + Spring Security6.4.1

Spring Authorization Server 是一个提供OAuth 2.1和OpenID Connect 1.0规范以及其他相关规范的实现的框架。它构建在Spring Security之上,为构建 OpenID Connect 1.0 身份提供商和 OAuth2 授权服务器产品提供安全、轻量级和可定制的基础。

m0_67390788的博客 1271

Python爬虫实战:汽车之家车型参数与口碑数据抓取分析

在当今信息爆炸的时代,购车决策已从传统的4S店咨询转变为数据驱动的智能化过程。汽车之家作为国内领先的汽车信息平台,汇聚了海量车型参数、车主口碑和专业评测数据。本文将详细介绍如何使用Python最新爬虫技术构建一个高效、稳定的汽车数据采集系统,通过多维度数据分析辅助用户做出更明智的购车决策。本项目将采用异步爬虫、智能反爬绕过、数据清洗与分析等现代化技术栈,完整实现从数据采集到可视化分析的全流程。本文详细介绍了如何使用Python最新技术构建一个功能完整的汽车之家数据爬虫系统。

2201_76125261的博客 1488

Spring+Security-3.0.1中文官方文档

Spring+Security-3.0.1中文官方文档.pdf 在线地址:http://www.asdtiang.org/wp-content/uploads/2011/09/Spring-Security-3.0.1-%E4%B8%AD%E6%96%87%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3.pdf  

flyli815的专栏 320

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Spring Security-3.0.1中文官方文档(翻译版)

这次发布的Spring Security-3.0.1是一个bug fix版,主要是对3.0中存在的一些问题进行修正。文档中没有添加新功能的介绍,但是将之前拼写错误的一些类名进行了修正,建议开发者以这一版本的文档为参考。 另:Spring Security从2010-01-01以后,版本控制从SVN换成了GIT,我们在翻译文档的时候,主要是根据SVN的变化来进行文档内容的比对,这次 换成GIT...

xyz20003的专栏 325

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Spring boot 3.3.4 + Spring Security 6.3.3 + Spring Authorization Server 1.3.2自定义密码模式

在写这篇文档之前,本人在网上查到很多升级密码模式采用JWT令牌格式,但并不符合本人想要的要求。主要有两点:一、用户登出就要撤销令牌,但JWT并不能立即失效,必须在有效期之后自动失效。虽然可以通过黑名单机制(比如用redis保存撤销的令牌)达到同样的效果,但这样授权服务器和资源服务器都要访问到黑名单,这样也就失去了JWT令牌可以本地验证的优势。二、资源服务器可以本地验证JWT令牌,不需要查询授权服务器,因此也不能实时感知到用户权限的变化。

xjj1314的专栏 1200

spring security3的基本配置和使用

折腾了一天终于把spring security 3.1.0集成进项目中了,这里特别说明了一下版本,因为不同的版本有些用法会存在一些差异。期间遇到了很多问题,记录在这里。 最大的心得是网上的资料只能参考,最重要的文档是spring security自带的tutorial的例子,这里的用法是和你要用到的版本是一致的。 [code="xml"] ...

pwc_beyond的博客 240
上一篇: js 控制样式添加
下一篇: user/group right
learnTech
博客等级 码龄14年 10粉丝 73原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值