init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.senmesh.security.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import com.senmesh.usercenter.dto.IUserDetail;
|
||||
|
||||
/**
|
||||
* 主要提供用户的授权信息的收集功能
|
||||
*
|
||||
* @author on 2019-11-05
|
||||
*/
|
||||
public interface GrantedAuthorityService {
|
||||
|
||||
/**
|
||||
* 获取用户的授权信息
|
||||
*
|
||||
* @param userDetails 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
Collection<? extends GrantedAuthority> getGrantedAuthorities(IUserDetail userDetails);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.senmesh.security.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import com.senmesh.common.AlitaResult;
|
||||
import com.senmesh.usercenter.authority.dto.PermissionQueryDTO;
|
||||
import com.senmesh.usercenter.authority.dto.UrlPermissionDTO;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-09-07
|
||||
*/
|
||||
public interface IPermissionSecurityService {
|
||||
|
||||
@ApiOperation("查询角色权限分配菜单接口")
|
||||
@GetMapping("/permission/list_url")
|
||||
AlitaResult<List<UrlPermissionDTO>> listUrl(PermissionQueryDTO permissionQueryDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.senmesh.security.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.senmesh.usercenter.dto.IUserDetail;
|
||||
import com.senmesh.usercenter.resource.dto.ComponentDTO;
|
||||
import com.senmesh.usercenter.resource.dto.UrlDTO;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-09-08
|
||||
*/
|
||||
public interface IResourceSecurityService {
|
||||
|
||||
/**
|
||||
* 查询当前登录用户资源树状列表(包含菜单组件)
|
||||
* @param systemCode
|
||||
* @return
|
||||
* @author sr on 2019-10-15
|
||||
*/
|
||||
List<UrlDTO> listResource(Integer systemCode, IUserDetail iUserDetail);
|
||||
|
||||
/**
|
||||
* 获取当前登录用户指定角色的资源树状列表(包含菜单组件)
|
||||
* @param systemCode
|
||||
* @param roleId
|
||||
* @return
|
||||
* @author sr on 2019-10-16
|
||||
*/
|
||||
List<UrlDTO> listResource(Integer systemCode, IUserDetail iUserDetail, Long roleId);
|
||||
|
||||
/**
|
||||
* 根据应用+机构获取url资源
|
||||
*
|
||||
* @param systemCode
|
||||
* @param orgId
|
||||
* @return
|
||||
* @author sr on 2020-09-08
|
||||
*/
|
||||
List<UrlDTO> listUrlDTO(Integer systemCode, Long orgId);
|
||||
|
||||
/**
|
||||
* 根据应用+机构获取Component资源
|
||||
*
|
||||
* @param systemCode
|
||||
* @param orgId
|
||||
* @return
|
||||
* @author sr on 2020-09-08
|
||||
*/
|
||||
List<ComponentDTO> listComponentDTO(Integer systemCode, Long orgId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.senmesh.security.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import com.senmesh.common.AlitaResult;
|
||||
import com.senmesh.usercenter.authority.dto.RoleAllocationDTO;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-09-07
|
||||
*/
|
||||
public interface IRoleAllocationSecurityService {
|
||||
|
||||
@ApiOperation("查询用户分配的角色")
|
||||
@GetMapping("/role/findByUserId/{userId}")
|
||||
AlitaResult<List<RoleAllocationDTO>> findByUserId(@PathVariable("userId") Long userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.senmesh.security.service;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import com.senmesh.common.AlitaResult;
|
||||
import com.senmesh.usercenter.user.dto.UserDetailQueryDTO;
|
||||
import com.senmesh.usercenter.user.login.dto.UserDetailDTO;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author sr on 2020-09-07
|
||||
*/
|
||||
public interface IUserSecurityService {
|
||||
|
||||
@ApiOperation("根据登录信息获取用户信息")
|
||||
@PostMapping("/anon/user/find_user_detail_dto")
|
||||
AlitaResult<UserDetailDTO> findUserDetailDTOResult(UserDetailQueryDTO userDetailQueryDto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.senmesh.security.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.senmesh.security.access.provider.GrantedAuthorityProvider;
|
||||
import com.senmesh.security.service.GrantedAuthorityService;
|
||||
import com.senmesh.usercenter.dto.IUserDetail;
|
||||
|
||||
/**
|
||||
* 主要提供用户的授权信息的收集功能
|
||||
*
|
||||
* @author on 2019-11-05
|
||||
*/
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
public class GrantedAuthorityServiceImpl implements GrantedAuthorityService, InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private List<GrantedAuthorityProvider> providers;
|
||||
|
||||
/**
|
||||
* 获取用户的授权信息
|
||||
*
|
||||
* @param userDetails 用户信息
|
||||
* @return 权限信息
|
||||
*/
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getGrantedAuthorities(IUserDetail userDetails) {
|
||||
Collection<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
|
||||
for (GrantedAuthorityProvider provider : providers) {
|
||||
Collection<? extends GrantedAuthority> list = provider.provide(userDetails);
|
||||
if (list != null && !list.isEmpty()) {
|
||||
grantedAuthorities.addAll(list);
|
||||
}
|
||||
}
|
||||
return grantedAuthorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notEmpty(providers, "providers can not be empty");
|
||||
AnnotationAwareOrderComparator.sort(providers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user