Examples of XRD


Examples of org.openxri.xml.XRD

        // stuff the root URI for @, =, and +.  This makes them all the same!
        // e.g. =jmj ends up being the same as @jmj.  For testing only.
        //
        try
        {
          XRD eqXRD = new XRD();
          eqXRD.addService(getRootAuthority());
         
          XRD atXRD = new XRD();
          atXRD.addService(getRootAuthority());
          oResolver.setAuthority("=", eqXRD);
          oResolver.setAuthority("@", atXRD);
        }
        catch (Exception oEx)
        {
View Full Code Here

Examples of org.openxri.xml.XRD

    // do nothing
  }

  private XRD makeSampleXRD() {

    XRD xrd = new XRD();
    Service defaultService;

    try {

      defaultService = new DefaultService(new URI("http://www.openxri.org"));
      xrd.addService(defaultService);
    } catch (URISyntaxException ex) {

      ex.printStackTrace();
    }
View Full Code Here

Examples of org.openxri.xml.XRD

    try {

      if (store instanceof StoreResettable) ((StoreResettable) store).resetStore();

      SubSegment rootSubSegment1 = store.createRootSubSegment("=example", new XRD());
      Authority rootAuthority1 = store.getSubSegmentAuthority(rootSubSegment1);
      SubSegment subSegment1 = store.registerSubsegment(rootAuthority1, "*name1", makeSampleXRD());
      SubSegment subSegment2 = store.registerSubsegment(rootAuthority1, "*name2", makeSampleXRD());

      SubSegment rootSubSegment2 = store.createRootSubSegment("@example", new XRD());
      Authority rootAuthority2 = store.getSubSegmentAuthority(rootSubSegment2);
      SubSegment subSegment3 = store.registerSubsegment(rootAuthority2, "*name3", makeSampleXRD());
      Authority authority3 = store.getSubSegmentAuthority(subSegment3);
      SubSegment subSegment4 = store.registerSubsegment(authority3, "*name4", makeSampleXRD());

View Full Code Here

Examples of org.openxri.xml.XRD

      try {

        // create a new XRD

        XRD xrd = new XRD();

        // give subclasses a chance to init the XRD

        ret = this.initXRD(
            xrd,
            parent,
            subSegmentName,
            bSigned);

        // if a subclass returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Subclass handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // give authority handlers a chance to init it, if there are any for the current parent authority

        List authorityHandlers = new ArrayList();

        if (moAuthorityHandlers.get(parent.getAuthorityId()) != null)
          authorityHandlers.addAll((List) moAuthorityHandlers.get(parent.getAuthorityId()));

        for (Iterator ii = authorityHandlers.iterator(); ii.hasNext(); ) {

          if (ret == true) break;

          AuthorityHandler authorityHandler = (AuthorityHandler) ii.next();

          ret = authorityHandler.initXRD(
              xrd,
              parent,
              subSegmentName,
              bSigned);
        }

        // if an authority handler returned true, it doesnt want us to do any more work

        if (ret == true) {

          soLog.debug("Authority Handler handled XRD completely. Returning it without any more work.");
          xrds.add(xrd);
          break;
        }

        // using the parent authority and subsegment name, find the authority we are describing now

        SubSegment subSegment;
       
        try {

          subSegment = moStore.findSubSegment(parent, subSegmentName);
          if (subSegment == null) throw new StoreNotFoundException("Null value returned.");
        } catch (StoreNotFoundException ex) {

          ServerNotFoundException ex2 = new ServerNotFoundException("Cannot find subsegment: " + subSegmentName, ex);
          soLog.warn(ex2);
          throw ex2;
        }

        Authority authority = moStore.getSubSegmentAuthority(subSegment);

        // look up Refs and Services from the store, as well as LocalIDs if the store supports it

        Ref[] refs = moStore.getAuthorityRefs(authority);
        Service[] services = moStore.getAuthorityServices(authority);
        LocalID[] localIds;

        if (moStore instanceof StoreBetterLookup) {

          localIds = ((StoreBetterLookup) moStore).getSubSegmentLocalIds(subSegment);
        } else {

          localIds = new LocalID[0];
        }

        // fill it with information we got from the store

        for (int ii=0; ii<refs.length; ii++) xrd.addRef(refs[ii]);
        for (int ii=0; ii<services.length; ii++) xrd.addService(services[ii]);
        for (int ii=0; ii<localIds.length; ii++) xrd.addLocalID(localIds[ii]);

        // do we want a local authority resolution service for this authority?
        // this piece of information comes from the store, but we actually create
        // the service, since this requires knowledge of the server configuration

        if (authority.getLocalAuthService().equals(Boolean.TRUE)) {

          URI[] uris;

          try {

            uris = new URI[2];
            uris[0] = fillURI(authority.getAuthorityId(), "http");
            uris[1] = fillURI(authority.getAuthorityId(), "https");
          } catch(URISyntaxException ex) {

            throw new ServerInternalException("Invalid URI for authority resolution service.", ex);
          }

          xrd.addService(new AuthorityResolutionService(uris, authority.getAuthorityId()));
        }

        // let our subclasses finish the XRD before we append it to the XRDS

        this.finishXRD(
View Full Code Here

Examples of org.openxri.xml.XRD

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(new InputSource(new StringReader(this.xrdString)));

        XRD xrd = new XRD();
        xrd.fromDOM(document.getDocumentElement());

        ((StoreEditable) openXRIStore).setXrd(AuthorityDetails.this.authority, xrd);
      } catch (StoreException ex) {

        AuthorityDetails.log.error(ex);
View Full Code Here

Examples of org.openxri.xml.XRD

      if (request.getHeader("User-Agent") == null) {
       
        String server;
        String identifier = request.getRequestURI().substring(request.getContextPath().length() + 1);
         
        XRD xrd = resolver.resolveSEPToXRD(
            sPath,
            new TrustType(TrustType.TRUST_NONE),
            AuthenticationService.SERVICE_TYPE1,
            null,
            true);

        if (xrd == null || xrd.getSelectedServices().getList().size() == 0) {

          sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no authentication url found", null);
          return;
        }

        server = ((Service) xrd.getSelectedServices().getList().get(0)).getURIAt(0).getUriString();

        log.debug("OpenID hack triggered: Server=" + server + ", Identifier=" + identifier);
       
        this.outputOpenIDServerHack(response, server);
        return;
View Full Code Here

Examples of org.openxri.xml.XRD

      }
    }

    // set the request preferences on the resolver before querying.
    XRDS xrds = null;
    XRD xrd = null;
    try
    {
      if (sep) {
        if (resMediaType == null) {
          // see section 7.6 for special redirect rule
          ArrayList uris = resolver.resolveSEPToURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          if (uris == null || uris.size() == 0) {
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
            return;
          }
          String s = (String) uris.get(0);

          log.trace("Sending redirect to '" + s + "'");

          response.sendRedirect(s);
        }
        else if (resMediaType.isType(MimeType.URI_LIST)) {
          String  text = resolver.resolveSEPToTextURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          if (text.length() <= 0)
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
          else
            sendResponse(response, resMediaType.getType(), text, null);
        }
        else if (resMediaType.isType(MimeType.XRDS_XML)) {
          xrds = resolver.resolveSEPToXRDS(oXRI, trustType, serviceType, serviceMediaType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrds.toString(), trustType);
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
          xrd = resolver.resolveSEPToXRD(oXRI, trustType, serviceType, serviceMediaType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrd.toResultString(), trustType);
        }
        else {
          // else - we should have taken care of it in checkSupportedMediaTypes
          log.error("processProxyRequest - should not reach here (sep=true)");
        }
      }
      else {
        //// authority resolution only
        if(resMediaType == null) {
          resMediaType = new MimeType(MimeType.XRDS_XML);
        }

        if (resMediaType.isType(MimeType.XRDS_XML)) {
          xrds = resolver.resolveAuthToXRDS(oXRI, trustType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrds.toString(), trustType);
          return;
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
          xrd = resolver.resolveAuthToXRD(oXRI, trustType, refs);
          sendResponse(response, isDumbBrowser, resMediaType.getType(), xrd.toString(), trustType);
        }
        else if (resMediaType.isType(MimeType.URI_LIST)) {
          // ignore (must do SEP when text/uri-list is specified)
          log.warn("text/uri-list given but does not want to do service selection");
          // TODO: do we return an error?
View Full Code Here

Examples of org.openxri.xml.XRD

  throws IOException
  {
    log.trace("sendPartialResponse(dumbBrowser=" + isDumbBrowser + ", partialXRDS=" + partialXRDS.toString());

    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);
    }
    else if (resMediaType.isType(MimeType.URI_LIST)) {
      errMsg = "# " + errMsg;
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, errMsg, trustType);
    }
    else if (resMediaType.isType(MimeType.XRDS_XML)) {
      sendResponse(response, isDumbBrowser, resMediaType.getType(), partialXRDS.toString(), trustType);
    }
    else if (resMediaType.isType(MimeType.XRD_XML)) {
      sendResponse(response, isDumbBrowser, resMediaType.getType(), xrd.toString(), trustType);
    }
    else {
      // else - we should have taken care of it in checkSupportedMediaTypes
      log.error("processProxyRequest - should not reach here (exception)");
    }
View Full Code Here

Examples of org.openxri.xml.XRD

    flags.setNoDefaultP(nodefault_p);
    flags.setNoDefaultT(nodefault_t);
   
    // set the request preferences on the resolver before querying.
    XRDS xrds = null;
    XRD xrd = null;
    try
    {
      if (sep) {
        if (resMediaType == null) {
          // see section 7.6 for special redirect rule
//          ArrayList<?> uris = this.resolver.resolveSEPToURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          ArrayList<?> uris = this.resolver.resolveSEPToURIList(oXRI, serviceType, serviceMediaType, flags, state);
          if (uris == null || uris.size() == 0) {
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
            return;
          }
          String s = (String) uris.get(0);

          log.trace("Sending redirect to '" + s + "'");

          response.sendRedirect(s);
        }
        else if (resMediaType.isType(MimeType.URI_LIST)) {
//          String  text = this.resolver.resolveSEPToTextURIList(oXRI.toString(), trustType, serviceType, serviceMediaType, refs);
          String text = this.resolver.resolveSEPToTextURIList(oXRI, serviceType, serviceMediaType, flags, state);
          if (text.length() <= 0)
            sendResponse(response, HTTP_ERROR_CONTENT_TYPE, "SEP_NOT_FOUND(code=241): no url found", null);
          else
            sendResponse(response, resMediaType.getType(), text, null);
        }
        else if (resMediaType.isType(MimeType.XRDS_XML)) {
//          xrds = this.resolver.resolveSEPToXRDS(oXRI, trustType, serviceType, serviceMediaType, refs);
          xrds = this.resolver.resolveSEPToXRDS(oXRI, serviceType, serviceMediaType, flags, state);
          sendResponse(response, debug, resMediaType.getType(), xrds.toString(), trustType);
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
//          xrd = this.resolver.resolveSEPToXRD(oXRI, trustType, serviceType, serviceMediaType, refs);
          xrd = this.resolver.resolveSEPToXRD(oXRI, serviceType, serviceMediaType, flags, state);
          sendResponse(response, debug, resMediaType.getType(), xrd.toResultString(), trustType);
        }
        else {
          // else - we should have taken care of it in checkSupportedMediaTypes
          log.error("processProxyRequest - should not reach here (sep=true)");
        }
      }
      else {
        //// authority resolution only
        if(resMediaType == null) {
          resMediaType = new MimeType(MimeType.XRDS_XML);
        }

        if (resMediaType.isType(MimeType.XRDS_XML)) {
//          xrds = this.resolver.resolveAuthToXRDS(oXRI, trustType, refs);
          xrds = this.resolver.resolveAuthToXRDS(oXRI, flags, state);
          sendResponse(response, debug, resMediaType.getType(), xrds.toString(), trustType);
          return;
        }
        else if (resMediaType.isType(MimeType.XRD_XML)) {
//          xrd = this.resolver.resolveAuthToXRD(oXRI, trustType, refs);
          xrd = this.resolver.resolveAuthToXRD(oXRI, flags, state);
          sendResponse(response, debug, resMediaType.getType(), xrd.toString(), trustType);
        }
        else if (resMediaType.isType(MimeType.URI_LIST)) {
          // ignore (must do SEP when text/uri-list is specified)
          log.warn("text/uri-list given but does not want to do service selection");
          // TODO: do we return an error?
View Full Code Here

Examples of org.openxri.xml.XRD

        response.sendRedirect(this.bareXRINotFoundRedirect + URLEncoder.encode(qxri, "UTF-8"));
        return;
      }
    }
    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);
    }
    else if (resMediaType.isType(MimeType.URI_LIST)) {
      errMsg = "# " + errMsg;
      sendResponse(response, HTTP_ERROR_CONTENT_TYPE, errMsg, trustType);
    }
    else if (resMediaType.isType(MimeType.XRDS_XML)) {
      sendResponse(response, isDebug, resMediaType.getType(), partialXRDS.toString(), trustType);
    }
    else if (resMediaType.isType(MimeType.XRD_XML)) {
      sendResponse(response, isDebug, resMediaType.getType(), xrd.toString(), trustType);
    }
    else {
      // else - we should have taken care of it in checkSupportedMediaTypes
      log.error("processProxyRequest - should not reach here (exception)");
    }
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.