use of net.opengis.ows.x11.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 net.opengis.ows.x11.MetadataType in project midpoint by Evolveum.
the class CredentialPolicyEvaluator method createAddHistoryDelta.
// TODO: generalize for other credentials
private <F extends FocusType> int createAddHistoryDelta(PrismContainer<R> oldCredentialContainer) throws SchemaException {
R oldCredentialContainerType = oldCredentialContainer.getValue().asContainerable();
MetadataType oldCredentialMetadata = oldCredentialContainerType.getMetadata();
PrismProperty<ProtectedStringType> oldValueProperty = oldCredentialContainer.findProperty(getCredentialRelativeValuePath());
if (oldValueProperty == null) {
return 0;
}
ProtectedStringType newHistoryValue = oldValueProperty.getRealValue();
ProtectedStringType passwordPsForStorage = newHistoryValue.clone();
CredentialsStorageTypeType storageType = SecurityUtil.getCredentialStoragetTypeType(getCredentialPolicy().getHistoryStorageMethod());
if (storageType == null) {
storageType = CredentialsStorageTypeType.HASHING;
}
prepareProtectedStringForStorage(passwordPsForStorage, storageType);
PrismContainerDefinition<PasswordHistoryEntryType> historyEntryDefinition = oldCredentialContainer.getDefinition().findContainerDefinition(PasswordType.F_HISTORY_ENTRY);
PrismContainer<PasswordHistoryEntryType> historyEntry = historyEntryDefinition.instantiate();
PrismContainerValue<PasswordHistoryEntryType> hisotryEntryValue = historyEntry.createNewValue();
PasswordHistoryEntryType entryType = hisotryEntryValue.asContainerable();
entryType.setValue(passwordPsForStorage);
entryType.setMetadata(oldCredentialMetadata == null ? null : oldCredentialMetadata.clone());
entryType.setChangeTimestamp(now);
ContainerDelta<PasswordHistoryEntryType> addHisotryDelta = ContainerDelta.createModificationAdd(new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_HISTORY_ENTRY), UserType.class, prismContext, entryType.clone());
context.getFocusContext().swallowToSecondaryDelta(addHisotryDelta);
return 1;
}
use of net.opengis.ows.x11.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 net.opengis.ows.x11.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);
}
Aggregations