| | |
| | | if (!StringUtils.isEmpty(model.cookie)) {
|
| | | return model.cookie;
|
| | | }
|
| | | read();
|
| | | UserModel storedModel = users.get(model.username.toLowerCase());
|
| | | UserModel storedModel = getUserModel(model.username);
|
| | | if (storedModel == null) {
|
| | | return null;
|
| | | }
|
| | | return storedModel.cookie;
|
| | | }
|
| | |
|
| | |
| | | * @return a user object or null
|
| | | */
|
| | | @Override
|
| | | public UserModel authenticate(char[] cookie) {
|
| | | public synchronized UserModel authenticate(char[] cookie) {
|
| | | String hash = new String(cookie);
|
| | | if (StringUtils.isEmpty(hash)) {
|
| | | return null;
|
| | |
| | | UserModel model = null;
|
| | | if (cookies.containsKey(hash)) {
|
| | | model = cookies.get(hash);
|
| | | }
|
| | | |
| | | if (model != null) {
|
| | | // clone the model, otherwise all changes to this object are
|
| | | // live and unpersisted
|
| | | model = DeepCopier.copy(model);
|
| | | }
|
| | | return model;
|
| | | }
|
| | |
| | | */
|
| | | @Override
|
| | | public UserModel authenticate(String username, char[] password) {
|
| | | read();
|
| | | UserModel returnedUser = null;
|
| | | UserModel user = getUserModel(username);
|
| | | if (user == null) {
|
| | |
| | | * @return a user object or null
|
| | | */
|
| | | @Override
|
| | | public UserModel getUserModel(String username) {
|
| | | public synchronized UserModel getUserModel(String username) {
|
| | | read();
|
| | | UserModel model = users.get(username.toLowerCase());
|
| | | if (model != null) {
|
| | |
| | | * @since 1.2.0
|
| | | */
|
| | | @Override
|
| | | public boolean updateUserModels(Collection<UserModel> models) {
|
| | | public synchronized boolean updateUserModels(Collection<UserModel> models) {
|
| | | try {
|
| | | read();
|
| | | for (UserModel model : models) {
|
| | |
| | | * @return true if update is successful
|
| | | */
|
| | | @Override
|
| | | public boolean updateUserModel(String username, UserModel model) {
|
| | | public synchronized boolean updateUserModel(String username, UserModel model) {
|
| | | UserModel originalUser = null;
|
| | | try {
|
| | | read();
|
| | |
| | | * @return true if successful
|
| | | */
|
| | | @Override
|
| | | public boolean deleteUser(String username) {
|
| | | public synchronized boolean deleteUser(String username) {
|
| | | try {
|
| | | // Read realm file
|
| | | read();
|
| | |
| | | * @since 0.8.0
|
| | | */
|
| | | @Override
|
| | | public List<TeamModel> getAllTeams() {
|
| | | public synchronized List<TeamModel> getAllTeams() {
|
| | | read();
|
| | | List<TeamModel> list = new ArrayList<TeamModel>(teams.values());
|
| | | list = DeepCopier.copy(list);
|
| | |
| | | * @return list of all usernames that can bypass the access restriction
|
| | | */
|
| | | @Override
|
| | | public List<String> getTeamnamesForRepositoryRole(String role) {
|
| | | public synchronized List<String> getTeamnamesForRepositoryRole(String role) {
|
| | | List<String> list = new ArrayList<String>();
|
| | | try {
|
| | | read();
|
| | |
| | | * @return true if successful
|
| | | */
|
| | | @Override
|
| | | public boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames) {
|
| | | public synchronized boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames) {
|
| | | try {
|
| | | Set<String> specifiedTeams = new HashSet<String>();
|
| | | for (String teamname : teamnames) {
|
| | |
| | | * @since 0.8.0
|
| | | */
|
| | | @Override
|
| | | public TeamModel getTeamModel(String teamname) {
|
| | | public synchronized TeamModel getTeamModel(String teamname) {
|
| | | read();
|
| | | TeamModel model = teams.get(teamname.toLowerCase());
|
| | | if (model != null) {
|
| | |
| | | * @return list of all usernames
|
| | | */
|
| | | @Override
|
| | | public List<UserModel> getAllUsers() {
|
| | | public synchronized List<UserModel> getAllUsers() {
|
| | | read();
|
| | | List<UserModel> list = new ArrayList<UserModel>(users.values());
|
| | | list = DeepCopier.copy(list);
|
| | |
| | | * @return list of all usernames that can bypass the access restriction
|
| | | */
|
| | | @Override
|
| | | public List<String> getUsernamesForRepositoryRole(String role) {
|
| | | public synchronized List<String> getUsernamesForRepositoryRole(String role) {
|
| | | List<String> list = new ArrayList<String>();
|
| | | try {
|
| | | read();
|
| | |
| | | */
|
| | | @Override
|
| | | @Deprecated
|
| | | public boolean setUsernamesForRepositoryRole(String role, List<String> usernames) {
|
| | | public synchronized boolean setUsernamesForRepositoryRole(String role, List<String> usernames) {
|
| | | try {
|
| | | Set<String> specifiedUsers = new HashSet<String>();
|
| | | for (String username : usernames) {
|
| | |
| | | * @return true if successful
|
| | | */
|
| | | @Override
|
| | | public boolean renameRepositoryRole(String oldRole, String newRole) {
|
| | | public synchronized boolean renameRepositoryRole(String oldRole, String newRole) {
|
| | | try {
|
| | | read();
|
| | | // identify users which require role rename
|
| | |
| | | * @return true if successful
|
| | | */
|
| | | @Override
|
| | | public boolean deleteRepositoryRole(String role) {
|
| | | public synchronized boolean deleteRepositoryRole(String role) {
|
| | | try {
|
| | | read();
|
| | |
|