private Object getRealContent(PrismValue pval, ItemPath residualPath) { if (residualPath == null || residualPath.isEmpty()) { return pval; } if (pval == null) { return null; } return pval.find(residualPath); }
public PipelineData evaluate(SelectExpressionType selectExpression, PipelineData input, ExecutionContext context, OperationResult result) throws ScriptExecutionException { if (selectExpression.getPath() == null) { return input; } ItemPath path = selectExpression.getPath().getItemPath(); PipelineData output = PipelineData.createEmpty(); for (PipelineItem item : input.getData()) { Object o = item.getValue().find(path); if (o != null) { if (o instanceof Item) { List<? extends PrismValue> values = ((Item<? extends PrismValue, ?>) o).getValues(); values.forEach((v) -> output.addValue(v, item.getResult().clone(), item.getVariables())); // clone to avoid aggregating subresults into unrelated results } else { throw new ScriptExecutionException( "In 'select' commands, only property/container/reference selection is supported for now. Select on '" + path + "' returned this instead: " + o); } } } return output; } }
@SuppressWarnings("unchecked") private void checkPassword(PipelineItem item, String userOid) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException, EncryptionException { PrismProperty<ProtectedStringType> returnedPassword = (PrismProperty<ProtectedStringType>) item.getValue().find(SchemaConstants.PATH_PASSWORD_VALUE); ProtectedStringType returnedRealValue = returnedPassword.getRealValue(); PrismObject<UserType> user = getUser(userOid); ProtectedStringType repoRealValue = user.asObjectable().getCredentials().getPassword().getValue(); String returnedClearValue = protector.decryptString(returnedRealValue); String repoClearValue = protector.decryptString(repoRealValue); System.out.println("Returned password = " + returnedClearValue + ", repo password = " + repoClearValue); assertEquals("Wrong password stored in repository", returnedClearValue, repoClearValue); }