mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
throw ScmSecurityException instead of RepositoryException
This commit is contained in:
@@ -55,12 +55,11 @@ import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.RepositoryHandler;
|
||||
import sonia.scm.repository.RepositoryHandlerNotFoundException;
|
||||
import sonia.scm.security.ScmSecurityException;
|
||||
import sonia.scm.security.SecurityContext;
|
||||
import sonia.scm.store.Store;
|
||||
import sonia.scm.store.StoreFactory;
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.SecurityUtil;
|
||||
import sonia.scm.web.security.WebSecurityContext;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -158,7 +157,7 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
||||
repository.getType());
|
||||
}
|
||||
|
||||
assertIsAdmin();
|
||||
SecurityUtil.assertIsAdmin(securityContextProvider);
|
||||
AssertUtil.assertIsValid(repository);
|
||||
|
||||
if (repositoryDB.contains(repository))
|
||||
@@ -490,20 +489,6 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
||||
types.add(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
private void assertIsAdmin() throws RepositoryException
|
||||
{
|
||||
if (!getCurrentUser().isAdmin())
|
||||
{
|
||||
throw new RepositoryException("admin permsission required");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -540,25 +525,6 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private User getCurrentUser()
|
||||
{
|
||||
SecurityContext context = securityContextProvider.get();
|
||||
|
||||
AssertUtil.assertIsNotNull(context);
|
||||
|
||||
User user = context.getUser();
|
||||
|
||||
AssertUtil.assertIsNotNull(user);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user