use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class TestUnix method createLdapGroupRole.
private PrismObject<RoleType> createLdapGroupRole(String name) throws SchemaException {
PrismObject<RoleType> role = getRoleDefinition().instantiate();
RoleType roleType = role.asObjectable();
roleType.setName(new PolyStringType(name));
AssignmentType roleAssignemnt = new AssignmentType();
ObjectReferenceType roleTargetRef = new ObjectReferenceType();
roleTargetRef.setOid(ROLE_META_LDAPGROUP_OID);
roleTargetRef.setType(RoleType.COMPLEX_TYPE);
roleAssignemnt.setTargetRef(roleTargetRef);
roleType.getAssignment().add(roleAssignemnt);
return role;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class TestIteration method assertUserNick.
private void assertUserNick(String accountName, String accountFullName, String expectedUserName, String expectedLocality) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
PrismObject<UserType> user = findUserByUsername(expectedUserName);
assertNotNull("No user for " + accountName + " (" + expectedUserName + ")", user);
display("Created user for " + accountName, user);
assertEquals("Wrong nickname in user created for " + accountName, accountFullName, user.asObjectable().getNickName().getOrig());
assertEquals("Wrong additionalName in user created for " + accountName, accountName, user.asObjectable().getAdditionalName().getOrig());
PolyStringType locality = user.asObjectable().getLocality();
if (locality == null) {
assertEquals("Wrong locality in user created for " + accountName, expectedLocality, null);
} else {
assertEquals("Wrong locality in user created for " + accountName, expectedLocality, locality.getOrig());
}
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class ShadowManager method createRepositoryShadow.
/**
* Create a copy of a shadow that is suitable for repository storage.
*/
private PrismObject<ShadowType> createRepositoryShadow(ProvisioningContext ctx, PrismObject<ShadowType> shadow) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);
PrismObject<ShadowType> repoShadow = shadow.clone();
ShadowType repoShadowType = repoShadow.asObjectable();
ResourceAttributeContainer repoAttributesContainer = ShadowUtil.getAttributesContainer(repoShadow);
CachingStategyType cachingStrategy = ProvisioningUtil.getCachingStrategy(ctx);
if (cachingStrategy == CachingStategyType.NONE) {
// Clean all repoShadow attributes and add only those that should be
// there
repoAttributesContainer.clear();
Collection<ResourceAttribute<?>> primaryIdentifiers = attributesContainer.getPrimaryIdentifiers();
for (PrismProperty<?> p : primaryIdentifiers) {
repoAttributesContainer.add(p.clone());
}
Collection<ResourceAttribute<?>> secondaryIdentifiers = attributesContainer.getSecondaryIdentifiers();
for (PrismProperty<?> p : secondaryIdentifiers) {
repoAttributesContainer.add(p.clone());
}
// Also add all the attributes that act as association identifiers.
// We will need them when the shadow is deleted (to remove the shadow from entitlements).
RefinedObjectClassDefinition objectClassDefinition = ctx.getObjectClassDefinition();
for (RefinedAssociationDefinition associationDef : objectClassDefinition.getAssociationDefinitions()) {
if (associationDef.getResourceObjectAssociationType().getDirection() == ResourceObjectAssociationDirectionType.OBJECT_TO_SUBJECT) {
QName valueAttributeName = associationDef.getResourceObjectAssociationType().getValueAttribute();
if (repoAttributesContainer.findAttribute(valueAttributeName) == null) {
ResourceAttribute<Object> valueAttribute = attributesContainer.findAttribute(valueAttributeName);
if (valueAttribute != null) {
repoAttributesContainer.add(valueAttribute.clone());
}
}
}
}
repoShadowType.setCachingMetadata(null);
ProvisioningUtil.cleanupShadowActivation(repoShadowType);
} else if (cachingStrategy == CachingStategyType.PASSIVE) {
// Do not need to clear anything. Just store all attributes and add metadata.
CachingMetadataType cachingMetadata = new CachingMetadataType();
cachingMetadata.setRetrievalTimestamp(clock.currentTimeXMLGregorianCalendar());
repoShadowType.setCachingMetadata(cachingMetadata);
} else {
throw new ConfigurationException("Unknown caching strategy " + cachingStrategy);
}
setKindIfNecessary(repoShadowType, ctx.getObjectClassDefinition());
// setIntentIfNecessary(repoShadowType, objectClassDefinition);
// Store only password meta-data in repo
CredentialsType creds = repoShadowType.getCredentials();
if (creds != null) {
PasswordType passwordType = creds.getPassword();
if (passwordType != null) {
ProvisioningUtil.cleanupShadowPassword(passwordType);
PrismObject<UserType> owner = null;
if (ctx.getTask() != null) {
owner = ctx.getTask().getOwner();
}
ProvisioningUtil.addPasswordMetadata(passwordType, clock.currentTimeXMLGregorianCalendar(), owner);
}
// TODO: other credential types - later
}
// convert to the resource reference.
if (repoShadowType.getResource() != null) {
repoShadowType.setResource(null);
repoShadowType.setResourceRef(ObjectTypeUtil.createObjectRef(ctx.getResource()));
}
// now
if (repoShadowType.getResourceRef() == null) {
repoShadowType.setResourceRef(ObjectTypeUtil.createObjectRef(ctx.getResource()));
}
if (repoShadowType.getName() == null) {
repoShadowType.setName(new PolyStringType(ShadowUtil.determineShadowName(shadow)));
}
if (repoShadowType.getObjectClass() == null) {
repoShadowType.setObjectClass(attributesContainer.getDefinition().getTypeName());
}
if (repoShadowType.isProtectedObject() != null) {
repoShadowType.setProtectedObject(null);
}
normalizeAttributes(repoShadow, ctx.getObjectClassDefinition());
return repoShadow;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class PropertyRestriction method checkValueType.
private Object checkValueType(Object value, ValueFilter filter) throws QueryException {
Class expectedType = linkDefinition.getTargetDefinition().getJaxbClass();
if (expectedType == null || value == null) {
// nothing to check here
return value;
}
if (expectedType.isPrimitive()) {
expectedType = ClassUtils.primitiveToWrapper(expectedType);
}
//attempt to fix value type for polystring (if it was string in filter we create polystring from it)
if (PolyString.class.equals(expectedType) && (value instanceof String)) {
LOGGER.debug("Trying to query PolyString value but filter contains String '{}'.", filter);
String orig = (String) value;
value = new PolyString(orig, context.getPrismContext().getDefaultPolyStringNormalizer().normalize(orig));
}
//attempt to fix value type for polystring (if it was polystringtype in filter we create polystring from it)
if (PolyString.class.equals(expectedType) && (value instanceof PolyStringType)) {
LOGGER.debug("Trying to query PolyString value but filter contains PolyStringType '{}'.", filter);
PolyStringType type = (PolyStringType) value;
value = new PolyString(type.getOrig(), type.getNorm());
}
if (String.class.equals(expectedType) && (value instanceof QName)) {
//eg. shadow/objectClass
value = RUtil.qnameToString((QName) value);
}
if (value instanceof RawType) {
// MID-3850: but it's quite a workaround. Maybe we should treat RawType's earlier than this.
try {
return ((RawType) value).getParsedRealValue(expectedType);
} catch (SchemaException e) {
throw new QueryException("Couldn't parse value " + value + " as " + expectedType + ": " + e.getMessage(), e);
}
}
if (!expectedType.isAssignableFrom(value.getClass())) {
throw new QueryException("Value should be type of '" + expectedType + "' but it's '" + value.getClass() + "', filter '" + filter + "'.");
}
return value;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.
the class PerformanceTest method createPoly.
private PolyStringType createPoly(String orig) {
PolyStringType poly = new PolyStringType();
poly.setOrig(orig);
return poly;
}
Aggregations