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