public boolean isUserInGroup(final String username, final String group) { try { return userManager.isUserInGroup(group, username); } catch (final DbException e) { log.error("Database error trying to test users group: '" + username + "'", e); } return false; }
private User getUser(String username) { try { return userManager.getUser(username); } catch (Exception e) { log.warn("Could not find user by username: " + username, e); return null; } }
public String getRemoteUsername(final HttpServletRequest request) { try { final UserLogin user = getUserManager().getCurrentUser(request); if (user != null) { return user.getUserName(); } } catch (final IllegalStateException ise) { log.error("Illegal State Exception while trying to get the remote user's name: ",ise); } return null; }
public Option<Pair<String, String>> get() { UserLogin user = userManager.getCurrentUser(request.get()); if (user == null) { return none(); } try { LoginCookie lc = userManager.preCookUrl(request.get(), "/activity", true); return some(pair("FEAUTH", lc.encode())); } catch (DbException e) { throw new RuntimeException(e); } } }
private boolean hasPermissionToView(final String username, final RepositoryHandle handle) { final UserManager um = AppConfig.getsConfig().getUserManager(); UserLogin userLogin; if (username == null) { userLogin = null; } else { try { userLogin = um.createTrustedUserLogin(username); } catch (final DbException e) { log.warn("Invalid user '" + username + "' tried to view review. Access denied."); return false; } catch (final LicensePolicyException e) { log.warn("License exception when user '" + username + "' tried to view review. Access denied."); return false; } } return um.hasPermissionToAccess(userLogin, handle); }
public boolean authenticate(final String username, final String password) { try { final UserLogin userLogin = userManager.login(CrucibleFilter.getRequest(), CrucibleFilter.getResponse(), username, password, false); if (userLogin != null) { return true; } } catch (final DbException e) { log.error("Database error trying to authenticate user '" + username + "'", e); } catch (final LicensePolicyException e) { log.error("License error trying to authenticate user '" + username + "'", e); } return false; }
public boolean currentUserCanView(RepositoryHandle repository) { Principal user = getCurrentUser(); return userManager.hasPermissionToAccess(user, repository) || (isAnon(user) && AppConfig.getsConfig().isCruAnonAccessAllowed() && repository.getCfg().isAnonAccessAllowed()); }
public boolean isSystemAdmin(final String username) { try { return getUserManager().hasSysAdminPrivileges(username); } catch (final DbException e) { log.error("Database error while checking user '" + username + "' for sysadmin permissions.", e); } return false; }
private void loginUserForThisRequest(String username, HttpServletRequest request) { try { UserLogin user = userManager.createTrustedUserLogin(username, true, false); request.setAttribute(UserManager.USER_ATTR_KEY, user); } catch (LicensePolicyException e) { log.error("License problem authenticating request", e); } catch (DbException e) { log.error("Problem authenticating request", e); } }
public void run() { // For now, we don't care what changed, we'll just expire it all // CachingManagerFactory.getCacheExpiryManagerInstance().flush(); try { AppConfig.getsConfig().getUserManager().resyncAuth(true); } catch (final Exception e) { log.warn("Unable to resync auth.", e); } }
public Collection<String> getUsersInGroup(final String groupname) throws FisheyeAccessorException { try { return AppConfig.getsConfig().getUserManager().getUsersInGroup(groupname); } catch (final DbException e) { throw new FisheyeAccessorException("Exception occured while retrieving users for group: " + groupname, e); } } }
public void addSysadminGroup(final String groupname) throws FisheyeAccessorException { try { final AdminUserConfig adminUserManager = AppConfig.getsConfig().getAdminUserManager(); adminUserManager.addGroup(groupname); AppConfig.getsConfig().saveConfig(); } catch (final IOException e) { throw new FisheyeAccessorException("IOException occured while trying to add sysadmin group: " + groupname, e); } }
public String getRemoteUsername() { UserLogin user = AppConfig.getsConfig().getUserManager().getCurrentUser(CrucibleFilter.getRequest()); if(user != null) { return user.getUserName(); } return null; }
public FEUser getUser(final String username) throws DbException { return getUserManager().getUser(username); }
public boolean authenticate(final String username, final String password) { try { final UserLogin userLogin = getUserManager().login(CrucibleFilter.getRequest(), CrucibleFilter.getResponse(), username, password, false); if (userLogin != null) { return true; } } catch (final DbException e) { log.error("Database error trying to authenticate user '" + username + "'", e); } catch (final LicensePolicyException e) { log.error("License error trying to authenticate user '" + username + "'", e); } return false; }
public boolean isUserInGroup(final String username, final String groupname) { try { return getUserManager().isUserInGroup(groupname, username); } catch (final DbException e) { log.error("Database error trying to test users group: '" + username + "'", e); } return false; }
/** * Because any FishEye user can become a sysadmin by providing the sysadmin password, we need to work for * both the case where we are trying to see if the current user has admin permission, and the case where we are * asking if a named user has admin permission. * * We return true if either: * - the named user has adminpermissions in their own right * - the named user has the same name as the current user, and the current request has admin permission. */ public boolean isSystemAdmin(final String username) { try { return userManager.hasSysAdminPrivileges(username) || (currentUserIs(username) && LoginInterceptor.isAdminUser(CrucibleFilter.getRequest())); } catch (final DbException e) { log.error("Database error while checking user '" + username + "' for sysadmin permissions.", e); } return false; }
public void loginUserForThisRequest(String username, HttpServletRequest request) { try { UserLogin user = getUserManager().createTrustedUserLogin(username, true, false); request.setAttribute(UserManager.USER_ATTR_KEY, user); } catch (LicensePolicyException e) { log.error("License problem authenticating request", e); } catch (DbException e) { log.error("Problem authenticating request", e); } } }
public Principal resolve(final String username) throws UserResolutionException { if (username == null) return null; try { if (userManager.getUser(username) == null) { log.error("Could not resolve user '" + username + "'"); return null; } } catch (final DbException e) { throw new UserResolutionException("Exception resolving user '" + username + "'.", e); } return new SimplePrincipal(username); }
public UserProfile getUserProfile(String username) { try { User user = userManager.getUser(username); if (user != null) { return new FisheyeUserProfile(user.getUsername(), user.getDisplayName(), user.getEmail()); } else { return null; } } catch (DbException e) { throw new RuntimeException("Error retrieving user '" + username + "'", e); } }