Examples of XRD


Examples of org.openxri.xml.XRD

        "MaxRequests", "10"));
    int maxTotalBytes = Integer.parseInt(properties.getProperty(
        "MaxTotalBytes", "1048576")); // 1Mb
    int maxBytesPerRequest = Integer.parseInt(properties.getProperty(
        "MaxBytesPerRequest", "512000")); // 500Kb
    XRD equalsAuthority = XRD.parseXRD(properties
        .getProperty("EqualsAuthority"), false);
    XRD atAuthority = XRD.parseXRD(properties.getProperty("AtAuthority"),
        false);
    XRD bangAuthority = XRD.parseXRD(properties
        .getProperty("BangAuthority"), false);
    String supports = properties.getProperty("SupportedResMediaTypes");
 
    this.setMaxFollowRedirects(maxFollowRedirects);
    this.setMaxFollowRefs(maxFollowRefs);
View Full Code Here

Examples of org.openxri.xml.XRD

    this.setAuthority("@", atAuthority);
    this.setAuthority("!", bangAuthority);
  }

  public XRD createErrorXRD(String query, String code, String msg) {
    XRD err = new XRD();
    err.setQuery(query);
    Status stat = new Status(code, msg);
    err.setStatus(stat);
    return err;
  }
View Full Code Here

Examples of org.openxri.xml.XRD

  private XRI parseAbsoluteQXRIOrError(String qxri)
      throws PartialResolutionException {
    try {
      XRI xri = new XRI(qxri);
      if (xri.isRelative()) {
        XRD err = createErrorXRD(qxri, Status.INVALID_QXRI,
            "QXRI is not absolute.");
        throw new PartialResolutionException(err);
      }
      return xri;
    } catch (XRIParseException e) {
      XRD err = createErrorXRD(qxri, Status.INVALID_QXRI,
          "QXRI parse error: " + e.getMessage());
      throw new PartialResolutionException(err);
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri, Status.PERM_FAIL,
          "Unexpected error while parsing input: " + e.getMessage());
      throw new PartialResolutionException(err);
    }
  }
View Full Code Here

Examples of org.openxri.xml.XRD

    public void testCache()
    {
        Cache oCache = new Cache(1000);
        assertTrue("Initial cache not empty", oCache.getNumNodes() == 0);

        XRD oDesc = new XRD();
        Service atAuthService = new Service();
        atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
        atAuthService.addType(Tags.SERVICE_AUTH_RES);
        atAuthService.addURI("http://gcs.epok.net/xri/resolve?ns=at");
        oDesc.addService(atAuthService);

        XRD oDummy = new XRD();
        Service dummyService = new Service();
        dummyService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
        dummyService.addType(Tags.SERVICE_AUTH_RES);
        dummyService.addURI("http://www.example.com/xri/resolve?id=1");
        oDummy.addService(dummyService);

        GCSAuthority oAuth = new GCSAuthority("@");
        oCache.stuff(oAuth, oDesc);
        assertTrue("Initial cache incorrect", oCache.getNumNodes() == 1);
View Full Code Here

Examples of org.openxri.xml.XRD

        Cache oCache = new Cache(1000);
        oCache.prune((XRIAuthority) AuthorityPath.buildAuthorityPath("@"));
        assertTrue("Initial cache not empty", oCache.getNumNodes() == 0);

       
        XRD oDesc = new XRD();
        Service atAuthService = new Service();
        atAuthService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
        atAuthService.addType(Tags.SERVICE_AUTH_RES);
        atAuthService.addURI("http://gcs.epok.net/xri/resolve?ns=at");
        oDesc.addService(atAuthService);

        GCSAuthority oAuth = new GCSAuthority("@");
        oCache.stuff(oAuth, oDesc);
        assertTrue("Initial cache incorrect", oCache.getNumNodes() == 1);
View Full Code Here

Examples of org.openxri.xml.XRD

        */ /**
        *
        */
        public void run()
        {
            XRD oDummy = new XRD();
            Service dummyService = new Service();
            dummyService.addMediaType(Tags.CONTENT_TYPE_XRDS + ";trust=none");
            dummyService.addType(Tags.SERVICE_AUTH_RES);
            dummyService.addURI("http://www.example.com/xri/resolve?id=1");
            oDummy.addService(dummyService);

            String[] oCases =
                { "@!a1!b2!c3!d4", "@!x1!y2!z3", "@!a1!b2!c3", "@!a1!b2", "@!a1!b2!m3", "@!a1!o2!p3", "@!a1!o2!q3", "@!a1!b2!c3!d4!e5", "@!x1!y2" };

            Cache oCache = new Cache(1000);
View Full Code Here

Examples of org.openxri.xml.XRD

     
      qxri = "@xrid*test*live.unit.tests*0001-simple";
      xri = XRI.fromIRINormalForm(qxri);
      xrds = resolver.resolveAuthToXRDS(xri, flags, new ResolverState());
      assertTrue("Expected 4 XRDs", xrds.getNumChildren() == 4);
      XRD xrd3 = xrds.getDescriptorAt(3);
      assertTrue("subseg[3] should be *0001-simple", xrd3.getQuery().equals("*0001-simple"));
      assertTrue("subseg[3] should be CID verified", xrd3.getStatus().getCID().equals(Status.CID_VERIFIED));
      assertTrue("subseg[3] should be CEID verified", xrd3.getStatus().getCEID().equals(Status.CID_VERIFIED));
    }
    catch (Exception e) {
      fail("Not expecting an exception here: " + e);
      e.printStackTrace();
    }
View Full Code Here

Examples of org.openxri.xml.XRD

    log.debug("XRI: " + xri);

    String resolveXri = (xri.startsWith("=") || xri.startsWith("@")) ? xri : "=" + xri;
    resolveXri = resolveXri.replace("-", "*");
    XRD xrd = null;

    // resolve the XRI

    log.debug("Resolving " + resolveXri);

    try {

      xrd = resolver.resolveSEPToXRD(new XRI(resolveXri), serviceString, null, resolverFlags, new ResolverState());
    } catch (PartialResolutionException ex) {

      log.error("Problem while resolving " + resolveXri + ": " + ex.getMessage(), ex);
      sendResponse(response, HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    if (xrd == null || (! Status.SUCCESS.equals(xrd.getStatusCode()))) {

      log.error("No XRD or bad status code for " + resolveXri + ": " + (xrd != null ? xrd.getStatusCode() : null));
      sendResponse(response, HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    // construct the JSON

    StringBuffer buffer = new StringBuffer();
    buffer.append("{\n");
    buffer.append("  \"locations\": [ ");

    String canonical;

    if (xrd.getCanonicalID() != null) {

      canonical = xrd.getCanonicalID().getValue();
    } else {

      canonical = resolveXri;
    }

    List<String> jsonLocations = new ArrayList<String>();

    for (int i=0; i<xrd.getSelectedServices().getList().size(); i++) {

      Service service = (Service) xrd.getSelectedServices().getList().get(i);

      if (service == null) continue;

      for (int ii=0; ii<service.getNumURIs(); ii++) {

View Full Code Here

Examples of org.openxri.xml.XRD

    }
  }

 
  public static XRD createAuthRoot(String uri) {
    XRD xrd = new XRD();

    // construct an authority resolution service
    Service srv = new Service();
    TrustType tt = new TrustType(); // default trust type
    String authMediaType = Tags.CONTENT_TYPE_XRDS + ";"
        + tt.getParameterPair();
    srv.addMediaType(authMediaType, null, Boolean.FALSE);
    srv.addType(Tags.SERVICE_AUTH_RES);
    srv.addURI(uri);

    // add it to the XRD
    xrd.addService(srv);

    return xrd;
  }
View Full Code Here

Examples of org.openxri.xml.XRD

  {
    // instantiate a Resolver object
    Resolver resolver = new Resolver();

    // configure roots
    XRD eqRoot = createAuthRoot("http://equal.xri.net/");
    eqRoot.setCanonicalID(new CanonicalID("="));
    Status eqRootStatus = new Status(Status.SUCCESS);
    eqRootStatus.setCID(Status.CID_VERIFIED);
    eqRoot.setStatus(eqRootStatus);
    resolver.setAuthority("=", eqRoot);

    XRD atRoot = createAuthRoot("http://at.xri.net/");
    atRoot.setCanonicalID(new CanonicalID("@"));
    Status atRootStatus = new Status(Status.SUCCESS);
    atRootStatus.setCID(Status.CID_VERIFIED);
    atRoot.setStatus(atRootStatus);
    resolver.setAuthority("@", atRoot);

    return resolver;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.