• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java XDIReader类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中xdi2.core.io.XDIReader的典型用法代码示例。如果您正苦于以下问题:Java XDIReader类的具体用法?Java XDIReader怎么用?Java XDIReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

XDIReader类属于xdi2.core.io包,在下文中一共展示了XDIReader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: signMessage

点赞 2

import xdi2.core.io.XDIReader; //导入依赖的package包/类
public static Graph signMessage(String message, XDIAddress[] addresses, String key) {

		try {
			// parse the message to graph
			Graph graph = MemoryGraphFactory.getInstance().openGraph();
			XDIReader xdiReader = XDIReaderRegistry.getAuto();
			xdiReader.read(graph, new StringReader(message));

			// find the addresses
			for (XDIAddress address : addresses) {

				ContextNode contextNode = graph.getDeepContextNode(address, true);
				if (contextNode == null) throw new RuntimeException("No context node found at address " + address);

				// sign
				RSASignature signature = (RSASignature) Signatures.createSignature(contextNode, "sha", 256, "rsa", 2048, true);

				PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(key));
				KeyFactory keyFactory = KeyFactory.getInstance("RSA");
				Key k = keyFactory.generatePrivate(keySpec);

				new RSAStaticPrivateKeySignatureCreator((PrivateKey) k).createSignature(signature);
			}

			return graph;
		}
		catch(Exception e) {
			log.warn("Error while signing a message:\n" + message, e);
		}

		return null;

	}
 

开发者ID:projectdanube,
项目名称:xdi2-manager,
代码行数:34,
代码来源:XdiUtils.java

示例2: callbackGraph

点赞 2

import xdi2.core.io.XDIReader; //导入依赖的package包/类
@Override
protected void callbackGraph(String messagingContainerPath, Graph graph, MyState state) throws Xdi2MessagingException, IOException {

	XDIReader reader = XDIReaderRegistry.getAuto();

	try {

		graph.clear();
		reader.read(graph, System.in);
	} catch (Exception ex) {

		System.err.println("Problem while loading graph " + messagingContainerPath);
		ex.printStackTrace(System.err);
	}
}
 

开发者ID:projectdanube,
项目名称:xdi2-tools,
代码行数:16,
代码来源:CommandLoadGraph.java

示例3: callbackGraph

点赞 2

import xdi2.core.io.XDIReader; //导入依赖的package包/类
@Override
protected void callbackGraph(String messagingContainerPath, Graph graph, MyState state) throws Xdi2MessagingException, IOException {

	System.out.println("Rebuilding graph " + messagingContainerPath + ".");

	XDIWriter writer = state.mimeType == null ? XDIWriterRegistry.getDefault() : XDIWriterRegistry.forMimeType(new MimeType(state.mimeType));
	XDIReader reader = new AutoReader(null);

	try {

		if (writer == null) throw new RuntimeException("Unknown MIME type " + state.mimeType);

		StringWriter stringWriter = new StringWriter();
		writer.write(graph, stringWriter);

		graph.clear();

		StringReader stringReader = new StringReader(stringWriter.toString());
		reader.read(graph, stringReader);
	} catch (Exception ex) {

		System.err.println("Problem while rebuilding graph " + messagingContainerPath);
		ex.printStackTrace(System.err);
	}
}
 

开发者ID:projectdanube,
项目名称:xdi2-tools,
代码行数:26,
代码来源:CommandRebuildGraphs.java

示例4: callbackGraph

点赞 1

import xdi2.core.io.XDIReader; //导入依赖的package包/类
@Override
protected void callbackGraph(String messagingContainerPath, Graph graph, MyState state) throws Exception {

	String zipEntryName = messagingContainerPath + ".xdi";
	if (zipEntryName.startsWith("/")) zipEntryName = zipEntryName.substring(1);

	ZipEntry zipEntry = state.zipFile.getEntry(zipEntryName);

	if (zipEntry == null) {

		System.out.println("Not restoring graph " + messagingContainerPath + ": Not found in ZIP file.");
		return;
	} else {

		System.out.println("Restoring graph " + messagingContainerPath + ".");
	}

	InputStream zipInputStream = state.zipFile.getInputStream(zipEntry);

	XDIReader reader = XDIReaderRegistry.getAuto();

	try {

		graph.clear();
		reader.read(graph, zipInputStream);
	} catch (Exception ex) {

		System.err.println("Problem while restoring graph " + messagingContainerPath);
		ex.printStackTrace(System.err);
	}

	zipInputStream.close();
}
 

开发者ID:projectdanube,
项目名称:xdi2-tools,
代码行数:34,
代码来源:CommandRestoreGraphs.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)