Package org.openxri.xml

Examples of org.openxri.xml.Status


  public static XRD makeNotFoundXrd(String subSegmentName) {

    XRD xrd = new XRD();

    xrd.setQuery(subSegmentName);
    xrd.setStatus(new Status(Status.QUERY_NOT_FOUND, "No descriptor found for this query."));
    xrd.setServerStatus(new ServerStatus(Status.QUERY_NOT_FOUND, "No descriptor found for this query."));

    return(xrd);
  }
View Full Code Here


    String text = ex.getMessage();
    if (text == null || text.trim().equals("")) text = "An internal error occurred: " + ex.getClass().getName();

    xrd.setQuery(subSegmentName);
    xrd.setStatus(new Status(Status.TEMPORARY_FAIL, text));
    xrd.setServerStatus(new ServerStatus(Status.TEMPORARY_FAIL, text));

    return(xrd);
  }
View Full Code Here

    if (this.code == null || this.text == null) throw new StageException("Not initialized.");

    // add a <Status> tag to the XRD

    xrd.setStatus(new Status(this.code, this.text));

    // done

    return(xrd);
  }
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

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

          TrustType tt = new TrustType();
          tt.setParameterPair(false, true);
    XRD myRoot = createAuthRoot("http://localhost:8080/server/resolve/ns/@blog*lockbox/", tt);
    log.debug("TrustedResolver() root hint  = " + myRoot.serializeDOM(false, true));
          myRoot.setCanonicalID(new CanonicalID("@!E459.819D.771.7990!5B62.6F13.7602.5176"));
    Status myRootStatus = new Status(Status.SUCCESS);
    myRootStatus.setCID(Status.CID_VERIFIED);
    myRoot.setStatus(myRootStatus);
    resolver.setAuthority("(@blog*lockbox)", myRoot); // note () form, whereas URL /ns/... does not
          return resolver;
  }
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

  void parseFetchedXRD(XRDS xrdsOut, XRD xrd, XRD prevXRD, XRISubSegment query, Service prevService, ResolverFlags flags) throws PartialResolutionException
  {
    // 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) {
      xrd.setStatus(new Status(Status.INVALID_XRDS, "Missing ServerStatus or Status element in XRD"));
      throw new PartialResolutionException(xrdsOut);
    }


    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 prevStatus = prevXRD.getStatus();
      Status s = xrd.getStatus();

      String prevCIDStat = prevStatus.getCID();
      if (prevCIDStat.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())
    {
      XRD xrdCopy = (XRD)xrd.clone();
      xrdCopy.clearDOM();

      // Each descriptor must be validated independently as well as
      // against the one that preceded (described) it in the
      // descriptor chain.

      boolean valid = isTrustedDescriptor(query, xrdCopy, prevService);

      // bail if the descriptor is not valid
      if (!valid) {
        xrd.setStatus(new Status(Status.UNVERIFIED_SIGNATURE, "Signature verification failed."));
        throw new PartialResolutionException(xrdsOut);
      }

    }
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

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.