Skip to content

The Unified and Autonomous Development Platform

Refactored permissions and roles.

robin shineb3bf4e00adae
diff --git a/commons.security/src/main/java/com/pmease/commons/security/AbstractRealm.java b/commons.security/src/main/java/com/pmease/commons/security/AbstractRealm.java
index 749d5ea895..19a3129ffa 100644
--- a/commons.security/src/main/java/com/pmease/commons/security/AbstractRealm.java
+++ b/commons.security/src/main/java/com/pmease/commons/security/AbstractRealm.java
@@ -25,7 +25,7 @@ public abstract class AbstractRealm<T extends AbstractUser> extends AuthorizingR
private GeneralDao generalDao;
- protected final Class<T> userClass;
+ private final Class<T> userClass;
@SuppressWarnings("unchecked")
@Inject
@@ -46,7 +46,7 @@ public abstract class AbstractRealm<T extends AbstractUser> extends AuthorizingR
@Override
public Collection<String> getStringPermissions() {
- return doGetPermissions(userId);
+ return new HashSet<String>();
}
@Override
@@ -56,7 +56,7 @@ public abstract class AbstractRealm<T extends AbstractUser> extends AuthorizingR
@Override
public Collection<Permission> getObjectPermissions() {
- return new HashSet<Permission>();
+ return permissionsOf(userId);
}
};
}
@@ -68,7 +68,7 @@ public abstract class AbstractRealm<T extends AbstractUser> extends AuthorizingR
* @return
* Collection of {@link WildcardPermission} string
*/
- protected abstract Collection<String> doGetPermissions(Long userId);
+ protected abstract Collection<Permission> permissionsOf(Long userId);
/**
* Retrieve {@link AuthenticationInfo} of specified token.
@@ -82,16 +82,16 @@ public abstract class AbstractRealm<T extends AbstractUser> extends AuthorizingR
* @throws
* AuthenticationException
*/
- protected AuthenticationInfo doGetAuthenticationInfo(UsernamePasswordToken token) throws AuthenticationException {
+ protected AuthenticationInfo authenticationInfoOf(UsernamePasswordToken token) throws AuthenticationException {
DetachedCriteria criteria = DetachedCriteria.forClass(userClass);
- criteria.add(Restrictions.eq("loginName", token.getUsername()));
+ criteria.add(Restrictions.eq("name", token.getUsername()));
return (AbstractUser) generalDao.find(criteria);
}
@Override
protected final AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
- return doGetAuthenticationInfo((UsernamePasswordToken) token);
+ return authenticationInfoOf((UsernamePasswordToken) token);
}
@Override
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/UserRealm.java b/gitop.core/src/main/java/com/pmease/gitop/core/UserRealm.java
index 212d379a84..4f7b363696 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/UserRealm.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/UserRealm.java
@@ -1,31 +1,44 @@
package com.pmease.gitop.core;
-import java.util.Arrays;
+import java.util.ArrayList;
import java.util.Collection;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.shiro.authc.credential.CredentialsMatcher;
+import org.apache.shiro.authz.Permission;
import com.pmease.commons.persistence.dao.GeneralDao;
import com.pmease.commons.security.AbstractRealm;
+import com.pmease.gitop.core.entitymanager.TeamManager;
+import com.pmease.gitop.core.entitymanager.UserManager;
+import com.pmease.gitop.core.model.Team;
import com.pmease.gitop.core.model.User;
@Singleton
public class UserRealm extends AbstractRealm<User> {
+ private final TeamManager teamManager;
+
+ private final UserManager userManager;
+
@Inject
- public UserRealm(GeneralDao generalDao, CredentialsMatcher credentialsMatcher) {
+ public UserRealm(GeneralDao generalDao, CredentialsMatcher credentialsMatcher,
+ TeamManager teamManager, UserManager userManager) {
super(generalDao, credentialsMatcher);
+ this.teamManager = teamManager;
+ this.userManager = userManager;
}
@Override
- protected Collection<String> doGetPermissions(Long userId) {
- if (userId == 0L)
- return Arrays.asList("read");
- else
- return Arrays.asList("*");
+ protected Collection<Permission> permissionsOf(Long userId) {
+ Collection<Permission> permissions = new ArrayList<Permission>();
+
+ permissions.add(userManager.load(userId).getAuthorization().getRole());
+ for (Team team: teamManager.getTeams(userId))
+ permissions.add(team);
+ return permissions;
}
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/TeamManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/TeamManager.java
new file mode 100644
index 0000000000..954524053f
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/TeamManager.java
@@ -0,0 +1,15 @@
+package com.pmease.gitop.core.entitymanager;
+
+import java.util.Collection;
+
+import com.google.inject.ImplementedBy;
+import com.pmease.commons.persistence.dao.GenericDao;
+import com.pmease.gitop.core.entitymanager.impl.DefaultTeamManager;
+import com.pmease.gitop.core.model.Team;
+
+@ImplementedBy(DefaultTeamManager.class)
+public interface TeamManager extends GenericDao<Team> {
+
+ Collection<Team> getTeams(Long userId);
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/UserManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/UserManager.java
index d5517f181a..ac2cb3a01e 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/UserManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/UserManager.java
@@ -1,8 +1,11 @@
package com.pmease.gitop.core.entitymanager;
+import com.google.inject.ImplementedBy;
import com.pmease.commons.persistence.dao.GenericDao;
+import com.pmease.gitop.core.entitymanager.impl.DefaultUserManager;
import com.pmease.gitop.core.model.User;
+@ImplementedBy(DefaultUserManager.class)
public interface UserManager extends GenericDao<User> {
/**
* Find root user in the system.
@@ -10,5 +13,5 @@ public interface UserManager extends GenericDao<User> {
* @return
* root user of the system, or null if root user has not been populated
*/
- public User findRoot();
+ User getRootUser();
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultTeamManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultTeamManager.java
new file mode 100644
index 0000000000..27e1033bb4
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultTeamManager.java
@@ -0,0 +1,39 @@
+package com.pmease.gitop.core.entitymanager.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.hibernate.Session;
+
+import com.pmease.commons.persistence.Transactional;
+import com.pmease.commons.persistence.dao.DefaultGenericDao;
+import com.pmease.commons.persistence.dao.GeneralDao;
+import com.pmease.gitop.core.entitymanager.TeamManager;
+import com.pmease.gitop.core.entitymanager.UserManager;
+import com.pmease.gitop.core.model.Team;
+import com.pmease.gitop.core.model.Membership;
+
+@Singleton
+public class DefaultTeamManager extends DefaultGenericDao<Team> implements TeamManager {
+
+ private final UserManager userManager;
+
+ public DefaultTeamManager(GeneralDao generalDao, Provider<Session> sessionProvider, UserManager userManager) {
+ super(generalDao, sessionProvider);
+ this.userManager = userManager;
+ }
+
+ @Transactional
+ @Override
+ public Collection<Team> getTeams(Long userId) {
+ Collection<Team> teams = new ArrayList<Team>();
+ for (Membership membership: userManager.load(userId).getMemberships())
+ teams.add(membership.getTeam());
+
+ return teams;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultUserManager.java b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultUserManager.java
index 6fb29b87e1..abec2dfb09 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultUserManager.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/entitymanager/impl/DefaultUserManager.java
@@ -1,33 +1,41 @@
package com.pmease.gitop.core.entitymanager.impl;
import javax.inject.Provider;
+import javax.inject.Singleton;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
+import com.google.common.base.Preconditions;
import com.pmease.commons.persistence.Transactional;
import com.pmease.commons.persistence.dao.DefaultGenericDao;
import com.pmease.commons.persistence.dao.GeneralDao;
import com.pmease.gitop.core.entitymanager.UserManager;
import com.pmease.gitop.core.model.User;
+@Singleton
public class DefaultUserManager extends DefaultGenericDao<User> implements UserManager {
-
+ private volatile User rootUser;
+
public DefaultUserManager(GeneralDao generalDao, Provider<Session> sessionProvider) {
super(generalDao, sessionProvider);
}
@Transactional
@Override
- public User findRoot() {
- Criteria criteria = getSession().createCriteria(User.class).addOrder(Order.asc("id"));
-
- /* the first created user should be root user */
- criteria.setFirstResult(0);
- criteria.setMaxResults(1);
- return (User) criteria.uniqueResult();
+ public User getRootUser() {
+ if (rootUser == null) {
+ Criteria criteria = getSession().createCriteria(User.class).addOrder(Order.asc("id"));
+
+ /* the first created user should be root user */
+ criteria.setFirstResult(0);
+ criteria.setMaxResults(1);
+ rootUser = (User) criteria.uniqueResult();
+ Preconditions.checkNotNull(rootUser);
+ }
+ return rootUser;
}
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/Authorization.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/Authorization.java
new file mode 100644
index 0000000000..b8b30f5af4
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/Authorization.java
@@ -0,0 +1,43 @@
+package com.pmease.gitop.core.model;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+
+import org.hibernate.annotations.FetchMode;
+
+import com.pmease.commons.persistence.AbstractEntity;
+import com.pmease.gitop.core.model.role.Role;
+
+@SuppressWarnings("serial")
+@Entity
+ usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
+public class Authorization extends AbstractEntity {
+
+ @OneToOne(fetch=FetchType.EAGER)
+ @org.hibernate.annotations.Fetch(FetchMode.SELECT)
+ @JoinColumn(nullable=false)
+ @org.hibernate.annotations.ForeignKey(name="FK_AUTH_USER")
+ private User user;
+
+ private Role role;
+
+ public User getUser() {
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+ public Role getRole() {
+ return role;
+ }
+
+ public void setRole(Role role) {
+ this.role = role;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchOperation.java
deleted file mode 100644
index 315cb571d7..0000000000
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchOperation.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.pmease.gitop.core.model;
-
-/**
- * This class represents operation against a certain repository branch. Typical
- * branch operations include pull and push.
- *
- * @author robin
- *
- */
-public interface BranchOperation {
- /**
- * Checks whether or not passed operation is a subset of current operation
- * as parameter.
- * <p>
- * This will be used to check if a certain operation instance should match a permission entry.
- * For instance, push operation with file path <code>src/com/example/Core.java</code> is a
- * subset of push operation with file path <code>src/&#42;&#42;/&#42;.java</code>
- *
- * @param branchOperation
- * the operation to be checked if it is a subset of current operation
- * @return
- * true if passed operation is a subset of current operation; false otherwise
- */
- boolean implies(BranchOperation branchOperation);
-}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchPermission.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchPermission.java
deleted file mode 100644
index aaec1b646c..0000000000
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/BranchPermission.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.pmease.gitop.core.model;
-
-import com.pmease.commons.util.PathUtils;
-import com.pmease.commons.util.StringUtils;
-
-public class BranchPermission {
-
- private String repositoryNamePattern = "*";
-
- private String branchNamePattern = "**";
-
- private BranchOperation branchOperation = new PullFromBranch();
-
- private boolean allow;
-
- public String getRepositoryNamePattern() {
- return repositoryNamePattern;
- }
-
- public void setRepositoryNamePattern(String repositoryNamePattern) {
- this.repositoryNamePattern = repositoryNamePattern;
- }
-
- public String getBranchNamePattern() {
- return branchNamePattern;
- }
-
- public void setBranchNamePattern(String branchNamePattern) {
- this.branchNamePattern = branchNamePattern;
- }
-
- public BranchOperation getBranchOperation() {
- return branchOperation;
- }
-
- public void setBranchOperation(BranchOperation branchOperation) {
- this.branchOperation = branchOperation;
- }
-
- public boolean isAllow() {
- return allow;
- }
-
- public void setAllow(boolean allow) {
- this.allow = allow;
- }
-
- Boolean permits(String repositoryName, String branchName, BranchOperation branchOperation) {
- if (StringUtils.wildcardMatch(getRepositoryNamePattern(), repositoryName)
- && PathUtils.match(getBranchNamePattern(), branchName)
- && getBranchOperation().implies(branchOperation)) {
- return allow;
- } else {
- return null;
- }
- }
-}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/TeamMembership.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/Membership.java
similarity index 85%
rename from gitop.core/src/main/java/com/pmease/gitop/core/model/TeamMembership.java
rename to gitop.core/src/main/java/com/pmease/gitop/core/model/Membership.java
index bb264b39be..100593e5fc 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/TeamMembership.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/Membership.java
@@ -18,18 +18,18 @@ import com.pmease.commons.persistence.AbstractEntity;
})
@org.hibernate.annotations.Cache(
usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
-public class TeamMembership extends AbstractEntity {
+public class Membership extends AbstractEntity {
@ManyToOne(fetch=FetchType.EAGER)
@org.hibernate.annotations.Fetch(FetchMode.SELECT)
@JoinColumn(nullable=false)
- @org.hibernate.annotations.ForeignKey(name="FK_TMEM_USER")
+ @org.hibernate.annotations.ForeignKey(name="FK_MEM_USER")
private User user;
@ManyToOne(fetch=FetchType.EAGER)
@org.hibernate.annotations.Fetch(FetchMode.SELECT)
@JoinColumn(nullable=false)
- @org.hibernate.annotations.ForeignKey(name="FK_TMEM_TEAM")
+ @org.hibernate.annotations.ForeignKey(name="FK_MEM_TEAM")
private Team team;
public User getUser() {
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/PullFromBranch.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/PullFromBranch.java
deleted file mode 100644
index a99e0e1934..0000000000
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/PullFromBranch.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.pmease.gitop.core.model;
-
-public class PullFromBranch implements BranchOperation {
-
- @Override
- public boolean implies(BranchOperation branchOperation) {
- return branchOperation instanceof PullFromBranch;
- }
-
-}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/PullRequest.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/PullRequest.java
deleted file mode 100644
index 25af136517..0000000000
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/PullRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.pmease.gitop.core.model;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-
-import org.hibernate.annotations.FetchMode;
-
-import com.pmease.commons.persistence.AbstractEntity;
-
-@Entity
-@SuppressWarnings("serial")
-public class PullRequest extends AbstractEntity {
-
- @ManyToOne(fetch=FetchType.EAGER)
- @org.hibernate.annotations.Fetch(FetchMode.SELECT)
- @JoinColumn(nullable=false)
- @org.hibernate.annotations.ForeignKey(name="FK_PR_INI")
- private User initiator;
-
- public User getInitiator() {
- return initiator;
- }
-
- public void setInitiator(User initiator) {
- this.initiator = initiator;
- }
-
-}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/PushToBranch.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/PushToBranch.java
deleted file mode 100644
index 0e571568b6..0000000000
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/PushToBranch.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.pmease.gitop.core.model;
-
-import com.pmease.commons.util.PathUtils;
-
-public class PushToBranch implements BranchOperation {
-
- private String filePath = "**";
-
- public String getFilePath() {
- return filePath;
- }
-
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
-
- @Override
- public boolean implies(BranchOperation branchOperation) {
- if (branchOperation instanceof PushToBranch) {
- PushToBranch pushToBranch = (PushToBranch) branchOperation;
- return PathUtils.match(getFilePath(), pushToBranch.getFilePath());
- } else {
- return false;
- }
- }
-
-}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/Team.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/Team.java
index a7bfe179a2..c232b104e5 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/Team.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/Team.java
@@ -11,9 +11,17 @@ import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
+import org.apache.shiro.authz.Permission;
import org.hibernate.annotations.FetchMode;
+import com.google.common.base.Optional;
import com.pmease.commons.persistence.AbstractEntity;
+import com.pmease.gitop.core.model.projectpermission.OperationOfRepositorySet;
+import com.pmease.gitop.core.model.projectpermission.PrivilegedOperation;
+import com.pmease.gitop.core.model.projectpermission.ProjectOperation;
+import com.pmease.gitop.core.model.projectpermission.ProjectPermission;
+import com.pmease.gitop.core.model.projectpermission.PullFromProject;
+import com.pmease.gitop.core.model.projectpermission.WholeProjectOperation;
/**
* Every user can define its teams to authorize permissions to his/her repositories.
@@ -26,23 +34,25 @@ import com.pmease.commons.persistence.AbstractEntity;
@org.hibernate.annotations.Cache(
usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
@Table(uniqueConstraints={
- @UniqueConstraint(columnNames={"owner", "name"})
+ @UniqueConstraint(columnNames={"project", "name"})
})
@SuppressWarnings("serial")
-public class Team extends AbstractEntity {
+public class Team extends AbstractEntity implements Permission {
@Column(nullable=false)
private String name;
private String description;
- private List<BranchPermission> branchPermissions = new ArrayList<BranchPermission>();
+ private Optional<? extends WholeProjectOperation> authorizedWholeProjectAction = Optional.of(new PullFromProject());
+
+ private List<OperationOfRepositorySet> authorizedRepositoryActions = new ArrayList<OperationOfRepositorySet>();
@ManyToOne(fetch=FetchType.EAGER)
@org.hibernate.annotations.Fetch(FetchMode.SELECT)
@JoinColumn(nullable=false)
- @org.hibernate.annotations.ForeignKey(name="FK_TEAM_OWNER")
- private User owner;
+ @org.hibernate.annotations.ForeignKey(name="FK_TEAM_PROJ")
+ private User project;
public String getName() {
return name;
@@ -60,53 +70,54 @@ public class Team extends AbstractEntity {
this.description = description;
}
- public User getOwner() {
- return owner;
+ public User getProject() {
+ return project;
+ }
+
+ public void setProject(User project) {
+ this.project = project;
}
- public void setOwner(User owner) {
- this.owner = owner;
+ public Optional<? extends WholeProjectOperation> getAuthorizedWholeProjectAction() {
+ return authorizedWholeProjectAction;
}
- public List<BranchPermission> getBranchPermissions() {
- return branchPermissions;
+ public void setAuthorizedWholeProjectAction(
+ Optional<? extends WholeProjectOperation> authorizedWholeProjectAction) {
+ this.authorizedWholeProjectAction = authorizedWholeProjectAction;
}
- public void setBranchPermissions(List<BranchPermission> branchPermissions) {
- this.branchPermissions = branchPermissions;
+ public List<OperationOfRepositorySet> getAuthorizedRepositoryActions() {
+ return authorizedRepositoryActions;
}
- /**
- * Check whether or not a specified branch operation is permitted.
- * <p>
- * Supplied repository name, branch name and the operation will be matched against permission list
- * to find the first matching entry. If found, the <code>allow</code> flag of that entry will be returned
- * to indicate whether or not the operation is permitted. If no permission entry matches supplied
- * parameters, a null value will be returned to indicate that this team can not determine whether
- * or not the operation should be permitted.
- *
- * @param repositoryName
- * name of the repository name to operate against
- * @param branchName
- * name of the branch to operate against
- * @param branchOperation
- * operation to be checked
- * @return
- * true if the operation matches a permissive permission entry, false if the operation
- * matches a prohibitory permission entry, null if no permission entry can be matched.
- * In case of returning null, caller should determine the permission through other means,
- * such as continue to check other teams, or resort to default permission
- */
- public Boolean permits(String repositoryName, String branchName, BranchOperation branchOperation) {
- Boolean permits = null;
-
- for (BranchPermission permission: getBranchPermissions()) {
- permits = permission.permits(repositoryName, branchName, branchOperation);
- if (permits != null)
- return permits;
+ public void setAuthorizedRepositoryActions(
+ List<OperationOfRepositorySet> authorizedRepositoryActions) {
+ this.authorizedRepositoryActions = authorizedRepositoryActions;
+ }
+
+ @Override
+ public boolean implies(Permission permission) {
+ if (permission instanceof ProjectPermission) {
+ ProjectPermission projectPermission = (ProjectPermission) permission;
+ if (projectPermission.getProject().getId().equals(getProject().getId())) {
+ if (getAuthorizedWholeProjectAction().isPresent()) {
+ ProjectOperation projectAction = getAuthorizedWholeProjectAction().get();
+ if (projectAction.can(projectPermission.getOperation()))
+ return true;
+ }
+ for (PrivilegedOperation action: getAuthorizedRepositoryActions()) {
+ if (action.can(projectPermission.getOperation()))
+ return true;
+ }
+
+ return false;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
}
-
- return permits;
}
-
+
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/User.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/User.java
index 8836ea5839..03d0aeba38 100644
--- a/gitop.core/src/main/java/com/pmease/gitop/core/model/User.java
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/User.java
@@ -1,28 +1,55 @@
package com.pmease.gitop.core.model;
+import java.util.Collection;
+
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+import org.hibernate.annotations.FetchMode;
import com.pmease.commons.security.AbstractUser;
+/**
+ * This class represents an user (or project) in the system. In Gitop, users and projects
+ * are the same thing. To create a project, one can register a new user account representing
+ * the project itself, and then under that user account, create repositories and organize
+ * teams to do project cooperation.
+ *
+ * @author robin
+ *
+ */
@SuppressWarnings("serial")
@Entity
@org.hibernate.annotations.Cache(
usage=org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
public class User extends AbstractUser {
+
+ @OneToMany(mappedBy="user")
+ private Collection<Membership> memberships;
- private boolean project;
-
- /**
- * Whether or not this user represents a project.
- *
- * @return
- */
- public boolean isProject() {
- return project;
+ @OneToOne(fetch=FetchType.EAGER)
+ @org.hibernate.annotations.Fetch(FetchMode.SELECT)
+ @JoinColumn(nullable=false)
+ @org.hibernate.annotations.ForeignKey(name="FK_USER_AUTH")
+ private Authorization authorization;
+
+ public Collection<Membership> getMemberships() {
+ return memberships;
}
- public void setProject(boolean project) {
- this.project = project;
+ public void setMemberships(Collection<Membership> memberships) {
+ this.memberships = memberships;
}
-
+
+ public Authorization getAuthorization() {
+ return authorization;
+ }
+
+ public void setAuthorization(Authorization authorization) {
+ this.authorization = authorization;
+ }
+
}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchAdministration.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchAdministration.java
new file mode 100644
index 0000000000..4fad666457
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchAdministration.java
@@ -0,0 +1,10 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public class BranchAdministration implements BranchOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof BranchOperation;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchOperation.java
new file mode 100644
index 0000000000..52e0227e7f
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/BranchOperation.java
@@ -0,0 +1,5 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public interface BranchOperation extends PrivilegedOperation {
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfBranchSet.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfBranchSet.java
new file mode 100644
index 0000000000..863fbbd10f
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfBranchSet.java
@@ -0,0 +1,46 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+import com.pmease.commons.util.StringUtils;
+
+public class OperationOfBranchSet implements RepositoryOperation {
+
+ private String branchNames;
+
+ private BranchOperation branchOperation;
+
+ public OperationOfBranchSet(String branchNames, BranchOperation branchOperation) {
+ this.branchNames = branchNames;
+ this.branchOperation = branchOperation;
+ }
+
+ public String getBranchNames() {
+ return branchNames;
+ }
+
+ public void setBranchNames(String branchNames) {
+ this.branchNames = branchNames;
+ }
+
+ public BranchOperation getBranchOperation() {
+ return branchOperation;
+ }
+
+ public void setBranchOperation(BranchOperation branchOperation) {
+ this.branchOperation = branchOperation;
+ }
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ if (operation instanceof OperationOfBranchSet) {
+ OperationOfBranchSet operationOfBranchSet = (OperationOfBranchSet) operation;
+ if (StringUtils.wildcardMatch(getBranchNames(), operationOfBranchSet.getBranchNames())) {
+ return branchOperation.can(operationOfBranchSet.getBranchOperation());
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfRepositorySet.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfRepositorySet.java
new file mode 100644
index 0000000000..18e7c88a0f
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/OperationOfRepositorySet.java
@@ -0,0 +1,46 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+import com.pmease.commons.util.StringUtils;
+
+public class OperationOfRepositorySet implements PrivilegedOperation {
+
+ private String repositoryNames;
+
+ private RepositoryOperation repositoryOperation;
+
+ public OperationOfRepositorySet(String repositoryNames, RepositoryOperation repositoryOperation) {
+ this.repositoryNames = repositoryNames;
+ this.repositoryOperation = repositoryOperation;
+ }
+
+ public String getRepositoryNames() {
+ return repositoryNames;
+ }
+
+ public void setRepositoryNames(String repositoryNames) {
+ this.repositoryNames = repositoryNames;
+ }
+
+ public RepositoryOperation getRepositoryOperation() {
+ return repositoryOperation;
+ }
+
+ public void setRepositoryPermission(RepositoryOperation repositoryOperation) {
+ this.repositoryOperation = repositoryOperation;
+ }
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ if (operation instanceof OperationOfRepositorySet) {
+ OperationOfRepositorySet operationOfRepositorySet = (OperationOfRepositorySet) operation;
+ if (StringUtils.wildcardMatch(getRepositoryNames(), operationOfRepositorySet.getRepositoryNames())) {
+ return getRepositoryOperation().can(operationOfRepositorySet.getRepositoryOperation());
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PrivilegedOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PrivilegedOperation.java
new file mode 100644
index 0000000000..8480e78612
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PrivilegedOperation.java
@@ -0,0 +1,13 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+/**
+ * This interface stands for an operation requires permissions.
+ *
+ */
+public interface PrivilegedOperation {
+ /**
+ * Whether or not users with permission to perform current operation can perform
+ * specified operation.
+ */
+ boolean can(PrivilegedOperation operation);
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectAdministration.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectAdministration.java
new file mode 100644
index 0000000000..9e971b0afe
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectAdministration.java
@@ -0,0 +1,18 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+
+/**
+ * Project administrators can do anything inside a project.
+ *
+ * @author robin
+ *
+ */
+public class ProjectAdministration implements WholeProjectOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof ProjectAdministration
+ || new PushToProject().can(operation);
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectOperation.java
new file mode 100644
index 0000000000..f166d0503a
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectOperation.java
@@ -0,0 +1,5 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public interface ProjectOperation extends PrivilegedOperation {
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectPermission.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectPermission.java
new file mode 100644
index 0000000000..40c76c5f95
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/ProjectPermission.java
@@ -0,0 +1,39 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+import com.pmease.gitop.core.model.User;
+
+/**
+ * This interface serves as a mark up interface to indicate that all permissions
+ * implementing this interface are project level permissions.
+ *
+ * @author robin
+ *
+ */
+public class ProjectPermission {
+
+ private User project;
+
+ private ProjectOperation operation;
+
+ public ProjectPermission(User project, ProjectOperation operation) {
+ this.project = project;
+ this.operation = operation;
+ }
+
+ public User getProject() {
+ return project;
+ }
+
+ public void setProject(User project) {
+ this.project = project;
+ }
+
+ public ProjectOperation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(ProjectOperation operation) {
+ this.operation = operation;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromBranch.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromBranch.java
new file mode 100644
index 0000000000..d072d29a15
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromBranch.java
@@ -0,0 +1,10 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public class PullFromBranch implements BranchOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof PullFromBranch;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromProject.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromProject.java
new file mode 100644
index 0000000000..ecafe6d494
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PullFromProject.java
@@ -0,0 +1,11 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public class PullFromProject implements WholeProjectOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof PullFromProject
+ || new OperationOfRepositorySet("*", new OperationOfBranchSet("**", new PullFromBranch())).can(operation);
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToBranch.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToBranch.java
new file mode 100644
index 0000000000..4e5ddebc00
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToBranch.java
@@ -0,0 +1,33 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+import com.pmease.commons.util.PathUtils;
+
+public class PushToBranch implements BranchOperation {
+
+ private String filePaths;
+
+ public PushToBranch(String filePaths) {
+ this.filePaths = filePaths;
+ }
+
+ public String getFilePaths() {
+ return filePaths;
+ }
+
+ public void setFilePaths(String filePaths) {
+ this.filePaths = filePaths;
+ }
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ if (operation instanceof PullFromBranch) {
+ return true;
+ } else if (operation instanceof PushToBranch) {
+ PushToBranch pushOperation = (PushToBranch) operation;
+ return PathUtils.match(filePaths, pushOperation.getFilePaths());
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToProject.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToProject.java
new file mode 100644
index 0000000000..2d4cc1b800
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/PushToProject.java
@@ -0,0 +1,12 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public class PushToProject implements WholeProjectOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof PushToProject
+ || new PullFromProject().can(operation)
+ || new OperationOfRepositorySet("*", new OperationOfBranchSet("**", new PushToBranch("**"))).can(operation);
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryAdministration.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryAdministration.java
new file mode 100644
index 0000000000..b1db2a7f56
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryAdministration.java
@@ -0,0 +1,10 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public class RepositoryAdministration implements RepositoryOperation {
+
+ @Override
+ public boolean can(PrivilegedOperation operation) {
+ return operation instanceof RepositoryOperation;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryOperation.java
new file mode 100644
index 0000000000..f86e8ab8b6
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/RepositoryOperation.java
@@ -0,0 +1,4 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public interface RepositoryOperation extends ProjectOperation {
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/WholeProjectOperation.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/WholeProjectOperation.java
new file mode 100644
index 0000000000..2ebb484931
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/projectpermission/WholeProjectOperation.java
@@ -0,0 +1,5 @@
+package com.pmease.gitop.core.model.projectpermission;
+
+public interface WholeProjectOperation extends ProjectOperation {
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/role/LimitedUser.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/LimitedUser.java
new file mode 100644
index 0000000000..d97077784b
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/LimitedUser.java
@@ -0,0 +1,24 @@
+package com.pmease.gitop.core.model.role;
+
+import org.apache.shiro.authz.Permission;
+
+
+/**
+ * Limited users can only browse the system without any other permissions.
+ * <p>
+ * They are not permitted to create repositories and teams.
+ * Since they can not create repositories, they will not be able to fork existing
+ * repositories even if those repositories are allowed to be forked.
+ *
+ * @author robin
+ *
+ */
+@SuppressWarnings("serial")
+public class LimitedUser implements Role {
+
+ @Override
+ public boolean implies(Permission permission) {
+ return permission instanceof LimitedUser;
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/role/NormalUser.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/NormalUser.java
new file mode 100644
index 0000000000..e902055395
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/NormalUser.java
@@ -0,0 +1,24 @@
+package com.pmease.gitop.core.model.role;
+
+import org.apache.shiro.authz.Permission;
+
+/**
+ * Normal users have all permissions of restricted users, and can also create their
+ * own repositories as well as being able to create teams.
+ * <p>
+ * They will be able to fork existing repositories if those repositories are allowed
+ * to be forked.
+ *
+ * @author robin
+ *
+ */
+@SuppressWarnings("serial")
+public class NormalUser implements Role {
+
+ @Override
+ public boolean implies(Permission permission) {
+ return permission instanceof NormalUser
+ || new LimitedUser().implies(permission);
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/role/PowerUser.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/PowerUser.java
new file mode 100644
index 0000000000..a1ed490d79
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/PowerUser.java
@@ -0,0 +1,22 @@
+package com.pmease.gitop.core.model.role;
+
+import org.apache.shiro.authz.Permission;
+
+/**
+ * Power users can do anything as system administrator except that they can not
+ * manage other user accounts and can not access repositories not authorized by
+ * the owners.
+ *
+ * @author robin
+ *
+ */
+@SuppressWarnings("serial")
+public class PowerUser implements Role {
+
+ @Override
+ public boolean implies(Permission permission) {
+ return permission instanceof PowerUser
+ || new NormalUser().implies(permission);
+ }
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/role/Role.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/Role.java
new file mode 100644
index 0000000000..3b74667ff4
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/Role.java
@@ -0,0 +1,9 @@
+package com.pmease.gitop.core.model.role;
+
+import java.io.Serializable;
+
+import org.apache.shiro.authz.Permission;
+
+public interface Role extends Permission, Serializable {
+
+}
diff --git a/gitop.core/src/main/java/com/pmease/gitop/core/model/role/SystemAdministrator.java b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/SystemAdministrator.java
new file mode 100644
index 0000000000..e0e75c350c
--- /dev/null
+++ b/gitop.core/src/main/java/com/pmease/gitop/core/model/role/SystemAdministrator.java
@@ -0,0 +1,13 @@
+package com.pmease.gitop.core.model.role;
+
+import org.apache.shiro.authz.Permission;
+
+@SuppressWarnings("serial")
+public class SystemAdministrator implements Role {
+
+ @Override
+ public boolean implies(Permission p) {
+ return true;
+ }
+
+}
diff --git a/gitop.core/src/test/java/com/pmease/gitop/core/model/PermissionTest.java b/gitop.core/src/test/java/com/pmease/gitop/core/model/PermissionTest.java
new file mode 100644
index 0000000000..73c7c21564
--- /dev/null
+++ b/gitop.core/src/test/java/com/pmease/gitop/core/model/PermissionTest.java
@@ -0,0 +1,11 @@
+package com.pmease.gitop.core.model;
+
+import org.junit.Test;
+
+public class PermissionTest {
+
+ @Test
+ public void shouldOnlyPermitAuthorizedOperations() {
+ }
+
+}
diff --git a/gitop.core/src/test/java/com/pmease/gitop/core/model/TeamTest.java b/gitop.core/src/test/java/com/pmease/gitop/core/model/TeamTest.java
deleted file mode 100644
index ce873b8bf0..0000000000
--- a/gitop.core/src/test/java/com/pmease/gitop/core/model/TeamTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.pmease.gitop.core.model;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class TeamTest {
-
- @Test
- public void shouldOnlyPermitAuthorizedBranchOperations() {
- Team team = new Team();
-
- BranchPermission permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("master");
- permission.setBranchOperation(new PullFromBranch());
- permission.setAllow(false);
- team.getBranchPermissions().add(permission);
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("*");
- permission.setBranchOperation(new PullFromBranch());
- permission.setAllow(true);
- team.getBranchPermissions().add(permission);
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("qa");
- permission.setBranchOperation(new PullFromBranch());
- permission.setAllow(false);
- team.getBranchPermissions().add(permission);
-
- assertFalse(team.permits("repo1", "master", new PullFromBranch()));
- assertTrue(team.permits("repo1", "development", new PullFromBranch()));
- assertTrue(team.permits("repo1", "qa", new PullFromBranch()));
- assertNull(team.permits("repo1", "master", new PushToBranch()));
- assertNull(team.permits("repo1", "devleopment", new PushToBranch()));
-
- team.getBranchPermissions().clear();
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("*");
- PushToBranch pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("doc/**");
- permission.setBranchOperation(pushToBranch);
- permission.setAllow(true);
- team.getBranchPermissions().add(permission);
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("*");
- pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("**");
- permission.setBranchOperation(pushToBranch);
- permission.setAllow(false);
- team.getBranchPermissions().add(permission);
-
- pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("doc/user_guide.pdf");
- assertTrue(team.permits("repo2", "master", pushToBranch));
-
- pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("src/program/Core.java");
- assertFalse(team.permits("repo2", "master", pushToBranch));
-
- assertNull(team.permits("repo2", "master", new PullFromBranch()));
-
- team.getBranchPermissions().clear();
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("repo?");
- permission.setBranchNamePattern("*");
- pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("doc/**");
- permission.setBranchOperation(pushToBranch);
- permission.setAllow(true);
- team.getBranchPermissions().add(permission);
-
- permission = new BranchPermission();
- permission.setRepositoryNamePattern("*");
- permission.setBranchNamePattern("*");
- permission.setBranchOperation(new PullFromBranch());
- permission.setAllow(false);
- team.getBranchPermissions().add(permission);
-
- pushToBranch = new PushToBranch();
- pushToBranch.setFilePath("doc/api/index.html");
- assertTrue(team.permits("repo2", "master", pushToBranch));
- assertFalse(team.permits("myrepo", "master", new PullFromBranch()));
- assertNull(team.permits("myrepo", "master", pushToBranch));
- }
-
-}