Examples of XRDS


Examples of org.openxri.xml.XRDS

 
 
  protected XRDS fetchRedirectXRDS(URI uri, XRD parent, XRI qxri, ResolverFlags flags, ResolverState state)
    throws PartialResolutionException
  {
      XRDS xrdsOut = new XRDS();
      String query = qxri.toURINormalForm();
      xrdsOut.setRedirect(uri.toString());
     
      XRDS tmpXRDS = null;
      try {
        log.info("fetchRedirectXRDS - fetching from URI(" + uri + ")");
        InputStream in = getDataFromURI(uri, query, flags, state);
       
        log.info("fetchRedirectXRDS - reading content from URI(" + uri + ")");
        tmpXRDS = readXRDS(in);

        log.debug("fetchRedirectXRDS - got XRDS = " + tmpXRDS.toString());
      } catch (IOException e) {
        log.error("fetchRedirectXRDS - got IOException from URI " + uri);
        throw makeResolutionException(xrdsOut, query, Status.NETWORK_ERROR, "Networking error encountered");
      } catch (Exception e) {
        log.error("fetchRedirectXRDS - unexpected error: " + e);
        e.printStackTrace();
        throw makeResolutionException(xrdsOut, query, Status.AUTH_RES_ERROR, e.getMessage());
      }

      //// sanity checks
     
      // there should be exactly one child element
      if (tmpXRDS.getNumChildren() != 1 || !tmpXRDS.isXRDAt(0)) {
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Invalid XRDS document: single XRD element expected");
      }
     
      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;
View Full Code Here

Examples of org.openxri.xml.XRDS

      return xrdsOut;
  }
 

  protected XRDS readXRDS(InputStream in) throws XRIResolutionException {
    XRDS xrds = null;

    if (in == null) {
      return xrds;
    }

    // Read response into DOM structure
    try {
      log.debug("readXRDS - parsing input stream");
      DOMParser domParser = DOMUtils.getDOMParser();
      domParser.parse(new InputSource(in));
      Document doc = domParser.getDocument();
      Element element = doc.getDocumentElement();
      log.debug("readXRDS - successfully read XML document into DOM");
      xrds = new XRDS(element, true);
      log.debug("readXRDS - successfully parsed XRDS document");
    } catch (IOException e) {
      throw new XRIResolutionException("I/O error while reading XRDS document: " + e, e);
    } catch (SAXException e) {
      throw new XRIResolutionException("Invalid XRDS document: " + e, e);
View Full Code Here

Examples of org.openxri.xml.XRDS

      ResolverState state) throws PartialResolutionException {
    log.trace("resolveAuthToXRDS(s'" + qxri + "', flags: " + flags + ")");
    if (proxyURI != null)
      return resolveViaProxy(qxri, null, null, false, flags, state);

    XRDS xrds = resolveAuthority(qxri, flags, state);
    if (flags.isUric()) {
      constructURIinXRD(xrds.getFinalXRD(), qxri);
    }
    return xrds;
  }
View Full Code Here

Examples of org.openxri.xml.XRDS

  public XRD resolveAuthToXRD(XRI qxri, ResolverFlags flags,
      ResolverState state) throws PartialResolutionException {
    log.trace("resolveAuthToXRD(s'" + qxri + "', flags: " + flags + ")");

    if (proxyURI != null) {
      XRDS xrds = resolveViaProxy(qxri, null, null, false, flags, state);
      return xrds.getFinalXRD();
    }

    XRDS xrds = resolveAuthority(qxri, flags, state);
    XRD finalXRD = xrds.getFinalXRD();
    if (flags.isUric()) {
      constructURIinXRD(finalXRD, qxri);
    }
    return finalXRD;
  }
View Full Code Here

Examples of org.openxri.xml.XRDS

        + ", sepMediaType=" + sepMediaType + ", flags:" + flags + ")");

    if (proxyURI != null)
      return resolveViaProxy(qxri, sepType, sepMediaType, true, flags, state);

    XRDS xrds = resolveAuthority(qxri, flags, state);
    XRD finalXRD = xrds.getFinalXRD();

    selectServiceFromXRD(xrds, finalXRD, qxri, sepType, sepMediaType, flags, state);
    if (flags.isUric()) {
      constructURIinXRD(xrds.getFinalXRD(), qxri);     
    }
    return xrds;
  }
View Full Code Here

Examples of org.openxri.xml.XRDS

      ResolverFlags flags, ResolverState state)
      throws PartialResolutionException {
    log.trace("resolveSEPToXRD('" + qxri + "', sepType=" + sepType
        + ", sepMediaType=" + sepMediaType + ", flags: " + flags + ")");

    XRDS xrds = resolveSEPToXRDS(qxri, sepType, sepMediaType, flags, state);
    return xrds.getFinalXRD();
  }
View Full Code Here

Examples of org.openxri.xml.XRDS

      throws PartialResolutionException {
    log.trace("resolveSEPToXRD('" + qxri + "', trustType=" + trustType
        + ", sepType=" + sepType + ", sepMediaType=" + sepMediaType
        + ", followRefs=" + followRefs + ")");

    XRDS xrds = resolveSEPToXRDS(qxri, trustType, sepType, sepMediaType,
        followRefs, state);
    return xrds.getFinalXRD();
  }
View Full Code Here

Examples of org.openxri.xml.XRDS

  public XRDS resolveAuthority(XRI qxri, ResolverFlags flags, ResolverState state)
    throws PartialResolutionException
  {
    log.trace("resolveAuthority(s'" + qxri + "', flags: " + flags + ")");

    XRDS xrdsOut = new XRDS();
    xrdsOut.setRef("xri://" + qxri.getAuthorityPath().toString());

    // determine the authority type
    AuthorityPath ap = qxri.getAuthorityPath();
    try {
      XRDS newXRDS;
      if (ap instanceof XRIAuthority)
        newXRDS = resolveXRIAuth(qxri, (XRIAuthority)ap, flags, state);
      else if (ap instanceof IRIAuthority)
        newXRDS = resolveIRIAuth((IRIAuthority) ap, flags, state);
      else
View Full Code Here

Examples of org.openxri.xml.XRDS

      throw new RuntimeException("First subsegment of '" + xriAuth + "' is null");
    }

    XRD rootXRD = getAuthority(rootAuth);
    if (rootXRD == null) {
      XRDS xrdsOut = new XRDS();
      // unknown root
      XRD err = createErrorXRD(
        xriAuth.toURINormalForm(),
        Status.UNKNOWN_ROOT,
        "Authority '" + rootAuth + "' is not configured"
      );
      xrdsOut.add(err);
      throw new PartialResolutionException(xrdsOut);
    }

    XRISegment segment = xriAuth.getXRISegment();
View Full Code Here

Examples of org.openxri.xml.XRDS

  protected XRDS resolveIRIAuth(IRIAuthority iriAuth, ResolverFlags flags, ResolverState state)
    throws PartialResolutionException
  {
    log.trace("resolveIRIAuth('" + iriAuth + "', flags: " + flags + ")");

    XRDS xrdsOut = new XRDS();

    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
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.