@Override public String formatOfficial(User user) { return StringUtils.defaultIfBlank(user.getName(), user.getLogin()); }
protected synchronized void writeLog(File file, boolean remove) { File rootDir; try { rootDir = file.getParentFile().getParentFile().getParentFile().getParentFile(); } catch (NullPointerException e) { log.error("Unable to write log: invalid file storage structure", e); return; } SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); UserSession userSession = userSessionSource.getUserSession(); String userLogin = userSession.getUser().getLogin(); String userId = userSession.getUser().getId().toString(); StringBuilder sb = new StringBuilder(); sb.append(df.format(timeSource.currentTimestamp())).append(" "); sb.append("[").append(userLogin).append("--").append(userId).append("] "); sb.append(remove ? "REMOVE" : "CREATE").append(" "); sb.append("\"").append(file.getAbsolutePath()).append("\"\n"); File logFile = new File(rootDir, "storage.log"); try { try (FileOutputStream fos = new FileOutputStream(logFile, true)) { IOUtils.write(sb.toString(), fos, StandardCharsets.UTF_8); } } catch (IOException e) { log.error("Unable to write log", e); } }
public String getCurrentSessionLogin() { return sessionSource.getUserSession().getUser().getLogin(); } }
protected String getDialogMessage(User user) { return messages.formatMainMessage( "toSubstitutedUser.msg", StringUtils.isBlank(user.getName()) ? user.getLogin() : user.getName() ); }
@Override public void init(Map<String, Object> params) { getDialogOptions().setHeight("400px"); StringBuilder sb = new StringBuilder(); for (AppPropertyEntity entity : exported) { sb.append("insert into SYS_CONFIG (ID, CREATE_TS, CREATED_BY, VERSION, NAME, VALUE_)\n"); sb.append("values ('").append(entity.getId()) .append("', current_timestamp, '") .append(uss.getUserSession().getUser().getLogin()) .append("', 0, '") .append(entity.getName()) .append("', '") .append(entity.getCurrentValue()).append("');\n\n"); } scriptArea.setValue(sb.toString()); } }
User user = event.getSource(); log.info("Handling user invalidation: {}", user.getLogin()); serverTokenStore.getAccessTokenValuesByUserLogin(user.getLogin()) .forEach(serverTokenStore::removeAccessToken); serverTokenStore.getRefreshTokenValuesByUserLogin(user.getLogin()) .forEach(serverTokenStore::removeRefreshToken); log.info("UserSessions, REST API & 'Remember me' tokens were invalidated for a user: {}", user.getLogin()); } catch (Throwable t) { log.error("An error occurred while handling user invalidation for user: {}.", user.getLogin(), t);
protected String getWarningMessage(User user) { if (user == null) return messages.getMainMessage("warning.userNotFound"); return messages.formatMainMessage( "warning.msg", StringUtils.isBlank(user.getName()) ? user.getLogin() : user.getName() ); }
public SecurityContext(UserSession session) { Preconditions.checkNotNullArgument(session, "session is null"); this.session = session; this.sessionId = session.getId(); this.user = session.getUser().getLogin(); }
protected void internalLogin() throws LoginException { PortalSecurityContext securityContext = new PortalSecurityContext(session); securityContext.setPortalApp(App.getInstance()); AppContext.setSecurityContext(securityContext); fireConnectionListeners(); if (log.isDebugEnabled()) { log.debug(String.format("Logged in: user=%s", session.getUser().getLogin())); } }
@Override public String getCurrentUserLogin() { return userSessionSource.checkCurrentUserSession() ? userSessionSource.getUserSession().getUser().getLogin() : null; }
public UserInfo(User user) { this.login = user.getLogin(); this.name = user.getName(); this.timeZone = user.getTimeZone(); this.language = user.getLanguage(); } }
public void sendSupportEmail(String message, String stackTrace) { try { User user = userSessionSource.getUserSession().getUser(); String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeSource.currentTimestamp()); Map<String, Object> binding = new HashMap<>(); binding.put("timestamp", date); binding.put("errorMessage", message); binding.put("stacktrace", stackTrace); binding.put("systemId", clientConfig.getSystemID()); binding.put("userLogin", user.getLogin()); if (MapUtils.isNotEmpty(additionalExceptionReportBinding)) { binding.putAll(additionalExceptionReportBinding); } reportService.sendExceptionReport(clientConfig.getSupportEmail(), MapUtils.unmodifiableMap(binding)); Notification.show(messages.getMainMessage("exceptionDialog.emailSent")); } catch (Throwable e) { log.error("Error sending exception report", e); Notification.show(messages.getMainMessage("exceptionDialog.emailSendingErr")); } }
@Override public List<String> getAvailableUsers() { List<String> result = new ArrayList<>(); Transaction tx = persistence.createTransaction(); try { EntityManager em = persistence.getEntityManager(); Query query = em.createQuery("select u from sec$User u"); List<User> userList = query.getResultList(); for (User user : userList) { result.add(user.getLogin()); } tx.commit(); } finally { tx.end(); } return result; }
protected void moveUsersToGroup(Set<User> selected) { Map<String, Object> lookupParams = ParamsMap.of( "exclude", groupsTree.getSelected().iterator().next(), "excludeChildren", false); AbstractLookup lookupWindow = openLookup(Group.class, items -> { if (items.size() == 1) { Group group = (Group) items.iterator().next(); List<UUID> usersForModify = new ArrayList<>(); for (User user : selected) { usersForModify.add(user.getId()); } userManagementService.moveUsersToGroup(usersForModify, group.getId()); if (selected.size() == 1) { User user = selected.iterator().next(); showNotification(formatMessage("userMovedToGroup", user.getLogin(), group.getName())); } else { showNotification(formatMessage("usersMovedToGroup", group.getName())); } usersTable.getDatasource().refresh(); } }, OpenType.DIALOG, lookupParams); lookupWindow.addCloseListener(actionId -> usersTable.requestFocus() ); }
private WebTaskExecutor(AppUI ui, BackgroundTask<T, V> runnableTask) { this.runnableTask = runnableTask; this.ui = ui; this.params = runnableTask.getParams() != null ? Collections.unmodifiableMap(runnableTask.getParams()) : Collections.emptyMap(); // copy security context this.securityContext = new SecurityContext(AppContext.getSecurityContextNN().getSession()); UserSession userSession = userSessionSource.getUserSession(); this.userLogin = userSession.getUser().getLogin(); this.future = new FutureTask<V>(this) { @Override protected void done() { WebTaskExecutor.this.ui.access(() -> handleDone() ); } }; }
public UserInfo(User user) { this.id = user.getId().toString(); this.login = user.getLogin(); this.name = user.getName(); this.firstName = user.getFirstName(); this.middleName = user.getMiddleName(); this.lastName = user.getLastName(); this.position = user.getPosition(); this.email = user.getEmail(); this.timeZone = user.getTimeZone(); this._instanceName = user.getInstanceName(); this.language = user.getLanguage(); }
/** * Pessimistic lock before start of editing, if it is configured for the entity. */ protected boolean lockIfNeeded(Entity entity) { MetaClass metaClass = getMetaClassForLocking(entity); LockInfo lockInfo = AppBeans.get(LockService.class).lock(metaClass.getName(), entity.getId().toString()); if (lockInfo == null) { justLocked = true; } else if (!(lockInfo instanceof LockNotSupported)) { showNotification( messages.getMainMessage("entityLocked.msg"), String.format(messages.getMainMessage("entityLocked.desc"), lockInfo.getUser().getLogin(), AppBeans.get(DatatypeFormatter.class).formatDateTime(lockInfo.getSince()) ), Frame.NotificationType.HUMANIZED ); return false; } return true; }
/** * Pessimistic lock before start of editing, if it is configured for the entity. */ protected boolean lockIfNeeded(Entity entity) { LockService lockService = getBeanLocator().get(LockService.class); LockInfo lockInfo = lockService.lock(getLockName(), entity.getId().toString()); if (lockInfo == null) { justLocked = true; } else if (!(lockInfo instanceof LockNotSupported)) { Messages messages = getBeanLocator().get(Messages.class); DatatypeFormatter datatypeFormatter = getBeanLocator().get(DatatypeFormatter.class); Notifications notifications = getScreenContext().getNotifications(); notifications.create(NotificationType.HUMANIZED) .withCaption(messages.getMainMessage("entityLocked.msg")) .withDescription(String.format(messages.getMainMessage("entityLocked.desc"), lockInfo.getUser().getLogin(), datatypeFormatter.formatDateTime(lockInfo.getSince()))) .show(); return false; } return true; }