Search in sources :

Example 26 with MetadataType

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");
    }
}
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 27 with MetadataType

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);
}
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 28 with MetadataType

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);
}
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)

Example 29 with MetadataType

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;
}
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)

Example 30 with MetadataType

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());
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition)

Aggregations

MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)30 ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)7 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)6 ConstructionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 PrismReferenceDefinition (com.evolveum.midpoint.prism.PrismReferenceDefinition)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2 List (java.util.List)2 Duration (javax.xml.datatype.Duration)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 MetadataType (org.openarchives.oai._2.MetadataType)2 Test (org.testng.annotations.Test)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1