use of edu.stanford.bmir.protege.web.shared.access.ActionId in project webprotege by protegeproject.
the class UserInSessionDecoder method decode.
@Override
public UserInSession decode(JSONValue json) {
JSONObject object = json.isObject();
if (object == null) {
throw new RuntimeException("Expected json object");
}
JSONValue userNameValue = object.get(USER_NAME);
if (userNameValue == null) {
throw new RuntimeException("Expected userName attribute");
}
JSONString userNameStringValue = userNameValue.isString();
if (userNameStringValue == null) {
throw new RuntimeException("Expected userName value to be string");
}
String displayName = object.get(DISPLAY_NAME).isString().stringValue();
String userEmail = object.get(USER_EMAIL).isString().stringValue();
JSONArray actionArray = object.get(APPLICATION_ACTIONS).isArray();
Set<ActionId> allowedActions = new HashSet<>();
if (actionArray != null) {
for (int i = 0; i < actionArray.size(); i++) {
ActionId actionId = new ActionId(actionArray.get(i).isString().stringValue());
allowedActions.add(actionId);
}
}
UserId userId = UserId.getUserId(userNameStringValue.stringValue());
UserDetails userDetails;
if (userId.isGuest()) {
userDetails = UserDetails.getGuestUserDetails();
} else {
userDetails = UserDetails.getUserDetails(userId, displayName, userEmail);
}
return new UserInSession(userDetails, allowedActions);
}
use of edu.stanford.bmir.protege.web.shared.access.ActionId in project webprotege by protegeproject.
the class UserInSessionFactory method getUserInSession.
/**
* Gets the user in session for the specified user id.
* @param userId The user id. This can be the id of the guest user.
*/
@Nonnull
public UserInSession getUserInSession(@Nonnull UserId userId) {
UserDetails userDetails = userDetailsManager.getUserDetails(userId).orElse(UserDetails.getGuestUserDetails());
Set<ActionId> actionClosure = accessManager.getActionClosure(forUser(userId), ApplicationResource.get());
return new UserInSession(userDetails, actionClosure);
}
use of edu.stanford.bmir.protege.web.shared.access.ActionId in project webprotege by protegeproject.
the class AbstractProjectActionHandler method getRequestValidator.
@Nonnull
@Override
public final RequestValidator getRequestValidator(@Nonnull A action, @Nonnull RequestContext requestContext) {
List<RequestValidator> validators = new ArrayList<>();
BuiltInAction builtInAction = getRequiredExecutableBuiltInAction();
if (builtInAction != null) {
ProjectPermissionValidator validator = new ProjectPermissionValidator(accessManager, action.getProjectId(), requestContext.getUserId(), builtInAction.getActionId());
validators.add(validator);
}
ActionId reqActionId = getRequiredExecutableAction();
if (reqActionId != null) {
ProjectPermissionValidator validator = new ProjectPermissionValidator(accessManager, action.getProjectId(), requestContext.getUserId(), reqActionId);
validators.add(validator);
}
Iterable<BuiltInAction> requiredExecutableBuiltInActions = getRequiredExecutableBuiltInActions();
for (BuiltInAction actionId : requiredExecutableBuiltInActions) {
ProjectPermissionValidator validator = new ProjectPermissionValidator(accessManager, action.getProjectId(), requestContext.getUserId(), actionId.getActionId());
validators.add(validator);
}
final RequestValidator additionalRequestValidator = getAdditionalRequestValidator(action, requestContext);
if (additionalRequestValidator != NullValidator.get()) {
validators.add(additionalRequestValidator);
}
return CompositeRequestValidator.get(validators);
}
use of edu.stanford.bmir.protege.web.shared.access.ActionId in project webprotege by protegeproject.
the class RoleOracleImpl method get.
public static RoleOracleImpl get() {
RoleOracleImpl impl = new RoleOracleImpl();
for (BuiltInRole builtInRole : BuiltInRole.values()) {
List<RoleId> parentRoles = builtInRole.getParents().stream().map(BuiltInRole::getRoleId).collect(toList());
List<ActionId> actions = builtInRole.getActions().stream().map(BuiltInAction::getActionId).collect(toList());
impl.addRole(new Role(builtInRole.getRoleId(), parentRoles, actions));
}
return impl;
}
Aggregations