use of io.jenkins.blueocean.commons.ServiceException.ForbiddenException in project blueocean-plugin by jenkinsci.
the class UserImpl method getFavorites.
@Override
public BlueFavoriteContainer getFavorites() {
/*
* Get the user id using authenticated user. User.current() returns authenticated user using security realm and
* associated IdStrategy to get a consistent id.
*
* @see IdStrategy#keyFor(String)
* @see IdStrategy.CaseInsensitive#keyFor(String)
*
*/
User u = User.current();
String expectedUserId = u != null ? u.getId() : Jenkins.ANONYMOUS.getName();
if (!user.getId().equals(expectedUserId)) {
throw new ForbiddenException("This user '" + expectedUserId + "' cannot access resource owned by '" + user.getId() + "'");
}
return new FavoriteContainerImpl(this, this);
}
Aggregations