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