Package org.openxri.xml

Examples of org.openxri.xml.Status


      // System.out.println(xrds);

      assertTrue("Expected 5 XRDs", xrds.getNumChildren() == 5);
      assertTrue("subseg[3] should be *0003-badcid", xrds.getDescriptorAt(3).getQuery().equals("*0003-badcid"));
     
      Status s3 = xrds.getDescriptorAt(3).getStatus();
      assertTrue("subseg[3].status.cid should be 'failed'", s3.getCID().equals("failed"));
     
      Status s4 = xrds.getDescriptorAt(4).getStatus();
      assertTrue("subseg[4].status.cid should be 'failed'", s4.getCID().equals("failed"));

     
     
      qxri = "@xrid*test*live.unit.tests*0001-simple";
      xri = XRI.fromIRINormalForm(qxri);
View Full Code Here


    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

            // 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());

        } // getDataFromURI()
View Full Code Here

    try {
      XRI ceidX = XRI.fromURINormalForm(ceid.getValue());

      log.info("verifyCEID - resolving CEID");
      XRD ceidXRD = resolveAuthToXRD(ceidX, flags, state);
      Status s = ceidXRD.getStatus();
      if (!s.getCID().equals(Status.CID_VERIFIED)) {
        log.debug("verifyCEID - XRD for CEID is not CID verified");
        return Status.CID_FAILED;
      }
     
      CanonicalID cid2 = ceidXRD.getCanonicalID();
View Full Code Here

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

      // status is not success
      ServerStatus sstat = xrd.getServerStatus();
      Status stat;
      if (sstat == null) {
        // compatibility: if no ServerStatus, look for Status
        stat = xrd.getStatus();
        if (stat != null) {
          xrd.setServerStatus(new ServerStatus(stat.getCode(), stat.getText()));
        }
      }
      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 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);
      }

      if (flags.isCid()) {
        Status parentStatus = parent.getStatus();
        Status s = xrd.getStatus();
       
        String parentCIDStat = parentStatus.getCID();
        if (parentCIDStat.equals(Status.CID_FAILED)) {
          s.setCID(Status.CID_FAILED);
        }
        else {
          s.setCID(verifyCID(prevXRD, xrd));
        }
      }
     
      // if we need to do trusted resolution checking
      if (flags.isSaml())
View Full Code Here

      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

    // find services
    List selectedSvcs = selectServices(xrd.getServices(), sepType, path, sepMediaType, flags);
    xrd.setSelectedServices(selectedSvcs);
    if (selectedSvcs.size() == 0) {
      Status s = xrd.getStatus();
      s.setCode(Status.SEP_NOT_FOUND);
      s.setText("Requested service endpoint not found");
      throw new PartialResolutionException(xrdsOut);
    }

    // check if first Service has Redirect of Ref
    Service srv = (Service)selectedSvcs.get(0);
View Full Code Here

      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);
View Full Code Here

  }

  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

    response.setStatus(HttpServletResponse.SC_OK);
    XRD xrd = partialXRDS.getFinalXRD();
    String errMsg = "";
    if (xrd != null) {
      Status stat = xrd.getStatus();
      errMsg = "Error code: " + stat.getCode() + " - " + stat.getText();
    }

    if (resMediaType == null) {
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, errMsg, null);
    }
View Full Code Here

TOP

Related Classes of org.openxri.xml.Status

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.