Search in sources :

Example 21 with MetadataType

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");
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) Duration(javax.xml.datatype.Duration) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 22 with MetadataType

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;
}
Also used : CredentialsStorageTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsStorageTypeType) PasswordHistoryEntryType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordHistoryEntryType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 23 with MetadataType

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);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) MetadataPanel(com.evolveum.midpoint.web.component.assignment.MetadataPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 24 with MetadataType

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);
}
Also used : OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) DomainType(net.opengis.ows.x11.DomainType) OwsOperationsMetadata(org.n52.shetland.ogc.ows.OwsOperationsMetadata) OwsMetadata(org.n52.shetland.ogc.ows.OwsMetadata) OwsSections(org.n52.shetland.ogc.ows.OwsSections) OwsServiceProvider(org.n52.shetland.ogc.ows.OwsServiceProvider) MetadataType(net.opengis.ows.x11.MetadataType) DomainMetadataType(net.opengis.ows.x11.DomainMetadataType) OwsServiceIdentification(org.n52.shetland.ogc.ows.OwsServiceIdentification) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) OwsAcceptVersions(org.n52.shetland.ogc.ows.OwsAcceptVersions) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)23 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)4 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 Test (org.testng.annotations.Test)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismReferenceDefinition (com.evolveum.midpoint.prism.PrismReferenceDefinition)1 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 RObject (com.evolveum.midpoint.repo.sql.data.common.RObject)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 DateLabelComponent (com.evolveum.midpoint.web.component.DateLabelComponent)1 MetadataPanel (com.evolveum.midpoint.web.component.assignment.MetadataPanel)1 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)1