本文整理汇总了C#中Resolver.setAuthority方法的典型用法代码示例。如果您正苦于以下问题:C# Resolver.setAuthority方法的具体用法?C# Resolver.setAuthority怎么用?C# Resolver.setAuthority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resolver
的用法示例。
在下文中一共展示了Resolver.setAuthority方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setupResolver
public static Resolver setupResolver()
{
// instantiate a Resolver obj
Resolver resolver = new Resolver();
// configure roots
XRD eqRoot = createAuthRoot("http://equal.xri.net");
resolver.setAuthority("=", eqRoot);
XRD atRoot = createAuthRoot("http://at.xri.net");
resolver.setAuthority("@", atRoot);
return resolver;
}
示例2: main
//.........这里部分代码省略.........
msTargetXRI = null;
mbIsVerbose = false;
msRootEqualsURI = ROOT_DEF_EQ_URI;
msRootAtURI = ROOT_DEF_AT_URI;
msRootBangURI = ROOT_DEF_BANG_URI;
msProxyURI = null;
mbCheckRoots = true;
msRootFile = null;
try {
setTrustType(TRUST_TYPE);
}
catch (Exception e) {
e.printStackTrace();
}
// exit with message if no arguments passed on the command line
if (sArgs.length == 0)
{
outputPleaseTypeHelp(sOutput);
return FAILURE;
}
// this is the "help" form of invocation (usage 2)
if (sArgs[0].equalsIgnoreCase(CMD_HELP))
{
outputUsage(sOutput);
return SUCCESS;
}
// from here on, we're dealing with the "normal" form of invocation
// (usage 1).
// scan the args, setting member variables for options, rootURI,
// and resolve XRI
int iResult = scanArgs(sOutput, sArgs);
if (iResult == FAILURE)
{
return FAILURE;
}
// validate that the root uris are ok
if (mbCheckRoots)
{
iResult = validateRootURIs(sOutput);
if (iResult == FAILURE)
{
return FAILURE;
}
}
// create and configure a resolver
Resolver resolver = new Resolver();
// populate the root with whatever trustType the user requested
String trustParam = ";" + trustType.getParameterPair();
XRD eqRoot = new XRD();
Service eqAuthService = new Service();
eqAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + trustParam, SEPElement.MATCH_ATTR_CONTENT, Boolean.FALSE);
eqAuthService.addType(Tags.SERVICE_AUTH_RES);
eqAuthService.addURI(msRootEqualsURI);
eqRoot.addService(eqAuthService);
XRD atRoot = new XRD();
Service atAuthService = new Service();
atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + trustParam, SEPElement.MATCH_ATTR_CONTENT, Boolean.FALSE);
atAuthService.addType(Tags.SERVICE_AUTH_RES);
atAuthService.addURI(msRootAtURI);
atRoot.addService(atAuthService);
XRD bangRoot = new XRD();
Service bangAuthService = new Service();
bangAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + trustParam, SEPElement.MATCH_ATTR_CONTENT, Boolean.FALSE);
bangAuthService.addType(Tags.SERVICE_AUTH_RES);
bangAuthService.addURI(msRootBangURI);
bangRoot.addService(bangAuthService);
resolver.setAuthority("=", eqRoot);
resolver.setAuthority("@", atRoot);
resolver.setAuthority("!", bangRoot);
if (msRootFile != null)
{
setRootsFromFile(resolver, msRootFile);
}
// invoke the tracert
lookup(sOutput, resolver);
}
catch (Throwable oThrowable)
{
outputException(sOutput, oThrowable);
return FAILURE;
}
return SUCCESS;
}
示例3: main
} // main()
/*
****************************************************************************
* process()
****************************************************************************
*/ /**
* Executes the xritracert command as indicated by the input args. See
* outputUsage for the forms of invocation and details about the program
* arguments.
*
* @param sArgs - command line arguments (e.g., from main)
* @param sOutput - program output (e.g., for stdout)
*
* @return SUCCESS or FAILURE
*/
public int process(StringBuilder sOutput, String[] sArgs)
{
try
{
// re-initialize variables so this may be called more than once
sOutput.setLength(0);
msTargetXRI = null;
mbIsVerbose = false;
mbDontOutputHeader = false;
msRootEqualsURI = ROOT_DEF_URI;
msRootAtURI = ROOT_DEF_URI;
// exit with message if no arguments passed on the command line
if (sArgs.length == 0)
{
outputPleaseTypeHelp(sOutput);
return FAILURE;
}
// this is the "help" form of invocation (usage 2)
if (sArgs[0].equalsIgnoreCase(CMD_HELP))
{
outputUsage(sOutput);
return SUCCESS;
}
// from here on, we're dealing with the "normal" form of invocation
// (usage 1).
// scan the args, setting member variables for options, rootURI,
// and resolve XRI
int iResult = scanArgs(sOutput, sArgs);
if (iResult == FAILURE)
{
return FAILURE;
}
// validate that the root uris are ok
iResult = validateRootURIs(sOutput);
if (iResult == FAILURE)
{
return FAILURE;
}
// create and configure a resolver
Resolver resolver = new Resolver();
XRD eqRoot = new XRD();
Service eqAuthService = new Service();
eqAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
eqAuthService.addType(Tags.SERVICE_AUTH_RES);
eqAuthService.addURI(msRootEqualsURI);
eqRoot.addService(eqAuthService);
XRD atRoot = new XRD();
Service atAuthService = new Service();
atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
atAuthService.addType(Tags.SERVICE_AUTH_RES);
atAuthService.addURI(msRootAtURI);
atRoot.addService(atAuthService);
resolver.setAuthority("=", eqRoot);
resolver.setAuthority("@", atRoot);
// invoke the tracert
tracert(sOutput, resolver);
}
catch (Throwable oThrowable)
{
outputException(sOutput, oThrowable);
return FAILURE;
}
return SUCCESS;
}