Package org.openxri.xml

Examples of org.openxri.xml.XRD


 
  protected void checkMaxRequests(XRDS xrdsOut, String query, ResolverState state)
    throws PartialResolutionException
  {
    if (maxRequests >= 0 && state.getNumRequests() >= maxRequests) {
      XRD finalXRD = xrdsOut.getFinalXRD();
      if (finalXRD == null) {
        finalXRD = createErrorXRD(query, Status.LIMIT_EXCEEDED, "Maximum of authority resolution requests exceeded");
        xrdsOut.add(finalXRD);
      } else {
        finalXRD.setStatus(new Status(Status.LIMIT_EXCEEDED,
            "Maximum of authority resolution requests exceeded"));
      }
      throw new PartialResolutionException(xrdsOut);
    }
   
View Full Code Here


 

  private PartialResolutionException
  makeResolutionException(XRDS targetXRDS, String query, String status, String message)
  {
    XRD x = createErrorXRD(query, status, message);
    targetXRDS.add(x);
    return new PartialResolutionException(targetXRDS);
  }
View Full Code Here

          String constructedURI = constructURI(uri, r.getAppend(), qxri);
          uri = new URI(constructedURI);
        }
      } catch (URISyntaxException e) {
        XRDS tmpXRDS = new XRDS();
        XRD err = createErrorXRD(r.getValue(), Status.INVALID_REDIRECT, "Invalid Redirect URI");
        tmpXRDS.add(err);
        xrdsOut.add(tmpXRDS);
        continue;
      }
     
      try {
        XRDS tmpXRDS = fetchRedirectXRDS(uri, parent, qxri, flags, state);
        xrdsOut.add(tmpXRDS);
       
        XRD finalXRD = tmpXRDS.getFinalXRD();
        tmpXRDS = new XRDS();
        List services = selectServiceFromXRD(tmpXRDS, finalXRD, qxri, sepType, sepMediaType, flags, state);
        xrdsOut.addAll(tmpXRDS);
        return services; // we're done!
      } catch (XRIResolutionException e) {
        XRDS tmpXRDS = new XRDS();
        XRD err = createErrorXRD(uri.toString(), Status.REDIRECT_ERROR, "Error fetching XRDS: " + e.getMessage());
        tmpXRDS.add(err);
        xrdsOut.add(tmpXRDS);
       
        // fall through to continue to the next
      }
View Full Code Here

      }
     
      if (!tmpXRDS.isXRDAt(0))
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Authority XRDS document should not contain XRDS element");

      XRD xrd = tmpXRDS.getDescriptorAt(0);
      xrdsOut.add(xrd);


      ServerStatus sstat = xrd.getServerStatus();
      Status stat;
      if (sstat == null) {
        // compatibility: if no ServerStatus, look for Status
        stat = xrd.getStatus();
      }
      else {
        stat = new Status(sstat.getCode(), sstat.getText());
        xrd.setStatus(stat);
      }
     
      if (stat == null)
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Missing ServerStatus or Status element in Redirect XRD");

      if (!stat.getCode().equals(Status.SUCCESS)) {
        throw new PartialResolutionException(xrdsOut);
      }

      // check the basic properties of the descriptor
      if (!xrd.isValid()) {       
        xrd.setStatus(new Status(Status.UNEXPECTED_RESPONSE, "XRD is not valid (stale?)"));
        throw new PartialResolutionException(xrdsOut);
      }
     
      String err = verifyRedirectXRD(xrd, parent);
      if (err != null) {
        xrd.setStatus(new Status(Status.REDIRECT_VERIFY_FAILED, err));
        throw new PartialResolutionException(xrdsOut);
      }
     
      // copy parent Status cid attribute if present
      stat.setCID(xrd.getCanonicalID() == null? Status.CID_ABSENT : parent.getStatus().getCID());
     
      // copy parent Status ceid attribute (without checking if present since it is supposed to be "off" for
      // non-final XRD, and we don't know whether this is a final XRD.)
      stat.setCEID(parent.getStatus().getCEID());
     
      try {
        if (xrd.getNumRedirects() > 0) {
          log.info("fetchRedirectXRDS - XRD at URI(" + uri + ") contains Redirect(s), following..");
          tmpXRDS = processRedirects(qxri, xrd, flags, state);
          xrdsOut.addAll(tmpXRDS);
        }
        else if (xrd.getNumRefs() > 0) {
          if (!flags.isRefs()) {
            throw makeResolutionException(
              xrdsOut,
              query,
              Status.REF_NOT_FOLLOWED,
View Full Code Here

        "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

    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

  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

    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

        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

        */ /**
        *
        */
        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

TOP

Related Classes of org.openxri.xml.XRD

Copyright © 2018 www.massapicom. 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.