• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XDIDiscoveryResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCloudName

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public String getCloudName(String cloudNumber) {
	Assert.hasLength(cloudNumber);

	long start = System.currentTimeMillis();
	String cloudName;
	
	try {

		XDIDiscoveryResult result = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discover(XDIAddress.create(cloudNumber));
		cloudName = result.getCloudNames()[0].toString();
	} catch (Exception e) {
		log.warn("Not possible to get a cloud name for " + cloudNumber + " - " + e.getMessage());
		return null;
	}

	if (cloudName == null) {
		log.warn("Not possible to get a cloud name for " + cloudNumber);
		return null;
	}
		
	
	log.debug("CloudNumber " + cloudNumber + " translated to " + cloudName + " in " + (System.currentTimeMillis() - start) + "ms");

	return cloudName;
}
 
开发者ID:projectdanube,项目名称:xdi2-manager,代码行数:26,代码来源:ReverseNameResolutionService.java


示例2: sampleAuthenticateSecretToken

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void sampleAuthenticateSecretToken() throws Xdi2ClientException {

		XDIDiscoveryClient xdiDiscoveryClient = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT;
		XDIDiscoveryResult xdiDiscoveryResult = xdiDiscoveryClient.discoverFromRegistry(XDIAddress.create("=alice"));

		CloudNumber cloudNumber = xdiDiscoveryResult.getCloudNumber();
		URI xdiEndpointUri = xdiDiscoveryResult.getXdiEndpointUri();
		String secretToken = "alice";

		try {

			XDIClientUtil.authenticateSecretToken(cloudNumber, xdiEndpointUri, secretToken);
		} catch (Xdi2ClientException ex) {

			System.err.println("Not authenticated.");
			throw ex;
		}

		System.out.println("Successfully authenticated.");
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:21,代码来源:RetrievePrivateKey.java


示例3: main

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		XDIDiscoveryClient xdiDiscoveryClient = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT;
		XDIDiscoveryResult resultFromRegistry = xdiDiscoveryClient.discoverFromRegistry(XDIAddress.create("=markus"));

		System.out.println("Result from registry:");
		System.out.println("Cloud Number: " + resultFromRegistry.getCloudNumber());
		System.out.println("Cloud Names: " + (resultFromRegistry.getCloudNames() == null ? null : Arrays.asList(resultFromRegistry.getCloudNames())));
		System.out.println("URI: " + resultFromRegistry.getXdiEndpointUri());
		System.out.println();

		if (resultFromRegistry.getXdiEndpointUri() != null && resultFromRegistry.getCloudNumber() != null) {

			XDIDiscoveryResult resultFromAuthority = xdiDiscoveryClient.discoverFromAuthority(resultFromRegistry.getXdiEndpointUri(), resultFromRegistry.getCloudNumber());

			System.out.println("Result from authority:");
			System.out.println("Cloud Number: " + resultFromAuthority.getCloudNumber());
			System.out.println("Cloud Names: " + (resultFromAuthority.getCloudNames() == null ? null : Arrays.asList(resultFromAuthority.getCloudNames())));
			System.out.println("URI: " + resultFromAuthority.getXdiEndpointUri());
		}
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:22,代码来源:SimpleDiscovery.java


示例4: discover

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public CloudNumber discover (String cloudName) throws Xdi2ClientException {
	Assert.hasLength(cloudName);
	cloudName = XdiUtils.normalizeCloudName(cloudName);
	
	XDIDiscoveryResult result = XDIDiscoveryClient.XDI2_DISCOVERY_CLIENT.discoverFromRegistry(XDIAddress.create(cloudName));

	return result.getCloudNumber();
}
 
开发者ID:projectdanube,项目名称:xdi2-manager,代码行数:9,代码来源:DiscoveryService.java


示例5: getDependentData

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static DependentData getDependentData( Statement stmt )
{
	try
	{
		CloudNumber cloudNumber = CloudNumber.create(stmt.getObject().toString());
		XDIDiscoveryResult result = getXDIDiscoveryClient().discoverFromRegistry(cloudNumber.getXDIAddress(), null);
		URL cloudUrl = result.getXdiEndpointUrl();

		Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
		MessageEnvelope getMessageEnvelope = new MessageEnvelope();
		Message getMessage = getMessageEnvelope.createMessage(cloudNumber.getXDIAddress());
		getMessage.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
		getMessage.setLinkContract(PublicLinkContract.class);
		getMessage.createGetOperation(XDIStatement.fromRelationComponents(cloudNumber.getXDIAddress(), XDIDictionaryConstants.XDI_ADD_IS_REF, XDIConstants.XDI_ADD_COMMON_VARIABLE));
		MessageResult getMessageResult = new XDIHttpClient(cloudUrl).send(getMessageEnvelope, null);
		for( Statement stmt1 : getMessageResult.getGraph().getRootContextNode().getAllStatements())
		{
			if( XDIDictionaryConstants.XDI_ADD_IS_REF.equals(stmt1.getPredicate()) == false )
			{
				logger.debug("getDependentData() - Ignore " + stmt1);
				continue;
			}
			logger.debug("getDependentData() - Process " + stmt1);
			String cloudName = stmt1.getObject().toString();
			DependentData rtn = new DependentData();
			rtn.setCloudName(cloudName);
			rtn.setCloudNumber(cloudNumber);
			rtn.setCloudUrl(cloudUrl);
			return rtn;
		}
	}
	catch( Exception e )
	{
		logger.error("getDependentData() failed - " + e.getMessage(), e);
	}
	logger.error("getDependentData() - Cannot find dependent cloud " + stmt);
	return null;
}
 
开发者ID:nzatnsr,项目名称:neustar-clouds-proxy,代码行数:39,代码来源:ProxyXdiService.java


示例6: sampleRetrievePrivateKeys

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void sampleRetrievePrivateKeys() throws Xdi2ClientException, GeneralSecurityException {

		XDIDiscoveryClient xdiDiscoveryClient = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT;
		XDIDiscoveryResult xdiDiscoveryResult = xdiDiscoveryClient.discoverFromRegistry(XDIAddress.create("=alice"));

		CloudNumber cloudNumber = xdiDiscoveryResult.getCloudNumber();
		URI xdiEndpointUri = xdiDiscoveryResult.getXdiEndpointUri();
		String secretToken = "alice";

		PrivateKey signaturePrivateKey = XDIClientUtil.retrieveSignaturePrivateKey(cloudNumber, xdiEndpointUri, secretToken);
		PrivateKey encryptionPrivateKey = XDIClientUtil.retrieveEncryptionPrivateKey(cloudNumber, xdiEndpointUri, secretToken);

		System.out.println("Successfully retrieved signature private key: " + signaturePrivateKey);
		System.out.println("Successfully retrieved encryption private key: " + encryptionPrivateKey);
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:16,代码来源:RetrievePrivateKey.java


示例7: getEndpointURI

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public  String getEndpointURI(String key , CloudNumber cloudNumber)
{
   
   logger.debug("getEndpointURI key=" + key + " , cloudNumber = " + cloudNumber.toString());
   BasicCSPInformation cspInformation = (BasicCSPInformation)cspRegistrar.getCspInformation();
   XDIDiscoveryClient discovery = cspInformation.getXdiDiscoveryClient();

   discovery.setAuthorityCache(null);
   try
   {
      XDI3Segment[] uriType = new XDI3Segment[1];
      uriType[0] = XDI3Segment.create(key);
      XDIDiscoveryResult discResult = discovery.discover(
            XDI3Segment.create(cloudNumber.toString()), uriType);
      //XDIDiscoveryResult discResult = discovery.discoverFromAuthority("https://mycloud-ote.neustar.biz/registry", cloudNumber, uriType);
      Map<XDI3Segment,String> endpointURIs = discResult.getEndpointUris();
      for (Map.Entry<XDI3Segment, String> epURI : endpointURIs.entrySet())
      {
         logger.debug("Looping ... Endpoint key = " + epURI.getKey().toString() + " ,value=" + epURI.getValue());
         if(epURI.getKey().toString().equals(key))
         {
            logger.debug("Found match for Endpoint key = " + key);
            return epURI.getValue();
         }
      }
      
   } catch (Xdi2ClientException e)
   {
      
      logger.debug("Error in getEndpointURI " + e.getMessage());
   }
   logger.debug("Did not find match for Endpoint key = " + key);
   return "";
   
}
 
开发者ID:RespectNetwork,项目名称:csp-provisioning-application,代码行数:36,代码来源:RegistrationManager.java


示例8: authenticate

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {

	String cloudName = authentication.getName();
	String secret = (String) authentication.getCredentials();
	
	// check if request comes from HTML form or basic auth
	if (authentication.getDetails() instanceof CMWebAuthenticationDetails) {
	}
	else {
		// basic auth - env is part of "username" ENV=cloudname
		String[] param = StringUtils.split(cloudName, "=*+");
		
		cloudName = cloudName.substring(cloudName.indexOf(param[1]) - 1);
		
		log.debug("Basic Auth: trying to authenticate " + cloudName);
	}
	
	 
	
	if (! (cloudName.startsWith("=") || cloudName.startsWith("*") || cloudName.startsWith("+")) ) {
		throw new UsernameNotFoundException("Cloud Name doesn't seem to be valid. Please check if it starts with =");
	}
	
	// cloud name discovery
	XDI2X509TrustManager.enable();

	XDIDiscoveryClient discoveryClient = XDIDiscoveryClient.XDI2_DISCOVERY_CLIENT;
	
	XDIDiscoveryResult result = null;
	try {
		result = discoveryClient.discoverFromRegistry(XDIAddress.create(cloudName));
	} catch (Xdi2ClientException e1) {
		log.warn("Error while discovering " + cloudName + ": " + e1.getMessage(), e1);
		throw new UsernameNotFoundException(e1.getMessage());
	}
	if (result == null || result.getCloudNumber() == null) {
		throw new UsernameNotFoundException("Cloud " + cloudName + " not found.");
	}
	if (result.getXdiEndpointUri() == null || StringUtils.isBlank(result.getXdiEndpointUri().toString())){
		throw new UsernameNotFoundException("Cloud " + cloudName + " found with Cloud Number " + result.getCloudNumber() + " but without Cloud Endpoint.");	
	}

	CloudNumber cloudNumber = result.getCloudNumber();
	String xdiEndpointUri = result.getXdiEndpointUri().toString();

	// authentication on personal cloud
	CloudUser cloudUser = new CloudUser(cloudName, cloudNumber, xdiEndpointUri, secret);

	MessageEnvelope messageEnvelope = new MessageEnvelope();
	MessageCollection messageCollection = messageEnvelope.getMessageCollection(cloudUser.getCloudNumber().getXDIAddress(), true);
	Message message = messageCollection.createMessage();
	message = cloudUser.prepareMessageToCloud(message);
	message.createGetOperation(RootLinkContract.createRootLinkContractXDIAddress(cloudUser.getCloudNumber().getXDIAddress()));

	try {
		cloudUser.getXdiClient().send(messageEnvelope);
	} catch (Xdi2ClientException e) {
		if (StringUtils.containsIgnoreCase(e.getMessage(), "invalid secret token")) {
			throw new BadCredentialsException("Invalid Cloud Name or password ");
		}
		else {
			throw new BadCredentialsException(e.getMessage());
		}
	}
	
	// what can we do here?
	List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
	//		SimpleGrantedAuthority role = new SimpleGrantedAuthority("USER_ROLE");
	//		authorities.add(role);

	return new UsernamePasswordAuthenticationToken(cloudUser, secret, authorities);
}
 
开发者ID:projectdanube,项目名称:xdi2-manager,代码行数:74,代码来源:XdiAuthenticationProvider.java


示例9: getCloudStatus

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public DiscoveryCloudStatus getCloudStatus (String cloudName) throws Xdi2ClientException {
	Assert.hasLength(cloudName);
	
	cloudName = XdiUtils.normalizeCloudName(cloudName);
	
	DiscoveryCloudStatus status = new DiscoveryCloudStatus(cloudName);
	
	XDIDiscoveryResult result = XDIDiscoveryClient.XDI2_DISCOVERY_CLIENT.discover(XDIAddress.create(cloudName));

	status.setCloudNumber(ObjectUtils.toString(result.getCloudNumber(), null));

	status.setCloudEndpoint(ObjectUtils.toString(result.getXdiEndpointUri(), null));

	status.setEncryptionPublicKey(result.getEncryptionPublicKey() != null ? Base64.encodeBase64String(result.getEncryptionPublicKey().getEncoded()) : null);
	status.setSignaturePublicKey(result.getSignaturePublicKey() != null ? Base64.encodeBase64String(result.getSignaturePublicKey().getEncoded()) : null);
	
	return status;
}
 
开发者ID:projectdanube,项目名称:xdi2-manager,代码行数:19,代码来源:DiscoveryService.java


示例10: discoverManual

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void discoverManual(CloudNumber cloudNumber) throws Exception {

		XDIDiscoveryResult resultFromRegistry = xdiDiscoveryClient.discoverFromRegistry(cloudNumber.getXDIAddress());

		URI xdiEndpointUri = resultFromRegistry.getXdiEndpointUri();

		MessageEnvelope messageEnvelope = new MessageEnvelope();
		Message message = messageEnvelope.createMessage(cloudNumber.getXDIAddress());
		message.setToPeerRootXDIArc(cloudNumber.getPeerRootXDIArc());
		message.createGetOperation(XDIStatement.fromComponents(cloudNumber.getXDIAddress(), XDIDictionaryConstants.XDI_ADD_IS_REF, XDIConstants.XDI_ADD_COMMON_VARIABLE));
		message.setLinkContractClass(PublicLinkContract.class);

		XDIClient xdiClient = new XDIHttpClient(xdiEndpointUri);

		MessagingResponse messagingResponse = xdiClient.send(messageEnvelope);

		ContextNode contextNode = messagingResponse.getGraph().getDeepContextNode(cloudNumber.getXDIAddress());
		ReadOnlyIterator<Relation> relations = contextNode.getRelations(XDIDictionaryConstants.XDI_ADD_IS_REF);

		for (Relation relation : relations) System.out.println("Manually discovered: " + relation.follow().getXDIAddress());
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:22,代码来源:CloudNameDiscovery.java


示例11: main

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		LogManager.getLogger("xdi2").setLevel(Level.OFF);

		XDIWriter writer = XDIWriterRegistry.forFormat("XDI DISPLAY", null);

		// discovery

		XDIDiscoveryClient xdiDiscoveryClient = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT;
		XDIDiscoveryResult xdiDiscoveryResult = xdiDiscoveryClient.discoverFromRegistry(XDIAddress.create("=markus"));

		// construct message

		MessageEnvelope messageEnvelope = new MessageEnvelope();
		Message message = messageEnvelope.createMessage(XDIAddress.create("=sender"));
		message.createGetOperation(XDIAddress.create("=markus<#email>"));
		message.setToPeerRootXDIArc(xdiDiscoveryResult.getCloudNumber().getPeerRootXDIArc());
		message.setLinkContractClass(PublicLinkContract.class);

		// construct client, send message, read result

		XDIClient client = new XDIHttpClient(xdiDiscoveryResult.getXdiEndpointUri());

		MessagingResponse messagingResponse = client.send(messageEnvelope);

		// print results

		System.out.println("Discovery result: ");
		writer.write(xdiDiscoveryResult.getMessagingResponse().getGraph(), System.out);
		System.out.println();

		System.out.println("Message envelope: ");
		writer.write(messageEnvelope.getGraph(), System.out);
		System.out.println();

		System.out.println("Messaging response: ");
		writer.write(messagingResponse.getGraph(), System.out);
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:39,代码来源:SimpleClient.java


示例12: discoverAutomatic

import xdi2.discovery.XDIDiscoveryResult; //导入依赖的package包/类
public static void discoverAutomatic(CloudNumber cloudNumber) throws Exception {

		XDIDiscoveryResult result = xdiDiscoveryClient.discover(cloudNumber.getXDIAddress());

		for (CloudName cloudName : result.getCloudNames()) System.out.println("Automatically discovered: " + cloudName);
	}
 
开发者ID:projectdanube,项目名称:xdi2-example-client,代码行数:7,代码来源:CloudNameDiscovery.java



注:本文中的xdi2.discovery.XDIDiscoveryResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationFilterRegistration类代码示例发布时间:2022-05-22
下一篇:
Java PicassoEngine类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap