mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
added groups to state
This commit is contained in:
@@ -36,9 +36,12 @@ package sonia.scm;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.web.security.WebSecurityContext;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
@@ -63,12 +66,15 @@ public class ScmState
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
*
|
||||
* @param securityContext
|
||||
* @param repositoryTypes
|
||||
*/
|
||||
public ScmState(User user, Type[] repositoryTypes)
|
||||
public ScmState(WebSecurityContext securityContext,
|
||||
Collection<Type> repositoryTypes)
|
||||
{
|
||||
this.user = user;
|
||||
this.user = securityContext.getUser();
|
||||
this.groups = securityContext.getGroups();
|
||||
this.repositoryTypes = repositoryTypes;
|
||||
}
|
||||
|
||||
@@ -80,7 +86,18 @@ public class ScmState
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Type[] getRepositoryTypes()
|
||||
public Collection<String> getGroups()
|
||||
{
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<Type> getRepositoryTypes()
|
||||
{
|
||||
return repositoryTypes;
|
||||
}
|
||||
@@ -109,13 +126,24 @@ public class ScmState
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groups
|
||||
*/
|
||||
public void setGroups(Collection<String> groups)
|
||||
{
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repositoryTypes
|
||||
*/
|
||||
public void setRepositoryTypes(Type[] repositoryTypes)
|
||||
public void setRepositoryTypes(Collection<Type> repositoryTypes)
|
||||
{
|
||||
this.repositoryTypes = repositoryTypes;
|
||||
}
|
||||
@@ -144,9 +172,12 @@ public class ScmState
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Collection<String> groups;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "repositoryTypes")
|
||||
private Type[] repositoryTypes;
|
||||
private Collection<Type> repositoryTypes;
|
||||
|
||||
/** Field description */
|
||||
private boolean success = true;
|
||||
|
||||
@@ -99,7 +99,8 @@ public class AuthenticationResource
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
resp = Response.ok(getState(user)).build();
|
||||
resp = Response.ok(new ScmState(securityContext,
|
||||
repositoryManger.getTypes())).build();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -135,7 +136,7 @@ public class AuthenticationResource
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
state = getState(user);
|
||||
state = new ScmState(securityContext, repositoryManger.getTypes());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -167,7 +168,7 @@ public class AuthenticationResource
|
||||
logger.debug("return state for user {}", user.getName());
|
||||
}
|
||||
|
||||
state = getState(user);
|
||||
state = new ScmState(securityContext, repositoryManger.getTypes());
|
||||
response = Response.ok(state).build();
|
||||
}
|
||||
else
|
||||
@@ -178,25 +179,6 @@ public class AuthenticationResource
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param user
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ScmState getState(User user)
|
||||
{
|
||||
ScmState state = new ScmState();
|
||||
|
||||
state.setUser(user);
|
||||
state.setRepositoryTypes(repositoryManger.getTypes().toArray(new Type[0]));
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user