Search in sources :

Example 1 with PermissionRequestDto

use of io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto in project datarouter by hotpads.

the class AdminEditUserHandler method getEditUserDetailsDto.

// TODO DATAROUTER-2788
private EditUserDetailsDto getEditUserDetailsDto(String username) {
    SessionBasedUser user = userInfo.getUserByUsername(username, false).orElseThrow();
    Set<Role> roles = userInfo.getRolesByUsername(username, false);
    List<PermissionRequestDto> permissionRequests = datarouterPermissionRequestDao.scanPermissionRequestsForUser(user.getId()).listTo(requests -> Scanner.of(datarouterUserHistoryService.getResolvedRequestToHistoryChangesMap(requests).entrySet())).sort(Comparator.comparing(Entry::getKey, DatarouterPermissionRequest.REVERSE_CHRONOLOGICAL_COMPARATOR)).map(this::buildPermissionRequestDto).list();
    return new EditUserDetailsDto(user.getUsername(), user.getId().toString(), user.getToken(), permissionRequests, deprovisionedUserDao.find(new DeprovisionedUserKey(username)).map(DeprovisionedUser::toDto).orElseGet(() -> buildDeprovisionedUserDto(user, roles)), roleManager.getConferrableRoles(getSessionInfo().getRoles()), roles, datarouterAccountUserService.getAllAccountNamesWithUserMappingsEnabled(), datarouterAccountUserService.findAccountNamesForUser(user), true, "", // zoneId can be configured through the UI, fallback to system default
    user.getZoneId().map(ZoneId::getId).orElse(ZoneId.systemDefault().getId()));
}
Also used : Role(io.datarouter.web.user.session.service.Role) Scanner(io.datarouter.scanner.Scanner) DatarouterUserExternalDetailService(io.datarouter.web.user.detail.DatarouterUserExternalDetailService) Arrays(java.util.Arrays) ResponseTool(io.datarouter.web.util.http.ResponseTool) PathNode(io.datarouter.pathnode.PathNode) BiFunction(java.util.function.BiFunction) DatarouterAuthFiles(io.datarouter.auth.config.DatarouterAuthFiles) DatarouterUserCreationService(io.datarouter.auth.service.DatarouterUserCreationService) DatarouterUserService(io.datarouter.auth.service.DatarouterUserService) Map(java.util.Map) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) ServerTypeDetector(io.datarouter.storage.servertype.ServerTypeDetector) DatarouterWebJsTool(io.datarouter.web.js.DatarouterWebJsTool) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) DeprovisionedUserDao(io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUserDao) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest) DatarouterAuthenticationConfig(io.datarouter.web.user.authenticate.config.DatarouterAuthenticationConfig) Objects(java.util.Objects) List(java.util.List) PermissionRequestDto(io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto) Role(io.datarouter.web.user.session.service.Role) DatarouterUserDao(io.datarouter.auth.storage.user.DatarouterUserDao) Entry(java.util.Map.Entry) Optional(java.util.Optional) Bootstrap4PageFactory(io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory) Bootstrap4ReactPageFactory(io.datarouter.web.html.react.bootstrap4.Bootstrap4ReactPageFactory) UserInfo(io.datarouter.auth.service.UserInfo) DatarouterAccountKey(io.datarouter.auth.storage.account.DatarouterAccountKey) CurrentUserSessionInfoService(io.datarouter.web.user.session.CurrentUserSessionInfoService) HashMap(java.util.HashMap) RequestBody(io.datarouter.web.handler.types.RequestBody) Function(java.util.function.Function) HashSet(java.util.HashSet) Inject(javax.inject.Inject) EmptyArray(io.datarouter.bytes.EmptyArray) DatarouterUser(io.datarouter.web.user.databean.DatarouterUser) DeprovisionedUserDto(io.datarouter.auth.web.deprovisioning.DeprovisionedUserDto) DatarouterUserEditService(io.datarouter.auth.service.DatarouterUserEditService) DatarouterAccountUserService(io.datarouter.auth.service.DatarouterAccountUserService) DatarouterAuthPaths(io.datarouter.auth.config.DatarouterAuthPaths) Mav(io.datarouter.web.handler.mav.Mav) DatarouterUserHistoryService(io.datarouter.auth.service.DatarouterUserHistoryService) DeprovisionedUser(io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUser) UserDeprovisioningStatusDto(io.datarouter.auth.web.deprovisioning.UserDeprovisioningStatusDto) StringTool(io.datarouter.util.string.StringTool) DatarouterUserByUsernameLookup(io.datarouter.web.user.databean.DatarouterUser.DatarouterUserByUsernameLookup) CopyUserListener(io.datarouter.auth.service.CopyUserListener) DeprovisionedUserKey(io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUserKey) RoleManager(io.datarouter.web.user.session.service.RoleManager) DatarouterPermissionRequestDao(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequestDao) BaseHandler(io.datarouter.web.handler.BaseHandler) SessionBasedUser(io.datarouter.web.user.session.service.SessionBasedUser) ZoneIds(io.datarouter.util.time.ZoneIds) Comparator(java.util.Comparator) DeprovisionedUserKey(io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUserKey) DeprovisionedUser(io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUser) PermissionRequestDto(io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto) ZoneId(java.time.ZoneId) SessionBasedUser(io.datarouter.web.user.session.service.SessionBasedUser)

Example 2 with PermissionRequestDto

use of io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto in project datarouter by hotpads.

the class AdminEditUserHandler method buildPermissionRequestDto.

// TODO DATAROUTER-2789
private PermissionRequestDto buildPermissionRequestDto(Entry<DatarouterPermissionRequest, Optional<String>> entry) {
    ZoneId zoneId = currentUserSessionInfoService.getZoneId(getRequest());
    DatarouterPermissionRequest request = entry.getKey();
    return new PermissionRequestDto(request.getKey().getRequestTime(), request.getRequestText(), request.getResolutionTime(), entry.getValue().orElse(null), zoneId);
}
Also used : PermissionRequestDto(io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto) ZoneId(java.time.ZoneId) DatarouterPermissionRequest(io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)

Aggregations

DatarouterPermissionRequest (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequest)2 PermissionRequestDto (io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto)2 DatarouterAuthFiles (io.datarouter.auth.config.DatarouterAuthFiles)1 DatarouterAuthPaths (io.datarouter.auth.config.DatarouterAuthPaths)1 CopyUserListener (io.datarouter.auth.service.CopyUserListener)1 DatarouterAccountUserService (io.datarouter.auth.service.DatarouterAccountUserService)1 DatarouterUserCreationService (io.datarouter.auth.service.DatarouterUserCreationService)1 DatarouterUserEditService (io.datarouter.auth.service.DatarouterUserEditService)1 DatarouterUserHistoryService (io.datarouter.auth.service.DatarouterUserHistoryService)1 DatarouterUserService (io.datarouter.auth.service.DatarouterUserService)1 UserInfo (io.datarouter.auth.service.UserInfo)1 DatarouterAccountKey (io.datarouter.auth.storage.account.DatarouterAccountKey)1 DeprovisionedUser (io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUser)1 DeprovisionedUserDao (io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUserDao)1 DeprovisionedUserKey (io.datarouter.auth.storage.deprovisioneduser.DeprovisionedUserKey)1 DatarouterPermissionRequestDao (io.datarouter.auth.storage.permissionrequest.DatarouterPermissionRequestDao)1 DatarouterUserDao (io.datarouter.auth.storage.user.DatarouterUserDao)1 DeprovisionedUserDto (io.datarouter.auth.web.deprovisioning.DeprovisionedUserDto)1 UserDeprovisioningStatusDto (io.datarouter.auth.web.deprovisioning.UserDeprovisioningStatusDto)1 EmptyArray (io.datarouter.bytes.EmptyArray)1