Skip to content

Commit

Permalink
fixing MID-4914
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Oct 1, 2018
1 parent 8775653 commit 90a7ecf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
Expand Up @@ -32,6 +32,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.input.RelationDropDownChoicePanel;
import com.evolveum.midpoint.web.security.SecurityUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AreaCategoryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
Expand Down Expand Up @@ -103,7 +104,7 @@ protected ObjectQuery addFilterToContentQuery(ObjectQuery query){
try {
ModelInteractionService mis = getPageBase().getModelInteractionService();
RoleSelectionSpecification roleSpec =
mis.getAssignableRoleSpecification(getTargetedAssignemntObject(), task, result);
mis.getAssignableRoleSpecification(getTargetedAssignemntObject(), (Class<AbstractRoleType>) getObjectType().getClassDefinition(), task, result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
Expand Down
Expand Up @@ -449,7 +449,7 @@ protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
try {
ModelInteractionService mis = TypedAssignablePanel.this.getPageBase().getModelInteractionService();
RoleSelectionSpecification roleSpec =
mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), task, result);
mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), AbstractRoleType.class, task, result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.TypeFilter;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
Expand Down Expand Up @@ -313,7 +314,7 @@ private ObjectFilter getAssignableRolesFilter() {
try {
ModelInteractionService mis = getPageBase().getModelInteractionService();
RoleSelectionSpecification roleSpec =
mis.getAssignableRoleSpecification(getTargetUser().asPrismObject(), task, result);
mis.getAssignableRoleSpecification(getTargetUser().asPrismObject(), (Class) ObjectTypes.getObjectTypeClass(getQueryType()), task, result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
Expand Down
Expand Up @@ -148,7 +148,7 @@ <F extends ObjectType> ModelContext<F> previewChanges(
*
* @param focus Object of the operation. The object (usually user) to whom the roles should be assigned.
*/
<F extends FocusType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException;
<F extends FocusType, R extends AbstractRoleType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus, Class<R> targetType, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException;

/**
* Returns filter for lookup of donors or power of attorney. The donors are the users that have granted
Expand Down
Expand Up @@ -93,6 +93,7 @@
import com.evolveum.midpoint.prism.query.AllFilter;
import com.evolveum.midpoint.prism.query.AndFilter;
import com.evolveum.midpoint.prism.query.EqualFilter;
import com.evolveum.midpoint.prism.query.InOidFilter;
import com.evolveum.midpoint.prism.query.NoneFilter;
import com.evolveum.midpoint.prism.query.NotFilter;
import com.evolveum.midpoint.prism.query.ObjectFilter;
Expand Down Expand Up @@ -441,7 +442,7 @@ public Collection<? extends DisplayableValue<String>> getActionUrls() {
}

@Override
public <F extends FocusType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus, Task task, OperationResult parentResult)
public <F extends FocusType, R extends AbstractRoleType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus, Class<R> targetType, Task task, OperationResult parentResult)
throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException {
OperationResult result = parentResult.createMinorSubresult(GET_ASSIGNABLE_ROLE_SPECIFICATION);

Expand Down Expand Up @@ -485,7 +486,7 @@ public <F extends FocusType> RoleSelectionSpecification getAssignableRoleSpecifi

try {
ObjectFilter filter = securityEnforcer.preProcessObjectFilter(ModelAuthorizationAction.AUTZ_ACTIONS_URLS_ASSIGN,
AuthorizationPhaseType.REQUEST, AbstractRoleType.class, focus, AllFilter.createAll(), null, task, result);
AuthorizationPhaseType.REQUEST, targetType, focus, AllFilter.createAll(), null, task, result);
LOGGER.trace("assignableRoleSpec filter: {}", filter);
spec.setFilter(filter);
if (filter instanceof NoneFilter) {
Expand Down Expand Up @@ -641,7 +642,7 @@ private Collection<RoleSelectionSpecEntry> getRoleSelectionSpecEntries(ObjectFil
Collection<RoleSelectionSpecEntry> subRoleSelectionSpec = getRoleSelectionSpecEntries(((NotFilter)filter).getFilter());
RoleSelectionSpecEntry.negate(subRoleSelectionSpec);
return subRoleSelectionSpec;
} else if (filter instanceof RefFilter) {
} else if (filter instanceof RefFilter || filter instanceof InOidFilter) {
return null;
} else {
throw new UnsupportedOperationException("Unexpected filter "+filter);
Expand Down
Expand Up @@ -4684,7 +4684,7 @@ protected <F extends FocusType> void assertRoleTypes(PrismObject<F> focus, Strin
protected <F extends FocusType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".getAssignableRoleSpecification");
OperationResult result = task.getResult();
RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, task, result);
RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, AbstractRoleType.class, task, result);
assertSuccess(result);
return spec;
}
Expand Down

0 comments on commit 90a7ecf

Please sign in to comment.