示例#1
0
        public void testFakeIRI()
        {
            Resolver oResolver = new IRIResolver();
            ResolverState state = new ResolverState();
            oResolver.setMaxHttpRedirects(0);
            try
            {
            XRD oDesc = oResolver.resolveAuthToXRD(
                    "xri://www.epok.net/!foo!bar", new TrustType(), true, state);
            assertTrue(
                "Failed to obtain XRD for IRI Authority",
                oDesc != null);
            assertTrue(
                "Failed to obtain correct XRD for IRI Authority",
                oDesc.getRefAt(0).getValue().Equals(
                    "xri://@foo"));
            }
            catch (Exception oEx)
            {
            oEx.printStackTrace();
            if (oEx is PartialResolutionException) {
                System.err.println("Partial = " + ((PartialResolutionException)oEx).getPartialXRDS());
            }
            System.err.println("Resolver state = " + state);
            fail("Got exception while trying to resolve IRI " + oEx);
            }

            try
            {
            XRD oDesc = oResolver.resolveAuthToXRD(
                    "xri://www.epok.net/!foo!bar", new TrustType(TrustType.TRUST_SAML), true);
            assertTrue(
                "Failed to get exception for trusted IRI Authority resolution",
                false);
            }
            catch (XRIResolutionException oEx) {}
            catch (Exception oEx)
            {
            fail("Got wrong exception while trying to resolve IRI " + oEx);
            }
        }
示例#2
0
文件: Resolver.cs 项目: tt/dotnetxri
	/**
	 * This is the recommended API to use for performing authority resolution an an XRI
	 * @param qxri
	 * @param flags - ResolverFlag
	 * @param state - ResolverState
	 * @return
	 * @throws PartialResolutionException
	 */
	public XRDS resolveAuthToXRDS(XRI qxri, ResolverFlags flags,
			ResolverState state) throws PartialResolutionException {
示例#3
0
            //throws XRIResolutionException
            /*
            ************************************************************************
            * getDataFromURI()
            ************************************************************************
            */
            /**
            *
            */
            protected InputStream getDataFromURI(URI uri, String query, ResolverFlags flags, ResolverState state)
            {
                // if we got the nonexistent "command" return a not found
                if (uri.getPath().indexOf("!nonexistent") >= 0)
                {
                XRD xrd = new XRD();
                xrd.setQuery("!nonexistent");
                xrd.setStatus(new Status(Status.AUTH_RES_NOT_FOUND));
                XRDS xrds = new XRDS();
                xrds.add(xrd);
                return new ByteArrayInputStream(xrds.toString().getBytes());
                }

                XRDS oDescs = new XRDS();

                // just the same response always
                XRD oFoo = new XRD();
                oFoo.setQuery("!foo");
                oFoo.setStatus(new Status(Status.SUCCESS));
                oDescs.add(oFoo);

                XRD oBar = new XRD();
                oBar.setQuery("!bar");
                oBar.setStatus(new Status(Status.SUCCESS));
                oDescs.add(oBar);

                if (uri.getPath().indexOf("!baz") > 0) {
                XRD baz = new XRD();
                baz.setQuery("!baz");
                baz.setStatus(new Status(Status.AUTH_RES_NOT_FOUND, "Not found"));
                oDescs.add(baz);
                }
                return new ByteArrayInputStream(oDescs.toString().getBytes());
            }
示例#4
0
            //    throws XRIResolutionException
            protected InputStream getDataFromURI(URI oURI, string query, ResolverFlags flags, ResolverState state)
            {
                // the path better be empty
                if ((oURI.getPath() != null) && (oURI.getPath().Length > 0))
                return null;

                XRD oDesc = new XRD();
                XRI oExternal = new XRI("xri://@foo");
                oDesc.addRef(new Ref(oExternal.toString()));
                XRDS oDescs = new XRDS();
                oDescs.add(oDesc);

                state.pushResolved(oURI.toString(), flags.toString(), oDesc.toString(), oURI);

                return new ByteArrayInputStream(oDescs.toString().getBytes());
            }