当前位置: 首页>>代码示例>>Java>>正文


Java Identifiers.createIp4方法代码示例

本文整理汇总了Java中de.hshannover.f4.trust.ifmapj.identifier.Identifiers.createIp4方法的典型用法代码示例。如果您正苦于以下问题:Java Identifiers.createIp4方法的具体用法?Java Identifiers.createIp4怎么用?Java Identifiers.createIp4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在de.hshannover.f4.trust.ifmapj.identifier.Identifiers的用法示例。


在下文中一共展示了Identifiers.createIp4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: singleUpdate

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public PublishElement singleUpdate(Vulnerability v) {
    IpAddress ip = Identifiers.createIp4(v.getHost());
    Document metadata = mMetadataFactory.createEvent(v.getNvt().getName(), // name
            mDateFormat.format(v.getTimestamp()), // discovered-time
            mContext.getOpenVasServerId(), // discoverer-id
            (int) (v.getNvt().getCvssBase() * 10 + 0.5), // magnitude
                                                            // (0-100)
            0, // confidence TODO define
            mapSignificance(v.getNvt().getRiskFactor()), // significance
            EventType.cve, // type
            v.getId(), // other-type-definition
            v.getDescription(), // information
            v.getNvt().getCve() // vulnerability-uri
            );

    PublishUpdate update = Requests.createPublishUpdate();
    update.setIdentifier1(ip);
    update.addMetadata(metadata);

    return update;
}
 
开发者ID:trustathsh,项目名称:ironvas,代码行数:22,代码来源:EventUpdateConverter.java

示例2: createSelfPublishRequest

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public static PublishRequest createSelfPublishRequest(String ipValue, String deviceName,
		String serviceName, String serviceType, String servicePort, String implementationName,
		String implementationVersion, String implementationPlatform, String implementationPatch,
		String administrativeDomain) {
	List<PublishElement> publishElements = new ArrayList<PublishElement>();

	Identifier ip = Identifiers.createIp4(ipValue);
	Identifier device = Identifiers.createDev(deviceName);
	publishElements.add(createDeviceIpPubElement(device, ip));

	try {
		Identifier service = createService(serviceName, serviceType, servicePort, administrativeDomain);
		Identifier implementation = createImplementation(implementationName, implementationVersion,
				implementationPlatform, implementationPatch, administrativeDomain);

		publishElements.add(createServiceIpPubElement(service, ip));
		publishElements.add(createServiceImplementationPubElement(service, implementation));
	} catch (MarshalException e) {
		e.printStackTrace();
	}

	return Requests.createPublishReq(publishElements);
}
 
开发者ID:trustathsh,项目名称:ironvas,代码行数:24,代码来源:SelfPublisher.java

示例3: setup

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
	DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
	f.setNamespaceAware(true);
	DocumentBuilder builder = f.newDocumentBuilder();
	mIdentifierFactory = new InMemoryIdentifierFactory();

	mIpAddress = Identifiers.createIp4("10.1.1.1");
	mIpAddressDocument = builder.newDocument();
	Element e1 = Identifiers.tryToElement(mIpAddress, mIpAddressDocument);
	mIpAddressDocument.appendChild(e1);

	mIdentity = Identifiers.createIdentity(
			IdentityType.other, "smartphone.os.android", "smartphone:01", "32939:category");
	mIdentityDocument = builder.newDocument();
	Element e2 = Identifiers.tryToElement(mIdentity, mIdentityDocument);
	mIdentityDocument.appendChild(e2);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:19,代码来源:InMemoryIdentifierFactoryTest.java

示例4: convertVertex

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
/**
 * Converts an IF-MAP vertex to an ifmapj defined {@link Identifier}
 * 
 * @param vertex
 *            the vertex in internal format
 * @return the corresponding {@link Identifier}
 */
protected Identifier convertVertex(IfmapVertex vertex) {
	switch (vertex.getTypeName()) {
		case "device":
			return Identifiers.createDev(vertex.valueFor("/device/name"));
		case "ip-address":
			return Identifiers.createIp4(vertex.valueFor("/ip-address[@value]"));
		case "access-request":
			return Identifiers.createAr(vertex.valueFor("/access-request[@name]"));
		default:
			LOGGER.warn("Pu types than dev, ip and ar are not supported as entry points yet!");
			break;
	}
	return null;
}
 
开发者ID:trustathsh,项目名称:irongpm,代码行数:22,代码来源:PublishAction.java

示例5: createSelfPublishRequest

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public static PublishRequest createSelfPublishRequest(String ipValue, String deviceName) {
	List<PublishElement> publishElements = new ArrayList<PublishElement>();

	Identifier ip = Identifiers.createIp4(ipValue);
	Identifier device = Identifiers.createDev(deviceName);
	publishElements.add(createDeviceIpPubElement(device, ip));

	return Requests.createPublishReq(publishElements);
}
 
开发者ID:trustathsh,项目名称:irongpm,代码行数:10,代码来源:SelfPublisher.java

示例6: singleDelete

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public PublishDelete singleDelete(Vulnerability v) {
    PublishDelete delete = Requests.createPublishDelete();

    String filter = String.format("meta:event[@ifmap-publisher-id='%s' "
            + "and other-type-definition='%s']",
            mContext.getIfmapPublisherId(), v.getId());

    IpAddress ip = Identifiers.createIp4(v.getHost());
    delete.addNamespaceDeclaration("meta", IfmapStrings.STD_METADATA_NS_URI);
    delete.setFilter(filter);
    delete.setIdentifier1(ip);

    return delete;
}
 
开发者ID:trustathsh,项目名称:ironvas,代码行数:15,代码来源:EventUpdateConverter.java

示例7: findDeviceForVulnerability

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
private Device findDeviceForVulnerability(Vulnerability v) {
    String host = v.getHost();
    IpAddress ip = Identifiers.createIp4(host);
    Device dev = mContext.getIfmapDeviceForIp(ip);

    return dev;
}
 
开发者ID:trustathsh,项目名称:ironvas,代码行数:8,代码来源:EsukomFeatureConverter.java

示例8: main

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public static void main(String[] args) {
	command = "dev-ip";
	
	ArgumentParser parser = createDefaultParser();
	ParserUtil.addPublishOperation(parser);
	ParserUtil.addDevice(parser);
	ParserUtil.addIpv4Address(parser);

	parseParameters(parser, args);
	
	printParameters(KEY_OPERATION, new String[] {KEY_DEVICE, KEY_IP});
	
	String device = resource.getString(KEY_DEVICE);
	String ip = resource.getString(KEY_IP);
	
	// prepare identifiers
	Identifier devIdentifier = Identifiers.createDev(device);
	Identifier ipIdentifier = Identifiers.createIp4(ip);

	// prepare metadata
	Document metadata = mf.createDevIp();

	PublishRequest request;
	// update or delete
	if (isUpdate(KEY_OPERATION)) {
		PublishUpdate publishUpdate = Requests.createPublishUpdate(devIdentifier, ipIdentifier,
				metadata, MetadataLifetime.forever);
		request = Requests.createPublishReq(publishUpdate);
	} else {
		String filter = "meta:device-ip";
		PublishDelete publishDelete = Requests.createPublishDelete(devIdentifier, ipIdentifier, filter);
		publishDelete.addNamespaceDeclaration(IfmapStrings.STD_METADATA_PREFIX,
				IfmapStrings.STD_METADATA_NS_URI);
		request = Requests.createPublishReq(publishDelete);
	}

	// publish
	publishIfmapData(request);
}
 
开发者ID:trustathsh,项目名称:ifmapcli,代码行数:40,代码来源:DevIp.java

示例9: main

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public static void main(String[] args) {
	command = "ar-ip";
	
	ArgumentParser parser = createDefaultParser();
	ParserUtil.addPublishOperation(parser);
	ParserUtil.addAccessRequest(parser);
	ParserUtil.addIpv4Address(parser);

	parseParameters(parser, args);
	
	printParameters(KEY_OPERATION, new String[] {KEY_ACCESS_REQUEST, KEY_IP});

	String ar = resource.getString(KEY_ACCESS_REQUEST);
	String ip = resource.getString(KEY_IP);
	
	// prepare identifiers
	Identifier arIdentifier = Identifiers.createAr(ar);
	Identifier ipIdentifier = Identifiers.createIp4(ip);

	// prepare metadata
	Document metadata = mf.createArIp();

	PublishRequest request;
	// update or delete
	if (isUpdate(KEY_OPERATION)) {
		PublishUpdate publishUpdate = Requests.createPublishUpdate(arIdentifier, ipIdentifier,
				metadata, MetadataLifetime.forever);
		request = Requests.createPublishReq(publishUpdate);
	} else {
		String filter = "meta:access-request-ip";
		PublishDelete publishDelete = Requests.createPublishDelete(arIdentifier, ipIdentifier, filter);
		publishDelete.addNamespaceDeclaration(IfmapStrings.STD_METADATA_PREFIX,
				IfmapStrings.STD_METADATA_NS_URI);
		request = Requests.createPublishReq(publishDelete);
	}

	publishIfmapData(request);
}
 
开发者ID:trustathsh,项目名称:ifmapcli,代码行数:39,代码来源:ArIp.java

示例10: createStartIdentifier

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
private static Identifier createStartIdentifier(String sIdentifierType, String sIdentifier) {
	switch (sIdentifierType) {
		case "device":
			return Identifiers.createDev(sIdentifier);
		case "access-request":
			return Identifiers.createAr(sIdentifier);
		case "ip-address":
			String[] split = sIdentifier.split(",");
			switch (split[0]) {
				case "IPv4":
					return Identifiers.createIp4(split[1]);
				case "IPv6":
					return Identifiers.createIp6(split[1]);
				default:
					throw new RuntimeException("unknown IP address type '"
							+ split[0] + "'");
			}
		case "mac-address":
			return Identifiers.createMac(sIdentifier);

		// TODO identity and extended identifiers

		default:
			throw new RuntimeException("unknown identifier type '"
					+ sIdentifierType + "'");
	}
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:28,代码来源:SubscriptionHelper.java

示例11: createIpv4AddressDocument

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
private Document createIpv4AddressDocument(String value) {
	de.hshannover.f4.trust.ifmapj.identifier.Identifier id = Identifiers.createIp4("10.1.1.1");
	Document document = mBuilder.newDocument();
	Element element = Identifiers.tryToElement(id, document);
	document.appendChild(element);
	return document;
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:8,代码来源:InMemoryIdentifierFactoryTest.java

示例12: createMatchedIdentifier

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
private static Identifier createMatchedIdentifier(RuleMatch match) throws MarshalException {
	LOGGER.trace("Method createMatchedIdentifier(RuleMatch match) called");

	Identifier result = null;
	IfmapVertex matchedVertex = match.getPublishVertex();

	String typeName = matchedVertex.getTypeName();
	String rawData = matchedVertex.getRawData();

	LOGGER.trace("MatchedVertex ("
			+ typeName + "): " + rawData);

	// TODO will not support ALL possible identifier types ... e.g. IPv6
	switch (typeName) {
		case IfmapStrings.ACCESS_REQUEST_EL_NAME:
			result = Identifiers.createAr(matchedVertex.valueFor("/access-request[@name]"));
			break;
		case IfmapStrings.DEVICE_EL_NAME:
			result = Identifiers.createDev(matchedVertex.valueFor("/device/name"));
			break;
		case IfmapStrings.IP_ADDRESS_EL_NAME:
			result = Identifiers.createIp4(matchedVertex.valueFor("/ip-address[@value]"));
			break;
		case IfmapStrings.MAC_ADDRESS_EL_NAME:
			result = Identifiers.createMac(matchedVertex.valueFor("/mac-address[@value]"));
			break;
		case IfmapStrings.IDENTITY_EL_NAME:
			if (matchedVertex.isExtendedIdentifier()) {
				result = Identifiers.createExtendedIdentity(rawData);
			} else {
				String name = matchedVertex.valueFor("/identity[@name]");
				String type = matchedVertex.valueFor("/identity[@type]");
				result = Identifiers.createIdentity(IdentityType.valueOf(type), name);
			}
			break;
		default:
			break;
	}

	return result;
}
 
开发者ID:trustathsh,项目名称:irongpm,代码行数:42,代码来源:PolicyPublisher.java

示例13: publish

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
private static void publish() {
	Identifier accessRequest;
	Identifier macAddress, ipAddress;
	Identifier identity;
	Identifier pepDevice, pdpDevice, endpointDevice;

	try {
		// establish session
		SSRC ssrc = createSSRC();
		ssrc.newSession();
		
		// create identifiers
		accessRequest = Identifiers.createAr(ssrc.getPublisherId() + ":" + username.hashCode());
		macAddress = Identifiers.createMac(mac);
		ipAddress = Identifiers.createIp4(ip);
		identity = Identifiers.createIdentity(IdentityType.userName, username);
		pepDevice = Identifiers.createDev("example-pep-id:" + username.hashCode());
		pdpDevice = Identifiers.createDev("example-pdp-id:" + username.hashCode());
		endpointDevice = Identifiers.createDev("example-endpoint-id:" + username.hashCode());
		
		// add mandatory metadata to publish request
		addArDevice(accessRequest, endpointDevice);
		addArMac(accessRequest, macAddress);
		addArIp(accessRequest, ipAddress);
		addAuthBy(accessRequest, pdpDevice);
		
		// add optional metadata to publish request
		addAuthAs(accessRequest, identity);
		addCap(accessRequest);
		addDevAttr(accessRequest, endpointDevice);
		addDevChar(accessRequest, pdpDevice);
		addRole(accessRequest, identity);
		addLayer2(accessRequest, pepDevice);
		addWlanInfo(accessRequest, pepDevice);
		
		// do publish
		ssrc.publish(publishRequest);
		
		// clean up
		ssrc.endSession();
		ssrc.closeTcpConnection();		
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(-1);
	}
}
 
开发者ID:trustathsh,项目名称:ifmapcli,代码行数:47,代码来源:Pdp.java

示例14: main

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
/**
 * main method
 */
public static void main(String[] args) {
	command = "bhi-addr";

	ArgumentParser parser = createDefaultParser();
	ParserUtil.addPublishOperation(parser);
	ParserUtil.addIcsBackhaulInterface(parser);
	ParserUtil.addIpv4Address(parser);

	parseParameters(parser, args);

	printParameters(KEY_OPERATION, new String[] {KEY_ICS_BACKHAUL_INTERFACE, KEY_IP});

	String bhi = resource.getString(KEY_ICS_BACKHAUL_INTERFACE);
	String ip = resource.getString(KEY_IP);

	// prepare identifiers
	Identity bhiIdentifier = IcsIdentifiers.createBackhaulInterface(bhi);
	IpAddress ipIdentifier = Identifiers.createIp4(ip);

	// prepare metadata
	Document metadata = icsmf.createBhiAdd();

	PublishRequest request;
	// update or delete
	if (isUpdate(KEY_OPERATION)) {
		PublishUpdate publishUpdate = Requests.createPublishUpdate(ipIdentifier, bhiIdentifier,
				metadata, MetadataLifetime.forever);
		request = Requests.createPublishReq(publishUpdate);
	} else {
		String filter = "ics-meta:bhi-address";
		PublishDelete publishDelete = Requests.createPublishDelete(ipIdentifier, bhiIdentifier, filter);
		publishDelete.addNamespaceDeclaration(IfmapStrings.ICS_METADATA_PREFIX,
				IfmapStrings.ICS_METADATA_NS_URI);
		request = Requests.createPublishReq(publishDelete);
	}

	// publish
	publishIfmapData(request);

}
 
开发者ID:trustathsh,项目名称:ifmapcli,代码行数:44,代码来源:BhiAddr.java

示例15: main

import de.hshannover.f4.trust.ifmapj.identifier.Identifiers; //导入方法依赖的package包/类
public static void main(String[] args) {
	command = "ip-mac";
	
	// TODO choice for IPv4 and IPv6
	ArgumentParser parser = createDefaultParser();
	ParserUtil.addPublishOperation(parser);
	ParserUtil.addIpv4Address(parser);
	ParserUtil.addMacAddress(parser);
	ParserUtil.addDhcpServer(parser);
	// TODO start-time, end-time
	
	parseParameters(parser, args);
	
	printParameters(KEY_OPERATION, new String[] {KEY_IP, KEY_MAC, KEY_DHCP_SERVER});

	String ip = resource.getString(KEY_IP);
	String mac = resource.getString(KEY_MAC);
	String dhcpServer = resource.getString(KEY_DHCP_SERVER);
	
	// prepare identifiers
	Identifier ipIdentifier = Identifiers.createIp4(ip);
	Identifier macIdentifier = Identifiers.createMac(mac);

	// prepare metadata
	// TODO start-time, end-time and dhcp-server name from Parser
	Date startTime = new Date(); // now
	Date endTime = new Date(startTime.getTime() + (1000*60*60*8)); // 8 hours later
	Document metadata = mf.createIpMac(Common.getTimeAsXsdDateTime(startTime),
			Common.getTimeAsXsdDateTime(endTime), dhcpServer);

	PublishRequest request;
	// update or delete
	if (isUpdate(KEY_OPERATION)) {
		PublishUpdate publishUpdate = Requests.createPublishUpdate(ipIdentifier, macIdentifier,
				metadata, MetadataLifetime.forever);
		request = Requests.createPublishReq(publishUpdate);
	} else {
		String filter = "meta:ip-mac[dhcp-server='ip-mac-cli']";
		PublishDelete publishDelete = Requests.createPublishDelete(ipIdentifier, macIdentifier, filter);
		publishDelete.addNamespaceDeclaration(IfmapStrings.STD_METADATA_PREFIX,
				IfmapStrings.STD_METADATA_NS_URI);
		request = Requests.createPublishReq(publishDelete);
	}

	// publish
	publishIfmapData(request);
}
 
开发者ID:trustathsh,项目名称:ifmapcli,代码行数:48,代码来源:IpMac.java


注:本文中的de.hshannover.f4.trust.ifmapj.identifier.Identifiers.createIp4方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。