private boolean matches(PrismPropertyValue<?> value1, PrismPropertyValue<?> value2, MatchingRule<?> matchingRule) { try { if (matchingRule.match(value1.getRealValue(), value2.getRealValue())) { return true; } } catch (SchemaException e) { // At least one of the values is invalid. But we do not want to throw exception from // a comparison operation. That will make the system very fragile. Let's fall back to // ordinary equality mechanism instead. if (Objects.equals(value1.getRealValue(), value2.getRealValue())) { return true; } } return false; }
@Override public T getRealValue() { PrismPropertyValue<T> value = getValue(); return value != null ? value.getRealValue() : null; }
public String getDataAsSingleString() throws ScriptExecutionException { if (!data.isEmpty()) { if (data.size() == 1) { return (String) ((PrismPropertyValue) data.get(0).getValue()).getRealValue(); // todo implement some diagnostics when this would fail } else { throw new ScriptExecutionException("Multiple values where just one is expected"); } } else { return null; } }
private boolean matchesAssociationPattern(@NotNull List<String> patterns, @NotNull ResourceAttribute<?> identifier, @NotNull MatchingRule<Object> matchingRule) { for (String pattern : patterns) { for (PrismPropertyValue<?> identifierValue : identifier.getValues()) { try { if (identifierValue != null && matchingRule.matchRegex(identifierValue.getRealValue(), pattern)) { return true; } } catch (SchemaException e) { LOGGER.warn("Value '{}' is invalid: {}", identifierValue, e.getMessage(), e); return false; } } } return false; } }
public static <T> T evaluateExpressionSingle(ExpressionType expressionBean, ExpressionVariables expressionVariables, String contextDescription, ExpressionFactory expressionFactory, PrismContext prismContext, Task task, OperationResult result, QName typeName, T defaultValue, Function<Object, Object> additionalConvertor) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { PrismPropertyDefinition<T> resultDef = prismContext.definitionFactory().createPropertyDefinition( new QName(SchemaConstants.NS_C, "result"), typeName); Expression<PrismPropertyValue<T>,PrismPropertyDefinition<T>> expression = expressionFactory.makeExpression(expressionBean, resultDef, contextDescription, task, result); ExpressionEvaluationContext eeContext = new ExpressionEvaluationContext(null, expressionVariables, contextDescription, task, result); eeContext.setAdditionalConvertor(additionalConvertor); PrismValueDeltaSetTriple<PrismPropertyValue<T>> exprResultTriple = ModelExpressionThreadLocalHolder .evaluateExpressionInContext(expression, eeContext, task, result); List<T> results = exprResultTriple.getZeroSet().stream() .map(ppv -> (T) ppv.getRealValue()) .collect(Collectors.toList()); return getSingleValue(results, defaultValue, contextDescription); }
@Override protected void collectPassword(PropertyDelta<ProtectedStringType> passwordDelta) throws SchemaException { if (isSelfPasswordChange(passwordDelta)) { AttributeDeltaBuilder deltaBuilder = new AttributeDeltaBuilder(); deltaBuilder.setName(OperationalAttributes.PASSWORD_NAME); PrismProperty<ProtectedStringType> newPasswordProperty = passwordDelta.getPropertyNewMatchingPath(); GuardedString newPasswordGs = passwordToGuardedString(newPasswordProperty.getRealValue(), "new password"); deltaBuilder.addValueToAdd(newPasswordGs); ProtectedStringType oldPasswordPs = passwordDelta.getEstimatedOldValues().iterator().next().getRealValue(); GuardedString oldPasswordGs = passwordToGuardedString(oldPasswordPs, "old password"); deltaBuilder.addValueToRemove(oldPasswordGs); attributesDelta.add(deltaBuilder.build()); } else { super.collectPassword(passwordDelta); } }
Object realValue = ((PrismPropertyValue) value).getRealValue(); if (realValue instanceof SearchFilterType) { retval.addAll(
private static void processEncryptablePrismPropertyValue(PrismPropertyValue<?> pval, ProtectedStringProcessor processor) { Object realValue = pval.getRealValue(); if (realValue instanceof ProtectedStringType) { processor.apply((ProtectedStringType) realValue, determinePropName(pval)); } else if (realValue instanceof MailConfigurationType) { // todo fix this hack (it's because MailConfigurationType is not a container) for (MailServerConfigurationType serverCfg : ((MailConfigurationType) realValue).getServer()) { processor.apply(serverCfg.getPassword(), "mail server password"); } } else if (realValue instanceof SmsConfigurationType) { // todo fix this hack (it's because SmsConfigurationType is not a container) for (SmsGatewayConfigurationType gwCfg : ((SmsConfigurationType) realValue).getGateway()) { processor.apply(gwCfg.getPassword(), "sms gateway password"); } } }
throw new SchemaException("'createdTimestamp' filter contains a null value: " + filter); Object realValue = value.getRealValue(); if (!(realValue instanceof XMLGregorianCalendar)) { throw new SchemaException("'createdTimestamp' filter contains a value other than XMLGregorianCalendar: " + realValue + " in " + filter);
private ObjectDelta<? extends ObjectType> createDelta(ObjectType objectType, PipelineData deltaData) throws ScriptExecutionException { if (deltaData.getData().size() != 1) { throw new ScriptExecutionException("Expected exactly one delta to apply, found " + deltaData.getData().size() + " instead."); } @SuppressWarnings({"unchecked", "raw"}) ObjectDeltaType deltaType = ((PrismPropertyValue<ObjectDeltaType>) deltaData.getData().get(0).getValue()).clone().getRealValue(); if (deltaType.getChangeType() == null) { deltaType.setChangeType(ChangeTypeType.MODIFY); } if (deltaType.getOid() == null && deltaType.getChangeType() != ChangeTypeType.ADD) { deltaType.setOid(objectType.getOid()); } if (deltaType.getObjectType() == null) { if (objectType.asPrismObject().getDefinition() == null) { throw new ScriptExecutionException("No definition for prism object " + objectType); } deltaType.setObjectType(objectType.asPrismObject().getDefinition().getTypeName()); } try { return DeltaConvertor.createObjectDelta(deltaType, prismContext); } catch (SchemaException e) { throw new ScriptExecutionException("Couldn't process delta due to schema exception", e); } } }
ProtectedStringType oldProjectionPassword = minusSet.iterator().next().getRealValue(); PropertyDelta<ProtectedStringType> userPasswordDelta = (PropertyDelta<ProtectedStringType>) userPasswordIdi.getDelta(); Collection<PrismPropertyValue<ProtectedStringType>> userPasswordDeltaOldValues = userPasswordDelta.getEstimatedOldValues(); if (userPasswordDeltaOldValues != null && !userPasswordDeltaOldValues.isEmpty()) { ProtectedStringType oldUserPassword = userPasswordDeltaOldValues.iterator().next().getRealValue(); try { if (oldUserPassword.canGetCleartext() && protector.compare(oldUserPassword, oldProjectionPassword)) {