use of org.geotoolkit.ows.xml.v200.MetadataType in project midpoint by Evolveum.
the class ObjectValuePolicyEvaluator method validateMinAge.
private void validateMinAge(StringBuilder messageBuilder, OperationResult result) {
if (oldCredentialType == null) {
return;
}
Duration minAge = getMinAge();
if (minAge == null) {
return;
}
MetadataType currentCredentialMetadata = oldCredentialType.getMetadata();
if (currentCredentialMetadata == null) {
return;
}
XMLGregorianCalendar lastChangeTimestamp = currentCredentialMetadata.getModifyTimestamp();
if (lastChangeTimestamp == null) {
lastChangeTimestamp = currentCredentialMetadata.getCreateTimestamp();
}
if (lastChangeTimestamp == null) {
return;
}
XMLGregorianCalendar changeAllowedTimestamp = XmlTypeConverter.addDuration(lastChangeTimestamp, minAge);
if (changeAllowedTimestamp.compare(now) == DatatypeConstants.GREATER) {
LOGGER.trace("Password minAge violated. lastChange={}, minAge={}, now={}", lastChangeTimestamp, minAge, now);
String msg = shortDesc + " could not be changed because password minimal age was not yet reached.";
result.addSubresult(new OperationResult("Password minimal age", OperationResultStatus.FATAL_ERROR, msg));
messageBuilder.append(msg);
messageBuilder.append("\n");
}
}
use of org.geotoolkit.ows.xml.v200.MetadataType in project midpoint by Evolveum.
the class PrismObjectPanel method createMetadataPanel.
protected void createMetadataPanel(IModel<ObjectWrapper<O>> model, ListItem<ContainerWrapper> item, PrismContainerPanel containerPanel) {
//check if metadata container exists for
//the current item and create metadata panel if yes
Component metadataPanel;
//becomes visible only in case metadata exists
Model<Boolean> metadataVisibility = Model.of(false);
ItemPath metadataContainerPath = item.getModelObject().isMain() ? new ItemPath(ObjectType.F_METADATA) : new ItemPath(item.getModelObject().getPath(), ObjectType.F_METADATA);
if (model.getObject().findContainerWrapper(metadataContainerPath) != null) {
ContainerWrapper<MetadataType> metadataContainer = model.getObject().findContainerWrapper(metadataContainerPath);
metadataVisibility.setObject(true);
String containerName = item.getModelObject().isMain() ? "Object" : StringUtils.capitalize(item.getModelObject().getPath().last().toString());
metadataPanel = new MetadataPanel(ID_CONTAINER_METADATA, new AbstractReadOnlyModel<MetadataType>() {
@Override
public MetadataType getObject() {
return metadataContainer.getItem().getRealValue();
}
}, containerName, "");
} else {
metadataPanel = new WebMarkupContainer(ID_CONTAINER_METADATA);
}
metadataPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return containerPanel.isVisible() && metadataVisibility.getObject() && model.getObject().isShowMetadata() && !ContainerStatus.ADDING.equals(model.getObject().getStatus());
}
});
metadataPanel.setOutputMarkupId(true);
item.add(metadataPanel);
}
use of org.geotoolkit.ows.xml.v200.MetadataType in project arctic-sea by 52North.
the class OwsEncoderv110 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
if (element instanceof OwsServiceIdentification) {
return encodeServiceIdentification((OwsServiceIdentification) element);
} else if (element instanceof OwsServiceProvider) {
return encodeServiceProvider((OwsServiceProvider) element);
} else if (element instanceof OwsOperationsMetadata) {
return encodeOperationsMetadata((OwsOperationsMetadata) element);
} else if (element instanceof OwsExceptionReport) {
if (isEncodeExceptionsOnly(additionalValues) && !((OwsExceptionReport) element).getExceptions().isEmpty()) {
return encodeOwsException(((OwsExceptionReport) element).getExceptions().get(0));
}
return encodeOwsExceptionReport((OwsExceptionReport) element);
} else if (element instanceof OwsMetadata) {
MetadataType metadataType = MetadataType.Factory.newInstance(getXmlOptions());
encodeOwsMetadata((OwsMetadata) element, metadataType);
return metadataType;
} else if (element instanceof OwsDomain) {
DomainType domainType = DomainType.Factory.newInstance(getXmlOptions());
encodeOwsDomain((OwsDomain) element, domainType);
return domainType;
} else if (element instanceof OwsAcceptVersions) {
return encodeAcceptVersions((OwsAcceptVersions) element);
} else if (element instanceof OwsSections) {
return encodeSections((OwsSections) element);
}
throw new UnsupportedEncoderInputException(this, element);
}
use of org.geotoolkit.ows.xml.v200.MetadataType in project midpoint by Evolveum.
the class CredentialPolicyEvaluator method createAddHistoryDelta.
// TODO: generalize for other credentials
private int createAddHistoryDelta(PrismContainer<R> oldCredentialContainer) throws SchemaException {
R oldCredentialContainerType = oldCredentialContainer.getRealValue();
MetadataType oldCredentialMetadata = oldCredentialContainerType.getMetadata();
PrismProperty<ProtectedStringType> oldValueProperty = oldCredentialContainer.findProperty(getCredentialRelativeValuePath());
if (oldValueProperty == null) {
return 0;
}
ProtectedStringType oldValue = oldValueProperty.getRealValue();
if (oldValue == null) {
return 0;
}
ProtectedStringType passwordPsForStorage = oldValue.clone();
CredentialsStorageTypeType storageType = defaultIfNull(SecurityUtil.getCredentialStorageTypeType(getCredentialPolicy().getHistoryStorageMethod()), CredentialsStorageTypeType.HASHING);
prepareProtectedStringForStorage(passwordPsForStorage, storageType);
PrismContainerDefinition<PasswordHistoryEntryType> historyEntryDefinition = oldCredentialContainer.getDefinition().findContainerDefinition(PasswordType.F_HISTORY_ENTRY);
PrismContainer<PasswordHistoryEntryType> entryContainer = historyEntryDefinition.instantiate();
PrismContainerValue<PasswordHistoryEntryType> entryPcv = entryContainer.createNewValue();
PasswordHistoryEntryType entry = entryPcv.asContainerable();
entry.setValue(passwordPsForStorage);
entry.setMetadata(oldCredentialMetadata != null ? oldCredentialMetadata.clone() : null);
entry.setChangeTimestamp(now);
ContainerDelta<PasswordHistoryEntryType> addHistoryDelta = prismContext.deltaFactory().container().createModificationAdd(SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_ENTRY, FocusType.class, entry.clone());
context.getFocusContext().swallowToSecondaryDelta(addHistoryDelta);
return 1;
}
use of org.geotoolkit.ows.xml.v200.MetadataType in project midpoint by Evolveum.
the class SchemaTestUtil method assertFocusDefinition.
public static void assertFocusDefinition(ComplexTypeDefinition complexTypeDefinition, String defDesc, QName expectedExtensionTypeName, int expectedExtensionItemDefs) {
assertNotNull("No " + defDesc + " definition", complexTypeDefinition);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_NAME, "ObjectType.name");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_NAME, 0);
PrismAsserts.assertPropertyDefinition(complexTypeDefinition, ObjectType.F_DESCRIPTION, DOMUtil.XSD_STRING, 0, 1);
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, ObjectType.F_DESCRIPTION, "ObjectType.description");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, ObjectType.F_DESCRIPTION, 10);
assertFalse("" + defDesc + " definition is marked as runtime", complexTypeDefinition.isRuntimeSchema());
PrismContainerDefinition extensionContainer = complexTypeDefinition.findContainerDefinition(UserType.F_EXTENSION);
PrismAsserts.assertDefinition(extensionContainer, UserType.F_EXTENSION, expectedExtensionTypeName, 0, 1);
assertTrue("Extension is NOT runtime", extensionContainer.isRuntimeSchema());
// assertTrue("Extension is NOT dynamic", extensionContainer.isDynamic());
assertEquals("Extension size", expectedExtensionItemDefs, extensionContainer.getDefinitions().size());
PrismAsserts.assertItemDefinitionDisplayName(complexTypeDefinition, UserType.F_EXTENSION, "ObjectType.extension");
PrismAsserts.assertItemDefinitionDisplayOrder(complexTypeDefinition, UserType.F_EXTENSION, 1000);
PrismContainerDefinition<ActivationType> activationContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ACTIVATION);
PrismAsserts.assertDefinition(activationContainer, UserType.F_ACTIVATION, ActivationType.COMPLEX_TYPE, 0, 1);
assertFalse("Activation is runtime", activationContainer.isRuntimeSchema());
assertEquals("Activation size", 12, activationContainer.getDefinitions().size());
PrismAsserts.assertPropertyDefinition(activationContainer, ActivationType.F_ADMINISTRATIVE_STATUS, SchemaConstants.C_ACTIVATION_STATUS_TYPE, 0, 1);
PrismContainerDefinition<AssignmentType> assignmentContainer = complexTypeDefinition.findContainerDefinition(UserType.F_ASSIGNMENT);
PrismAsserts.assertDefinition(assignmentContainer, UserType.F_ASSIGNMENT, AssignmentType.COMPLEX_TYPE, 0, -1);
assertFalse("Assignment is runtime", assignmentContainer.isRuntimeSchema());
assertEquals("Assignment definition size", 24, assignmentContainer.getDefinitions().size());
PrismContainerDefinition<ConstructionType> constructionContainer = assignmentContainer.findContainerDefinition(AssignmentType.F_CONSTRUCTION);
PrismAsserts.assertDefinition(constructionContainer, AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1);
assertFalse("Construction is runtime", constructionContainer.isRuntimeSchema());
PrismReferenceDefinition accountRefDef = complexTypeDefinition.findItemDefinition(UserType.F_LINK_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(accountRefDef, UserType.F_LINK_REF, ObjectReferenceType.COMPLEX_TYPE, 0, -1);
assertEquals("Wrong target type in accountRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
PrismContainerDefinition<MetadataType> metadataContainer = complexTypeDefinition.findContainerDefinition(UserType.F_METADATA);
assertFalse("Metadata is runtime", metadataContainer.isRuntimeSchema());
assertFalse("Metadata is dynamic", metadataContainer.isDynamic());
assertTrue("Metadata is NOT operational", metadataContainer.isOperational());
assertEquals("Metadata size", 23, metadataContainer.getDefinitions().size());
PrismReferenceDefinition tenantRefDef = complexTypeDefinition.findItemDefinition(UserType.F_TENANT_REF, PrismReferenceDefinition.class);
PrismAsserts.assertDefinition(tenantRefDef, UserType.F_TENANT_REF, ObjectReferenceType.COMPLEX_TYPE, 0, 1);
assertEquals("Wrong target type in tenantRef", ShadowType.COMPLEX_TYPE, accountRefDef.getTargetTypeName());
}
Aggregations