本文整理了Java中com.clusterra.iam.core.application.user.UserId.getId()
方法的一些代码示例,展示了UserId.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UserId.getId()
方法的具体详情如下:
包路径:com.clusterra.iam.core.application.user.UserId
类名称:UserId
方法名:getId
暂无
代码示例来源:origin: com.clusterra/clusterra-iam-core
public TenantNotFoundException(UserId userId) {
super("tenant not found by " + userId.getId());
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
public WrongTenantException(TenantId tenantId, UserId userId) {
super("user id <" + userId.getId() + "> does not belong to tenant <" + tenantId.getId() + ">");
}
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public boolean canExecute(UserId userId, String actionName) {
Validate.notNull(userId);
Validate.notEmpty(actionName);
return authorizedMembershipRepository.isUserAssociatedWithAction(userId.getId(), actionName) != null;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public void deleteByUserId(UserId userId) {
Set<AuthorizedMembership> memberships = authorizedMembershipRepository.findByUserId(userId.getId());
for (AuthorizedMembership membership : memberships) {
authorizedMembershipRepository.delete(membership);
}
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public Tenant findByUser(UserId userId) throws TenantNotFoundException {
Tenant tenant = tenantRepository.findByUserId(userId.getId());
if (tenant == null) {
throw new TenantNotFoundException(userId);
}
return tenant;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Override
public String getCurrentAuditor() {
try {
return identityTracker.currentUser().getId();
} catch (NotAuthenticatedException e) {
logger.debug("current identity not set, but called for, message: {}", e.getLocalizedMessage());
return null;
}
}
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public boolean canExecute(UserId userId, ActionDescriptor actionDescriptor) {
return authorizedMembershipRepository.isUserAssociatedWithAction(userId.getId(), actionDescriptor.getActionName()) != null;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public List<RoleDescriptor> findRolesByUser(UserId userId) {
List<Role> roles = authorizedMembershipRepository.findRolesByUserId(userId.getId());
List<RoleDescriptor> result = new ArrayList<>(roles.size());
for (Role role : roles) {
result.add(new RoleDescriptor(role.getId(), role.getName()));
}
return result;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
private User getUser(UserId userId) throws UserNotFoundException {
User user = userRepository.findOne(userId.getId());
if (user == null) {
throw new UserNotFoundException(userId);
}
return user;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public List<RoleDescriptor> findRolesByGroupAndUser(GroupDescriptor groupDescriptor, UserId userId) {
List<Role> roles = authorizedMembershipRepository.findRolesByGroupIdAndUserId(groupDescriptor.getGroupId(), userId.getId());
List<RoleDescriptor> result = new ArrayList<>(roles.size());
for (Role role : roles) {
result.add(new RoleDescriptor(role.getId(), role.getName()));
}
return result;
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
@Protected(roles = {DefaultRole.USER, DefaultRole.ADMIN})
public User findUser(UserId userId) throws UserNotFoundException {
User user = userRepository.findOne(userId.getId());
if (user == null) {
throw new UserNotFoundException(userId);
}
return user;
}
代码示例来源:origin: com.clusterra/iam-rest
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity<SessionToken> login(HttpServletRequest request, @RequestBody Credentials credentials) throws InvalidCredentialsException, TenantNotFoundException, TenantDisabledException, UserDisabledException {
UserId userId = authenticationService.authenticate(credentials.login, credentials.password);
SessionToken sessionToken = sessionRegistry.registerSession(userId.getId(), request.getRemoteAddr());
Tenant tenant = tenantQueryService.findByUser(userId);
identityTrackerLifeCycle.startTracking(userId, new TenantId(tenant.getId()));
return new ResponseEntity<>(sessionToken, HttpStatus.CREATED);
}
代码示例来源:origin: com.clusterra/clusterra-iam-rest
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseEntity<SessionToken> login(HttpServletRequest request, @RequestBody Credentials credentials) throws InvalidCredentialsException, TenantNotFoundException, TenantDisabledException, UserDisabledException {
UserId userId = authenticationService.authenticate(credentials.login, credentials.password);
SessionToken sessionToken = sessionRegistry.registerSession(userId.getId(), request.getRemoteAddr());
Tenant tenant = tenantQueryService.findByUser(userId);
identityTrackerLifeCycle.startTracking(userId, new TenantId(tenant.getId()));
return new ResponseEntity<>(sessionToken, HttpStatus.CREATED);
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public void deleteAuthorizedMembership(TenantId tenantId, UserId userId, RoleDescriptor roleDescriptor, GroupDescriptor groupDescriptor) {
checkTenantMatch(tenantId, userId);
AuthorizedMembership authorizedMembership = authorizedMembershipRepository.findByUserIdAndRoleId(userId.getId(), roleDescriptor.getRoleId(), groupDescriptor.getGroupId());
if (authorizedMembership != null) {
authorizedMembershipRepository.delete(authorizedMembership);
applicationEventPublisher.publishEvent(new AuthorizedMembershipDeletedEvent(this, tenantId, roleDescriptor, userId, groupDescriptor));
}
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
private void checkTenantMatch(TenantId tenantId, UserId userId) {
User user = userRepository.findOne(userId.getId());
if (!user.getTenant().getId().equals(tenantId.getId())) {
throw new WrongTenantException(tenantId, userId);
}
}
}
代码示例来源:origin: com.clusterra/clusterra-iam-core
@Transactional
public void createAuthorizedMembershipIfNotExists(TenantId tenantId, UserId userId, RoleDescriptor roleDescriptor, GroupDescriptor groupDescriptor) {
checkTenantMatch(tenantId, userId);
AuthorizedMembership membership = authorizedMembershipRepository.findByUserIdAndRoleId(userId.getId(), roleDescriptor.getRoleId(), groupDescriptor.getGroupId());
if (membership == null) {
Role r = roleRepository.findOne(roleDescriptor.getRoleId());
User u = userRepository.findOne(userId.getId());
Group g = groupRepository.findOne(groupDescriptor.getGroupId());
AuthorizedMembership authorizedMembership = new AuthorizedMembership(u, r, g);
authorizedMembershipRepository.save(authorizedMembership);
applicationEventPublisher.publishEvent(new AuthorizedMembershipCreatedEvent(this, tenantId, roleDescriptor, userId, groupDescriptor));
}
}
内容来源于网络,如有侵权,请联系作者删除!