use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class CtripUserInfoHolder method getUser.
@Override
public UserInfo getUser() {
try {
Object assertion = getAssertion.invoke(assertionHolder);
Method getPrincipal = assertion.getClass().getMethod("getPrincipal");
Object principal = getPrincipal.invoke(assertion);
Method getName = principal.getClass().getMethod("getName");
String name = (String) getName.invoke(principal);
UserInfo userInfo = new UserInfo();
userInfo.setUserId(name);
return userInfo;
} catch (Exception e) {
throw new RuntimeException("get user info from assertion holder error", e);
}
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class CtripUserService method transformUserServiceResponseToUserInfo.
private UserInfo transformUserServiceResponseToUserInfo(UserServiceResponse userServiceResponse) {
UserInfo userInfo = new UserInfo();
userInfo.setUserId(userServiceResponse.getEmpaccount());
userInfo.setName(userServiceResponse.getDisplayname());
userInfo.setEmail(userServiceResponse.getEmail());
return userInfo;
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class UserAccessFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
String requestUri = ((HttpServletRequest) request).getRequestURI();
try {
if (!isOpenAPIRequest(requestUri) && !isStaticResource(requestUri)) {
UserInfo userInfo = userInfoHolder.getUser();
if (userInfo != null) {
Tracer.logEvent(TracerEventType.USER_ACCESS, userInfo.getUserId());
}
}
} catch (Throwable e) {
Tracer.logError("Record user access info error.", e);
}
chain.doFilter(request, response);
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class ConfigPublishEmailBuilder method recipients.
private List<String> recipients(String appId, String namespaceName, String env) {
Set<UserInfo> modifyRoleUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.MODIFY_NAMESPACE));
Set<UserInfo> envModifyRoleUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.MODIFY_NAMESPACE, env));
Set<UserInfo> releaseRoleUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.RELEASE_NAMESPACE));
Set<UserInfo> envReleaseRoleUsers = rolePermissionService.queryUsersWithRole(RoleUtils.buildNamespaceRoleName(appId, namespaceName, RoleType.RELEASE_NAMESPACE, env));
Set<UserInfo> owners = rolePermissionService.queryUsersWithRole(RoleUtils.buildAppMasterRoleName(appId));
Set<String> userIds = new HashSet<>(modifyRoleUsers.size() + releaseRoleUsers.size() + owners.size());
for (UserInfo userInfo : modifyRoleUsers) {
userIds.add(userInfo.getUserId());
}
for (UserInfo userInfo : envModifyRoleUsers) {
userIds.add(userInfo.getUserId());
}
for (UserInfo userInfo : releaseRoleUsers) {
userIds.add(userInfo.getUserId());
}
for (UserInfo userInfo : envReleaseRoleUsers) {
userIds.add(userInfo.getUserId());
}
for (UserInfo userInfo : owners) {
userIds.add(userInfo.getUserId());
}
List<UserInfo> userInfos = userService.findByUserIds(Lists.newArrayList(userIds));
if (CollectionUtils.isEmpty(userInfos)) {
return Collections.emptyList();
}
List<String> recipients = new ArrayList<>(userInfos.size());
for (UserInfo userInfo : userInfos) {
recipients.add(userInfo.getEmail());
}
return recipients;
}
use of com.ctrip.framework.apollo.portal.entity.bo.UserInfo in project apollo by ctripcorp.
the class ConsumerService method createConsumer.
public Consumer createConsumer(Consumer consumer) {
String appId = consumer.getAppId();
Consumer managedConsumer = consumerRepository.findByAppId(appId);
if (managedConsumer != null) {
throw new BadRequestException("Consumer already exist");
}
String ownerName = consumer.getOwnerName();
UserInfo owner = userService.findByUserId(ownerName);
if (owner == null) {
throw new BadRequestException(String.format("User does not exist. UserId = %s", ownerName));
}
consumer.setOwnerEmail(owner.getEmail());
String operator = userInfoHolder.getUser().getUserId();
consumer.setDataChangeCreatedBy(operator);
consumer.setDataChangeLastModifiedBy(operator);
return consumerRepository.save(consumer);
}
Aggregations