master
parent
df5e566756
commit
e2d469b800
|
|
@ -10,7 +10,7 @@ import org.springframework.security.web.authentication.AuthenticationFailureHand
|
||||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
|
||||||
|
|
||||||
import com.boot.security.server.service.UserDetailsServiceImpl;
|
import com.boot.security.server.service.impl.UserDetailsServiceImpl;
|
||||||
|
|
||||||
@EnableGlobalMethodSecurity
|
@EnableGlobalMethodSecurity
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
package com.boot.security.server.dto;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Builder
|
|
||||||
public class ResponseInfo implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -4417715614021482064L;
|
|
||||||
|
|
||||||
private String code;
|
|
||||||
private String message;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.boot.security.server.service;
|
package com.boot.security.server.service.impl;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -24,7 +24,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("rrr");
|
GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("rrr");
|
||||||
authorities.add(grantedAuthority);
|
authorities.add(grantedAuthority);
|
||||||
|
|
||||||
User user = new User(username, "222", authorities);
|
User user = new User(username, username, authorities);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.boot.security.server.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spring获取bean工具类
|
||||||
|
*
|
||||||
|
* @author 小威老师
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class SpringUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(Class<T> cla) {
|
||||||
|
return applicationContext.getBean(cla);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(String name, Class<T> cal) {
|
||||||
|
return applicationContext.getBean(name, cal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getProperty(String key) {
|
||||||
|
return applicationContext.getBean(Environment.class).getProperty(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue