本文整理汇总了Java中de.hshannover.f4.trust.ifmapj.identifier.Device类的典型用法代码示例。如果您正苦于以下问题:Java Device类的具体用法?Java Device怎么用?Java Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Device类属于de.hshannover.f4.trust.ifmapj.identifier包,在下文中一共展示了Device类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDeletes
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
@Override
public List<PublishElement> toDeletes(Set<Vulnerability> vulnerabilities) {
List<PublishElement> elements = new ArrayList<PublishElement>();
Map<String, List<Vulnerability>> byIp = sortByIp(vulnerabilities);
for (List<Vulnerability> vulnerabilityList : byIp.values()) {
if (vulnerabilityList.size() > 0) {
Vulnerability first = vulnerabilityList.get(0);
Device dev = mHostDeviceMaping.get(first.getHost());
for (Vulnerability v : vulnerabilityList) {
List<PublishElement> e = singleVulnerabilityDelete(v, dev);
elements.addAll(e);
}
}
}
return elements;
}
示例2: preparePublishUpdatesOrDeletes
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
private static void preparePublishUpdatesOrDeletes() {
PublishElement publishUpdateOrDelete;
DummyCategory root = prepareCategoriesAndFeature();
String nodeName = root.localId;
Device dev = Identifiers.createDev(mDevice);
Identity rootCategory = createCategory(nodeName);
Document deviceCategory = createCategoryLink("device-category");
if (mIsUpdate) {
publishUpdateOrDelete = Requests.createPublishUpdate(dev, rootCategory, deviceCategory, MetadataLifetime.forever);
mPublishElements.add(publishUpdateOrDelete);
} else {
publishUpdateOrDelete = Requests.createPublishDelete(dev, rootCategory);
mPublishElements.add(publishUpdateOrDelete);
}
fork(rootCategory, root.features, root.subCategories);
}
示例3: singleVulnerability
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
/**
* Create the sub-tree for the given {@link Vulnerability} under the parent
* category node.
*
* @param v
* the {@link Vulnerability} to process
* @param parentCategory
* the parent node of the {@link Vulnerability} category node
* @param dev
* the device which is affected by the vulnerability
* @return a list of {@link PublishElement}s containing the publish
* information for the sub-tree
*/
private List<PublishElement> singleVulnerability(Vulnerability v,
Identity parentCategory, Device dev) {
List<PublishElement> elements = new ArrayList<PublishElement>();
// create a new (vulnerability) category for the vulnerability
PublishUpdate vulnerabilityUpdate = Requests.createPublishUpdate();
Identity vulnerabilityCategory = createCategory(
parentCategory.getName() + ".vulnerability:" + v.getId(),
dev.getName());
Document categoryLink = createCategoryLink("subcategory-of");
vulnerabilityUpdate.setIdentifier1(parentCategory);
vulnerabilityUpdate.setIdentifier2(vulnerabilityCategory);
vulnerabilityUpdate.addMetadata(categoryLink);
elements.add(vulnerabilityUpdate);
// create the features
Document[] features = new Document[] {
createFeature("Name", "qualified", v.getNvt().getName(), v),
createFeature("Port", "qualified", v.getPort(), v),
createFeature("Cvss-base", "quantitive", v.getNvt()
.getCvssBase() + "", v),
createFeature("Threat", "quantitive", v.getNvt()
.getRiskFactor().toString(), v),
createFeature("Description", "arbitrary", v.getDescription(), v),
createFeature("CVE", "qualified", v.getNvt().getCve(), v), // TODO split "multi CVE"
};
for (Document d : features) {
PublishUpdate u = Requests.createPublishUpdate();
u.setIdentifier1(vulnerabilityCategory);
u.addMetadata(d);
elements.add(u);
}
return elements;
}
示例4: singleVulnerabilityDelete
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
private List<PublishElement> singleVulnerabilityDelete(Vulnerability v,
Device dev) {
List<PublishElement> elements = new ArrayList<PublishElement>();
// delete link to parent category (vulnerability-scan-result)
PublishDelete parentDelete = Requests.createPublishDelete();
Identity parentCategory = createCategory(ROOT_CATEGORY_NAME,
dev.getName());
Identity vulnerability = createCategory(parentCategory.getName()
+ ".vulnerability:" + v.getId(), dev.getName());
parentDelete.setIdentifier1(parentCategory);
parentDelete.setIdentifier2(vulnerability);
String filter = String.format(
"%s:subcategory-of[@ifmap-publisher-id='%s']",
NAMESPACE_PREFIX, mContext.getIfmapPublisherId());
parentDelete.setFilter(filter);
parentDelete.addNamespaceDeclaration(NAMESPACE_PREFIX, NAMESPACE);
elements.add(parentDelete);
// delete all metadata (=features) from the vulnerability(-category)
PublishDelete featureDelete = Requests.createPublishDelete();
featureDelete.setIdentifier1(vulnerability);
String featureFilter = String.format(
"%s:feature[@ifmap-publisher-id='%s']", NAMESPACE_PREFIX,
mContext.getIfmapPublisherId());
featureDelete.setFilter(featureFilter);
featureDelete.addNamespaceDeclaration(NAMESPACE_PREFIX, NAMESPACE);
elements.add(featureDelete);
return elements;
}
示例5: findDeviceForVulnerability
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
private Device findDeviceForVulnerability(Vulnerability v) {
String host = v.getHost();
IpAddress ip = Identifiers.createIp4(host);
Device dev = mContext.getIfmapDeviceForIp(ip);
return dev;
}
示例6: extractDeviceFromResultItems
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
/**
* Pulls the device identifier from the given {@link ResultItem}.
*
* @param resultItems
* the device identifier or <code>null</code>
* @return
*/
private Device extractDeviceFromResultItems(List<ResultItem> resultItems) {
for (ResultItem i : resultItems) {
if (i.getIdentifier1() instanceof Device) {
return (Device) i.getIdentifier1();
}
if (i.getIdentifier2() instanceof Device) {
return (Device) i.getIdentifier2();
}
}
return null;
}
示例7: ClockSkewDetector
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
/**
* Private constructor.
*
* @param ssrc
* @param dev
*/
private ClockSkewDetector(SSRC ssrc, Device dev) {
if (ssrc == null) {
throw new NullPointerException();
}
if (dev == null) {
throw new NullPointerException();
}
mSsrc = ssrc;
mDev = dev;
mMetadataFac = IfmapJ.createStandardMetadataFactory();
}
示例8: IdentifierData
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
public IdentifierData(Identifier o) {
super();
if (o instanceof AccessRequest) {
mName = "access-request";
AccessRequest art = (AccessRequest) o;
mRequestObject = art;
mAttributes.put("name", art.getName());
if (art.getAdministrativeDomain() != null) {
mAttributes.put("administrative-domain",
art.getAdministrativeDomain());
}
this.mType = IdentifierConstants.IdentifierType.ACCESS_REQUEST;
} else if (o instanceof Device) {
mName = "device";
Device d = (Device) o;
mRequestObject = d;
mAttributes.put("name", d.getName());
this.mType = IdentifierConstants.IdentifierType.DEVICE;
} else if (o instanceof IpAddress) {
mName = "ip-address";
IpAddress ipt = (IpAddress) o;
mRequestObject = ipt;
mAttributes.put("value", ipt.getValue());
mAttributes.put("type", ipt.getType().toString());
if (ipt.getAdministrativeDomain() != null) {
mAttributes.put("administrative-domain",
ipt.getAdministrativeDomain());
}
this.mType = IdentifierConstants.IdentifierType.IP_ADDRESS;
} else if (o instanceof Identity) {
mName = "identity";
Identity it = (Identity) o;
mRequestObject = it;
mAttributes.put("name", it.getName());
mAttributes.put("type", it.getType().toString());
if (it.getAdministrativeDomain() != null) {
mAttributes.put("administrative-domain",
it.getAdministrativeDomain());
}
if (it.getOtherTypeDefinition() != null) {
mAttributes.put("other-type-definition",
it.getOtherTypeDefinition());
}
this.mType = IdentifierConstants.IdentifierType.IDENTITY;
} else if (o instanceof MacAddress) {
mName = "mac-address";
MacAddress mt = (MacAddress) o;
mRequestObject = mt;
mAttributes.put("value", mt.getValue());
if (mt.getAdministrativeDomain() != null) {
mAttributes.put("administrative-domain",
mt.getAdministrativeDomain());
}
this.mType = IdentifierConstants.IdentifierType.MAC_ADDRESS;
} else {
this.mType = IdentifierConstants.IdentifierType.OTHER;
}
}
示例9: toUpdates
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
@Override
public List<PublishElement> toUpdates(Set<Vulnerability> vulnerabilities) {
List<PublishElement> elements = new ArrayList<PublishElement>();
// group the vulnerabilities by IP address
Map<String, List<Vulnerability>> byIp = sortByIp(vulnerabilities);
for (List<Vulnerability> vulnerabilityList : byIp.values()) {
if (vulnerabilityList.size() > 0) {
// check if there is a device identifier for the current host
Vulnerability first = vulnerabilityList.get(0);
Device dev = findDeviceForVulnerability(first);
if (dev != null) {
LOGGER.finer("found device " + dev + " for "
+ first.getHost());
} else {
LOGGER.finer("creating device for " + first.getHost());
dev = Identifiers.createDev(new SecureRandom().nextInt()
+ "");
}
mHostDeviceMaping.put(first.getHost(), dev);
// create the "vulnerability-scan-result" root category
// for the current host
PublishUpdate update = Requests.createPublishUpdate();
Identity category = createCategory(ROOT_CATEGORY_NAME,
dev.getName());
Document deviceCategory = createCategoryLink("device-category");
update.setIdentifier1(dev);
update.setIdentifier2(category);
update.addMetadata(deviceCategory);
elements.add(update);
// create sub-tree for each of the vulnerabilities
for (Vulnerability v : vulnerabilities) {
List<PublishElement> e = singleVulnerability(v, category,
dev);
elements.addAll(e);
}
}
}
return elements;
}
示例10: main
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
public static void main(String[] args) {
command = "feature";
ArgumentParser parser = createDefaultParser();
ParserUtil.addFeatureTargetDevice(parser);
ParserUtil.addFeatureTreeDepth(parser);
ParserUtil.addFeatureMaxChilds(parser);
ParserUtil.addFeatureMaxFeatures(parser);
parseParameters(parser, args);
printParameters(new String[] {KEY_TARGET_DEVICE, KEY_DEPTH, KEY_MAX_CHILDS, KEY_MAX_FEATURES});
deviceIdentifier = resource.getString(KEY_TARGET_DEVICE);
treeDepth = resource.getInt(KEY_DEPTH);
maxChildsPerCategory = resource.getInt(KEY_MAX_CHILDS);
maxFeaturePerCategory = resource.getInt(KEY_MAX_FEATURES);
try {
SSRC ssrc = createSSRC();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
PublishUpdate update = Requests.createPublishUpdate();
String nodeName = "rootCategory";
Device dev = Identifiers.createDev(deviceIdentifier);
Identity root = createCategory(nodeName, deviceIdentifier);
Document deviceCategory = createCategoryLink("device-category");
update.setIdentifier1(dev);
update.setIdentifier2(root);
update.addMetadata(deviceCategory);
update.setLifeTime(MetadataLifetime.forever);
publishUpdates.add(update);
fork(root, 0, new String[] {nodeName});
ssrc.newSession();
PublishRequest req = Requests.createPublishReq();
for (PublishUpdate u : publishUpdates) {
req.addPublishElement(u);
}
ssrc.publish(req);
ssrc.endSession();
printStats();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例11: main
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
public static void main(String[] args) {
command = "perf1";
long maxBytes = Runtime.getRuntime().maxMemory();
System.out.println("Max memory: " + maxBytes / 1024 / 1024 + "M");
ArgumentParser parser = createDefaultParser();
ParserUtil.addPerf1NumberRequests(parser);
ParserUtil.addPerf1NumberUpdates(parser);
ParserUtil.addPerf1NumberSprints(parser);
parseParameters(parser, args);
printParameters(new String[] {KEY_NUMBER_REQUESTS, KEY_NUMBER_UPDATES, KEY_NUMBER_SPRINTS});
int numberRequests = resource.getInt(KEY_NUMBER_REQUESTS);
int numberUpdates = resource.getInt(KEY_NUMBER_UPDATES);
int sizeSprint = resource.getInt(KEY_NUMBER_SPRINTS);
int numberOfSprints;
if (sizeSprint > numberRequests){
// there is only one sprint
numberOfSprints = 1;
sizeSprint = numberRequests;
} else {
numberOfSprints = numberRequests / sizeSprint;
}
Device rootNode = Identifiers.createDev("parentNode");
Document authBy = mf.createAuthBy();
ArrayList<PublishRequest> publishRequests = new ArrayList<PublishRequest>(1000);
PublishRequest pr;
PublishUpdate pu;
Identifier id;
// create a certain number of publish requests
for (int i = 0; i < numberRequests; i++) {
pr = Requests.createPublishReq();
// create a certain number of publish updates
for (int j = 0; j < numberUpdates; j++) {
pu = Requests.createPublishUpdate();
// generate new Identifier
id = Identifiers.createIdentity(IdentityType.userName,
new Integer(Perf1.counter++).toString());
pu.setIdentifier1(rootNode);
pu.setIdentifier2(id);
pu.addMetadata(authBy);
pr.addPublishElement(pu);
}
publishRequests.add(pr);
}
try {
SSRC ssrc = createSSRC();
ssrc.newSession();
long start = System.currentTimeMillis();
for (int i = 0; i < numberOfSprints; i++) {
System.out.print("Do publish sprint " + i);
long startSprint = System.currentTimeMillis();
for (int j = i * sizeSprint; j < (i * sizeSprint) + sizeSprint; j++) {
pr = publishRequests.get(j);
ssrc.publish(pr);
}
long endSprint = System.currentTimeMillis();
System.out.print(" done! -> ");
System.out.println("Duration: " + (endSprint - startSprint) + "ms");
}
long end = System.currentTimeMillis();
System.out.println("Total Duration: " + (end - start) + "ms");
ssrc.endSession();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例12: main
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
public static void main(String[] args) {
command = "feature2";
ArgumentParser parser = createDefaultParser();
ParserUtil.addFeatureTargetDevice(parser);
parseParameters(parser, args);
printParameters(new String[] {KEY_TARGET_DEVICE});
deviceIdentifier = resource.getString(KEY_TARGET_DEVICE);
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
PublishUpdate update = Requests.createPublishUpdate();
DummyCategory root = prepareCategoriesAndFeatures();
// from device to category
String nodeName = root.localId;
Device dev = Identifiers.createDev(deviceIdentifier);
Identity rootCategory = createCategory(nodeName, deviceIdentifier);
Document deviceCategory = createCategoryLink("device-category");
update.setIdentifier1(dev);
update.setIdentifier2(rootCategory);
update.addMetadata(deviceCategory);
update.setLifeTime(MetadataLifetime.forever);
publishUpdates.add(update);
fork(rootCategory, root.features, root.subCategories);
// fork(smartphoneCategory, new String[] {nodeName}, );
SSRC ssrc = createSSRC();
ssrc.newSession();
PublishRequest req = Requests.createPublishReq();
for (PublishUpdate u : publishUpdates) {
req.addPublishElement(u);
}
ssrc.publish(req);
ssrc.endSession();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例13: createClockSkewDetector
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
/**
* Create a {@link ClockSkewDetector} instance which can be used to
* synchronize the time with the MAPS.
*
* @param ssrc
* the {@link SSRC} instance to be used for synchronization
* @param dev
* the {@link Device} used for time synchronization
* @return
*/
public static ClockSkewDetector createClockSkewDetector(SSRC ssrc, Device dev) {
return ClockSkewDetector.newInstance(ssrc, dev);
}
示例14: newInstance
import de.hshannover.f4.trust.ifmapj.identifier.Device; //导入依赖的package包/类
/**
* Factory method to get a {@link ClockSkewDetector} instance.
*
* @param ssrc
* @param dev
* @return
*/
public static ClockSkewDetector newInstance(SSRC ssrc, Device dev) {
return new ClockSkewDetector(ssrc, dev);
}