use of io.choerodon.core.oauth.CustomUserDetails in project knowledgebase-service by open-hand.
the class WorkSpaceServiceImpl method setUserSettingInfo.
private void setUserSettingInfo(Long organizationId, Long projectId, WorkSpaceInfoVO workSpaceInfoVO) {
CustomUserDetails customUserDetails = DetailsHelper.getUserDetails();
if (customUserDetails == null) {
return;
}
Long userId = customUserDetails.getUserId();
List<UserSettingDTO> userSettingDTOList = userSettingMapper.selectByOption(organizationId, projectId, SETTING_TYPE_EDIT_MODE, userId);
if (!userSettingDTOList.isEmpty() && userSettingDTOList.size() == 1) {
workSpaceInfoVO.setUserSettingVO(modelMapper.map(userSettingDTOList.get(0), UserSettingVO.class));
}
}
use of io.choerodon.core.oauth.CustomUserDetails in project knowledgebase-service by open-hand.
the class PageServiceImpl method deleteDraftContent.
@Override
public void deleteDraftContent(Long organizationId, Long projectId, Long pageId) {
pageRepository.checkById(organizationId, projectId, pageId);
CustomUserDetails userDetails = DetailsHelper.getUserDetails();
if (userDetails != null) {
Long userId = userDetails.getUserId();
PageContentDTO pageContent = new PageContentDTO();
pageContent.setPageId(pageId);
pageContent.setVersionId(0L);
pageContent.setCreatedBy(userId);
pageContentMapper.delete(pageContent);
}
}
use of io.choerodon.core.oauth.CustomUserDetails in project choerodon-starters by open-hand.
the class AbstractAsgardConsumer method beforeInvoke.
protected void beforeInvoke(CustomUserDetails customUserDetails) {
if (customUserDetails == null) {
customUserDetails = new CustomUserDetails("default", "unknown", Collections.emptyList());
customUserDetails.setUserId(0L);
customUserDetails.setOrganizationId(0L);
customUserDetails.setLanguage("zh_CN");
customUserDetails.setTimeZone("CCT");
}
Authentication user = new UsernamePasswordAuthenticationToken("default", "N/A", Collections.emptyList());
OAuth2Request request = new OAuth2Request(new HashMap<>(0), "", Collections.emptyList(), true, Collections.emptySet(), Collections.emptySet(), null, null, null);
OAuth2Authentication authentication = new OAuth2Authentication(request, user);
OAuth2AuthenticationDetails oAuth2AuthenticationDetails = new OAuth2AuthenticationDetails(new MockHttpServletRequest());
oAuth2AuthenticationDetails.setDecodedDetails(customUserDetails);
authentication.setDetails(oAuth2AuthenticationDetails);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
use of io.choerodon.core.oauth.CustomUserDetails in project choerodon-file by open-hand.
the class DevopsExcetionHandler method locale.
/**
* 返回用户的语言类型
*
* @return Locale
*/
private Locale locale() {
CustomUserDetails details = DetailsHelper.getUserDetails();
Locale locale = Locale.SIMPLIFIED_CHINESE;
if (details != null && "en_US".equals(details.getLanguage())) {
locale = Locale.US;
}
return locale;
}
use of io.choerodon.core.oauth.CustomUserDetails in project workflow-service by open-hand.
the class UserRegistryAspect method userRegistry.
/**
* @param joinPoint
* @throws Throwable
*/
@Before("userRegistry()")
public void userRegistry(JoinPoint joinPoint) {
CustomUserDetails details = DetailsHelper.getUserDetails();
String activitiGroup = "Group_activiti" + details.getOrganizationId();
String[] user = { details.getUserId().toString(), "password", "ROLE_ACTIVITI_USER", activitiGroup };
List<String> authoritiesStrings = Arrays.asList(Arrays.copyOfRange(user, 2, user.length));
if (!((InMemoryUserDetailsManager) userDetailsService).userExists(details.getUserId().toString())) {
((InMemoryUserDetailsManager) userDetailsService).createUser(new User(user[0], passwordEncoder.encode(user[1]), authoritiesStrings.stream().map(s -> new SimpleGrantedAuthority(s)).collect(Collectors.toList())));
}
activitiUserLoginUtil.logInAs(details.getUserId().toString());
}
Aggregations