Search in sources :

Example 76 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method searchUserByName.

protected UserType searchUserByName(String username) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the username is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + username + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (UserType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single user with username '" + username + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 77 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class Main method getConfiguration.

private static SystemConfigurationType getConfiguration(ModelPortType modelPort) throws FaultMessage {
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    modelPort.getObject(ModelClientUtil.getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), options, objectHolder, resultHolder);
    return (SystemConfigurationType) objectHolder.value;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 78 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class Main method searchRoleByName.

private static RoleType searchRoleByName(ModelPortType modelPort, String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
    // WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (RoleType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 79 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getShadowByName.

protected ShadowType getShadowByName(String resourceOid, QName objectClass, String name) throws JAXBException, SAXException, IOException, FaultMessage {
    // WARNING: in a real case make sure that the username is properly escaped before putting it in XML
    SearchFilterType filter = ModelClientUtil.parseSearchFilterType("                        <q:and xmlns:q='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'>\n" + "                            <q:ref>\n" + "                                <q:path>resourceRef</q:path>\n" + "                                <q:value>\n" + "                                    <oid>" + resourceOid + "</oid>\n" + "                                    <type>ResourceType</type>\n" + "                                </q:value>\n" + "                            </q:ref>\n" + "                            <q:equal>\n" + "                                <q:path>objectClass</q:path>\n" + "                                <q:value xmlns:a=\"" + objectClass.getNamespaceURI() + "\">a:" + objectClass.getLocalPart() + "</q:value>\n" + "                            </q:equal>\n" + "                            <q:equal>\n" + "                                <q:path>attributes/name</q:path>\n" + "                                <q:value>" + name + "</q:value>\n" + "                            </q:equal>\n" + "                        </q:and>\n");
    QueryType query = new QueryType();
    query.setFilter(filter);
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ShadowType.class), query, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    List<ObjectType> objects = objectList.getObject();
    if (objects.isEmpty()) {
        return null;
    }
    if (objects.size() == 1) {
        return (ShadowType) objects.get(0);
    }
    throw new IllegalStateException("Expected to find a single shadow with name '" + name + "' but found " + objects.size() + " ones instead");
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 80 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project metron by apache.

the class StixExtractor method extract.

@Override
public Iterable<LookupKV> extract(String line) throws IOException {
    STIXPackage stixPackage = STIXPackage.fromXMLString(line.replaceAll("\"Equal\"", "\"Equals\""));
    List<LookupKV> ret = new ArrayList<>();
    for (Observable o : getObservables(stixPackage)) {
        ObjectType obj = o.getObject();
        if (obj != null) {
            ObjectPropertiesType props = obj.getProperties();
            if (props != null) {
                ObjectTypeHandler handler = ObjectTypeHandlers.getHandlerByInstance(props);
                if (handler != null) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Found {} for properties {}", handler.getTypeClass().getCanonicalName(), props.toXMLString());
                    }
                    Iterable<LookupKV> extractions = handler.extract(props, config);
                    for (LookupKV extraction : extractions) {
                        ret.add(extraction);
                    }
                } else if (LOG.isDebugEnabled()) {
                    LOG.debug("Did not find a handler for properties {} of type {}", props.toXMLString(), props.getClass());
                }
            }
        }
    }
    return ret;
}
Also used : STIXPackage(org.mitre.stix.stix_1.STIXPackage) ObjectType(org.mitre.cybox.cybox_2.ObjectType) ObjectTypeHandler(org.apache.metron.dataloads.extractor.stix.types.ObjectTypeHandler) LookupKV(org.apache.metron.enrichment.lookup.LookupKV) ArrayList(java.util.ArrayList) Observable(org.mitre.cybox.cybox_2.Observable)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)243 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)126 Test (org.testng.annotations.Test)97 Task (com.evolveum.midpoint.task.api.Task)82 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)68 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)55 ArrayList (java.util.ArrayList)51 Holder (javax.xml.ws.Holder)48 QName (javax.xml.namespace.QName)32 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)29 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)28 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)24 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)22