本文整理了Java中org.hswebframework.web.authorization.Authentication.getUser()
方法的一些代码示例,展示了Authentication.getUser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.getUser()
方法的具体详情如下:
包路径:org.hswebframework.web.authorization.Authentication
类名称:Authentication
方法名:getUser
暂无
代码示例来源:origin: hs-web/hsweb-framework
@Override
public Authentication sync(Authentication authentication) {
authentications.put(authentication.getUser().getId(), authentication);
return authentication;
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public boolean canClaim(Task task, String userId) {
return getCandidateInfo(task)
.stream()
.map(CandidateInfo::user)
.anyMatch(user -> user.getUser().getId().equals(userId));
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/me/{key}")
@Authorize(merge = false)
@ApiOperation("获取当前用户的配置列表")
public ResponseMessage<List<UserSettingEntity>> get(Authentication authentication,
@PathVariable String key) {
return ResponseMessage.ok(userSettingService
.selectByUser(authentication.getUser().getId(), key)
.stream()
.filter(setting -> setting.hasPermission(R, RW))
.collect(Collectors.toList()));
}
代码示例来源:origin: hs-web/hsweb-framework
public boolean putCreatorId(OwnCreatedDataAccessConfig access, AuthorizingContext context) {
RecordCreationEntity entity = context.getParamContext().getParams()
.values().stream()
.filter(RecordCreationEntity.class::isInstance)
.map(RecordCreationEntity.class::cast)
.findAny().orElse(null);
if (entity != null) {
entity.setCreatorId(context.getAuthentication().getUser().getId());
} else {
logger.warn("try put creatorId property,but not found any RecordCreationEntity!");
}
return true;
}
代码示例来源:origin: hs-web/hsweb-framework
@PutMapping("/claim/{taskId}")
@ApiOperation("签收任务")
@Authorize(merge = false)
public ResponseMessage<Void> claim(@PathVariable String taskId, Authentication authentication) {
bpmTaskService.claim(taskId, authentication.getUser().getId());
return ResponseMessage.ok();
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/user-own/tree")
@Authorize(merge = false)
@ApiOperation("获取当前用户的菜单树")
public ResponseMessage<List<UserMenuEntity>> getUserMenuAsTree(@ApiParam(hidden = true) Authentication authentication) {
return ok(userMenuManagerService.getUserMenuAsTree(authentication.getUser().getId()));
}
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/user-own/list")
@Authorize(merge = false)
@ApiOperation("获取当前用户的菜单列表")
public ResponseMessage<List<UserMenuEntity>> getUserMenuAsList(@ApiParam(hidden = true) Authentication authentication) {
return ok(userMenuManagerService.getUserMenuAsList(authentication.getUser().getId()));
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public ResponseMessage<String> add(@RequestBody BindRoleUserEntity data) {
Authentication authentication = Authentication.current().orElse(null);
if (null != authentication) {
data.setCreatorId(authentication.getUser().getId());
}
return CreateController.super.add(data);
}
代码示例来源:origin: hs-web/hsweb-framework
@Authorize(merge = false)
@PutMapping(path = "/password")
@ApiOperation("修改当前登录用户的密码")
public ResponseMessage<Void> updateLoginUserPassword(@RequestParam String password,
@RequestParam String oldPassword) {
Authentication authentication = Authentication.current().orElseThrow(UnAuthorizedException::new);
getService().updatePassword(authentication.getUser().getId(), oldPassword, password);
return ok();
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public ResponseMessage<String> add(@RequestBody DashBoardConfigEntity data) {
Authentication.current().ifPresent(a -> data.setCreatorId(a.getUser().getId()));
return SimpleGenericEntityController.super.add(data);
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public ResponseMessage<String> saveOrUpdate(@RequestBody DashBoardConfigEntity data) {
Authentication.current().ifPresent(a -> data.setCreatorId(a.getUser().getId()));
return SimpleGenericEntityController.super.saveOrUpdate(data);
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public PersonnelAuthentication get() {
//TreadLocal Cache
return ThreadLocalUtils.get(threadLocalCacheKey, () ->
Authentication.current().map(authentication -> getByUserId(authentication.getUser().getId()))
.orElse(null));
}
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public ResponseMessage<String> add(@RequestBody DynamicFormEntity data) {
Authentication authentication = Authentication.current().orElse(null);
if (null != authentication) {
data.setCreatorId(authentication.getUser().getId());
}
data.setCreateTime(System.currentTimeMillis());
return SimpleGenericEntityController.super.add(data);
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/me/{key}/{id}")
@Authorize(merge = false)
@ApiOperation("获取当前用户的配置")
public ResponseMessage<UserSettingEntity> get(Authentication authentication,
@PathVariable String key,
@PathVariable String id) {
UserSettingEntity entity = userSettingService.selectByUser(authentication.getUser().getId(), key, id);
if (entity != null && entity.hasPermission(R, RW)) {
return ResponseMessage.ok();
}
return ResponseMessage.ok();
}
代码示例来源:origin: hs-web/hsweb-framework
@Override
public String getUserIdByUsernameAndPassword(String username, String password) {
try {
Authentication authenticate = authenticationManager.authenticate(new PlainTextUsernamePasswordAuthenticationRequest(username, password));
if (null != authenticate) {
return authenticate.getUser().getId();
}
} catch (ValidationException | UnsupportedOperationException | IllegalArgumentException e) {
return null;
}
return null;
}
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/claims")
@ApiOperation("获取待签收任务")
@Authorize(merge = false)
public ResponseMessage<PagerResult<TaskInfo>> getClaims(QueryParamEntity query, Authentication authentication) {
TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.taskCandidateUser(authentication.getUser().getId());
PagerResult<TaskInfo> result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of);
return ResponseMessage.ok(result);
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/claims-and-todo")
@ApiOperation("获取待签收和待处理的任务")
@Authorize(merge = false)
public ResponseMessage<PagerResult<TaskInfo>> getClaimsAndTodo(QueryParamEntity query, Authentication authentication) {
TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.taskCandidateOrAssigned(authentication.getUser().getId());
PagerResult<TaskInfo> result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of);
return ResponseMessage.ok(result);
}
代码示例来源:origin: hs-web/hsweb-framework
@PatchMapping
@Authorize(action = Permission.ACTION_UPDATE)
@ApiOperation(value = "保存客户端", notes = "如果客户端不存在则自动新增")
public ResponseMessage<OAuth2Client> saveOrUpdate(@RequestBody OAuth2ClientEntity clientEntity) {
Authentication authentication = Authentication.current().orElse(null);
if (null != authentication) {
clientEntity.setCreatorId(authentication.getUser().getId());
}
clientEntity.setCreateTimeNow();
return ResponseMessage.ok(repository.save(clientEntity));
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping("/todo")
@ApiOperation("获取待办任务")
@Authorize(merge = false)
public ResponseMessage<PagerResult<TaskInfo>> getTodoList(QueryParamEntity query, Authentication authentication) {
TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.taskAssignee(authentication.getUser().getId());
PagerResult<TaskInfo> result = QueryUtils.doQuery(taskQuery, query, TaskInfo::of);
return ResponseMessage.ok(result).exclude(query.getExcludes()).include(query.getIncludes());
}
代码示例来源:origin: hs-web/hsweb-framework
public static CandidateDetail of(CandidateInfo candidateInfo) {
CandidateDetail detail = new CandidateDetail();
if (candidateInfo.user() != null) {
detail.setName(candidateInfo.user().getUser().getName());
detail.setUserId(candidateInfo.user().getUser().getId());
}
if (candidateInfo.person() != null) {
detail.setPersonId(candidateInfo.person().getPersonnel().getId());
detail.setName(candidateInfo.person().getPersonnel().getName());
detail.setPositions(new ArrayList<>(candidateInfo.person().getPositions()));
}
return detail;
}
内容来源于网络,如有侵权,请联系作者删除!