Examples of PartialResolutionException


Examples of org.openxri.resolve.exception.PartialResolutionException

        throw new RuntimeException("Unknown authority type");
      xrdsOut.addAll(newXRDS);
      return xrdsOut;
    } catch (PartialResolutionException e) {
      xrdsOut.addAll(e.getPartialXRDS());
      throw new PartialResolutionException(xrdsOut);
    }
  }
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

        xriAuth.toURINormalForm(),
        Status.UNKNOWN_ROOT,
        "Authority '" + rootAuth + "' is not configured"
      );
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    XRISegment segment = xriAuth.getXRISegment();

    // resolve segment (list of subsegments not including root) against root XRD
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

    if (flags.isSaml()) {
      XRD err = createErrorXRD(iriAuth.toURINormalForm(),
          Status.NOT_IMPLEMENTED,
          "SAML is not supported for an IRI authority");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    // only use http for insecure and https for secure
    String scheme = flags.isHttps() ? "https" : "http";

    URI uri = null;
    try {
      uri = new URI(scheme, iriAuth.getIUserInfo(), iriAuth.getIHost(),
          iriAuth.getPort(), null, null, null);
    } catch (java.net.URISyntaxException e) {
      XRD err = createErrorXRD(iriAuth.toURINormalForm(),
          Status.INVALID_INPUT,
          "Unable to construct URI to resolve IRI authority: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    // now that we've constructed the new URI, try to return the stream from it
    InputStream in = null;
    try {
      in = getDataFromURI(uri, uri.toString(), flags, state);
    } catch (Exception e) {
      XRD err = createErrorXRD(iriAuth.toURINormalForm(),
          Status.NETWORK_ERROR,
          "Network error occurred while resolving IRI authority: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    if (in == null) {
      throw new RuntimeException(
          "resolveIRIAuth - getDataFromURI returned null");
    }

    // read the descriptors
    try {
      xrdsOut = readXRDS(in);
      if (xrdsOut.getNumChildren() != 1) {
        XRD err = createErrorXRD(iriAuth.toURINormalForm(),
            Status.UNEXPECTED_RESPONSE,
            "Expected 1 XRD from IRI authority, got "
                + xrdsOut.getNumChildren() + " instead");
        xrdsOut.add(err);
        throw new PartialResolutionException(xrdsOut);
      }
    } catch (XRIResolutionException e) {
      XRD err = createErrorXRD(iriAuth.toURINormalForm(),
          Status.UNEXPECTED_RESPONSE,
          "Error reading XRDS from server: " + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    // add the descriptor, but only if is is valid
    XRD xrd = xrdsOut.getDescriptorAt(0);
    if (!xrd.isValid()) {
      XRD err = createErrorXRD(iriAuth.toURINormalForm(),
          Status.UNEXPECTED_XRD, "XRD is invalid");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    return xrdsOut;
  }
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

    } catch (java.net.URISyntaxException oEx) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.INVALID_INPUT,
          "Unable to construct URI to access proxy resolution service");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    } catch (UnsupportedEncodingException e) {
      // thrown from URLEncoder.encode() - this should never happen since the
      // US-ASCII encoding should be supported on every computer or so we hope :)
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.INVALID_INPUT, "Charset not supported");
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.PERM_FAIL,
          "Unexpected error while constructing proxy URI: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    InputStream in = null;
    try {
      // try to get the data from it
      in = getDataFromURI(newURI, qxri.toURINormalForm(), flags, state);
      XRDS xrds = readXRDS(in);
      XRD finalXRD = xrds.getFinalXRD();

      String code = finalXRD.getStatusCode();
      if ((flags.isRefs() && !code.equals(Status.SUCCESS) && !code
          .equals(Status.REF_NOT_FOLLOWED))
          || !code.equals(Status.SUCCESS)) {
        // got either a non-SUCCESS code or
        // followRefs is on but we got non-SUCCESS and non-REF_NOT_FOLLOWED
        throw new PartialResolutionException(xrds);
      }
      return xrds;
    } catch (PartialResolutionException e) {
      // re-throw
      throw e;
    } catch (Exception e) {
      XRD err = createErrorXRD(qxri.getAuthorityPath().toURINormalForm(),
          Status.PERM_FAIL, "Error fetching XRDS from proxy: "
              + e.getMessage());
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }
  }
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

        // fall through to continue to the next
      }
    }
   
    log.info("processRedirects - exhausted list of Redirects. Throwing PRE");
    throw new PartialResolutionException(xrdsOut);
  }
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

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

Examples of org.openxri.resolve.exception.PartialResolutionException

    if (xrdsOut == null) { // no appropriate URI found
      xrdsOut = new XRDS();
      String code = flags.isHttps()? Status.TRUSTED_RES_ERROR : Status.AUTH_RES_ERROR;
      xrdsOut.add(createErrorXRD(query, code, "No URI found for authority resolution"));
    }
    throw new PartialResolutionException(xrdsOut);
  }
View Full Code Here

Examples of org.openxri.resolve.exception.PartialResolutionException

        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

Examples of org.openxri.resolve.exception.PartialResolutionException

  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

Examples of org.openxri.resolve.exception.PartialResolutionException

      }
      catch (PartialResolutionException e) {
        log.trace("got PRE: " + e.getPartialXRDS());
        log.trace("xrdsOut.n = " + xrdsOut.getNumChildren() + ", partialXRDS.n=" + e.getPartialXRDS().getNumChildren());
        xrdsOut.add(e.getPartialXRDS());
        throw new PartialResolutionException(xrdsOut);       
      }
     
      //// add the subsegments
      xrdsOut.addAll(tmpXRDS);
     
      //// replace parent XRD
      parent = tmpXRDS.getFinalXRD();
     
      for (int k = 0; k < tmpXRDS.getNumChildren(); k++) {
        XRISubSegment subseg = remainingSegment.getSubSegmentAt(k);
        parentXRI = parentXRI + subseg;
      }
     
      remainingSegment = remainingSegment.getRemainder(tmpXRDS.getNumChildren());

      tmpXRDS = null;     
      try {
        if (parent.getNumRedirects() > 0) {
          log.debug("resolveAuthSegment - processing Redirect(s)");
          tmpXRDS = processRedirects(qxri, parent, currentFlags, state);
          xrdsOut.addAll(tmpXRDS);
          // replace parent
          parent = tmpXRDS.getFinalXRD();
        }
        else if (parent.getNumRefs() > 0) {
          if (!currentFlags.isRefs()) {
            throw makeResolutionException(
              xrdsOut,
              query,
              Status.REF_NOT_FOLLOWED,
              "Ref not followed");
          }
          log.debug("resolveAuthSegment - processing Ref(s)");
          tmpXRDS = processRefs(parent, currentFlags, state);
          xrdsOut.addAll(tmpXRDS);
          // replace parent
          parent = tmpXRDS.getFinalXRD();
        }       
      }
      catch (PartialResolutionException e) {
        xrdsOut.addAll(e.getPartialXRDS());
        log.debug("resolveAuthSegment - got PRE while processing Ref or Redirect");
        throw new PartialResolutionException(xrdsOut);
      }
    }
   
    log.debug("resolveAuthSegment - successfully resolved all subsegments");
    if (parent.getStatus().getCID().equals(Status.CID_VERIFIED)
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.