Package org.openxri.xml

Examples of org.openxri.xml.Service


        private static XRD createAuthRoot(String uri, TrustType tt) {
    XRD xrd = new XRD();

    // construct an authority resolution service
    Service srv = new Service();
    if (tt == null)
                    tt = new TrustType(); // default trust type
                else {
                    try {
                        X509Certificate[] arr = new X509Certificate[1];
                        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("keystore.jks");
                        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
                        ks.load(is, "password".toCharArray());
                        arr[0] = (X509Certificate)ks.getCertificate("issuercert");
                        Document oDoc = new DocumentImpl();
                        KeyInfo oKeyInfo = new KeyInfo(oDoc);
                        X509Data oData = new X509Data(oDoc);
                        oData.addCertificate(arr[0]);
                        oKeyInfo.add(oData);
                        srv.setKeyInfo(oKeyInfo);
                       
                        srv.setProviderId("@!E459.819D.771.7990!5B62.6F13.7602.5176");
                    } catch (Exception e) {
                        throw new RuntimeException("Failed to load keystore alias (certificate): " + e.toString());
                    }
                }
    String authMediaType = Tags.CONTENT_TYPE_XRDS + ";"
        + tt.getParameterPair();
    srv.addMediaType(authMediaType, null, Boolean.FALSE);
    srv.addType(Tags.SERVICE_AUTH_RES);
    srv.addURI(uri);


    // add it to the XRD
    xrd.addService(srv);
View Full Code Here


    if (xrd.getSelectedServices().getList().size() < 1) {
      log.error("SEP Selection succeeded but no Service found!?");
      return new ArrayList();
    }

    Service topService = (Service) xrd.getSelectedServices().getList().get(0);

    ArrayList urisOut = new ArrayList();
    ArrayList uris = topService.getPrioritizedURIs();
    for (int i = 0; uris != null && i < uris.size(); i++) {
      SEPUri uri = (SEPUri) uris.get(i);
      String append = uri.getAppend();
      urisOut.add(constructURI(uri.getURI(), append, qxri));
    }
View Full Code Here

      throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Invalid XRDS document: too many XRD elements returned");     
    }
   

    XRD prevXRD = parent;
    Service prevService = parentService;
    ResolverFlags currentFlags = null; // this is for overriding by SamlBypassAuthority settings
    // check each child
    for (int d = 0; d < tmpXRDS.getNumChildren(); d++) {
      if (!tmpXRDS.isXRDAt(d))
        throw makeResolutionException(xrdsOut, query, Status.INVALID_XRDS, "Authority XRDS document should not contain XRDS element");
View Full Code Here

   
    ///// Try each URI in each selected service in turn
    Exception savedException = null;
    Iterator srvIterator = authResServices.iterator();
    while (srvIterator.hasNext()) {     
      Service srv = (Service) srvIterator.next();
      Iterator uriIterator = srv.getPrioritizedURIs().iterator();
     
      while (uriIterator.hasNext()) {
        SEPUri sepURI = (SEPUri) uriIterator.next();
        URI uri = sepURI.getURI();
View Full Code Here

              );
          }
          // we need to pass a Service object representing the authority resolution service
          // that was selected but this only matters for SAML resolution, in which case, only
          // one is allowed, so we just pass the first Service to it.
          Service authRes = (Service) authResServices.get(0);
          parseFetchedXRD(xrdsCached, xrdsCached.getDescriptorAt(0), parent, remainingSegment.getSubSegmentAt(0), authRes, flags);      
          tmpXRDS = xrdsCached;
        }
      }
View Full Code Here

      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);
    if (srv.getNumRedirects() > 0) {
      // try to follow each redirect (which will recurse back into this method if the XRDS was fetched successfully.)
      selectedSvcs = processServiceRedirects(xrdsOut, srv, xrd, qxri, sepType, sepMediaType, flags, state);
    }
    else if (srv.getNumRefs() > 0) {
      selectedSvcs = processServiceRefs(xrdsOut, srv, xrd, qxri, sepType, sepMediaType, flags, state);
    }

    return selectedSvcs;
  }
View Full Code Here

    if (selectedServices == null || selectedServices.size() == 0)
      return new ArrayList();

    PrioritizedList list = new PrioritizedList();
    for (int i = 0; i < selectedServices.size(); i++) {
      Service s = (Service) selectedServices.get(i);
      String priority = (s.getPriority() == null) ? PrioritizedList.PRIORITY_NULL
          : s.getPriority().toString();
      list.addObject(priority, s);
    }

    return list.getList();
  }
View Full Code Here

   
    log.debug("constructURIinXRD()");
   
    while (it.hasNext()) {
      log.debug("constructURIinXRD() got selected service");
      Service sep = (Service)it.next();
      List uris = sep.getURIs();
      Iterator itURI = uris.iterator();
      while (itURI.hasNext()) {
        SEPUri uri = (SEPUri)itURI.next();
        String append = uri.getAppend();
        if (append != null) {
          String r = constructURI(uri.getURI(), uri.getAppend(), qxri);
          try {
            uri.setURI(new URI(r));
            uri.setAppend(null);
          } catch (URISyntaxException e) {}
        }
      }
    }

    for (int i = 0; i < finalXRD.getNumServices(); i++) {
      log.debug("constructURIinXRD() got service");
      Service sep = (Service)finalXRD.getServiceAt(i);
      List uris = sep.getURIs();
      Iterator itURI = uris.iterator();
      while (itURI.hasNext()) {
        SEPUri uri = (SEPUri)itURI.next();
        String append = uri.getAppend();
        if (append != null) {
View Full Code Here

      assertTrue("The eighth child should be an XRDS element because it followed a Service-level Redirect", xrds.isXRDSAt(7));
      redirXRDS = xrds.getXRDSAt(7);
      assertTrue("Wrong redirect followed on the eighth child", redirXRDS.getRedirect().equals("http://auth.xrid.net/!332/"));
      assertTrue("Eighth child should have succeeded", redirXRDS.getFinalXRD().getStatusCode().equals(Status.SUCCESS));
      assertTrue("Should be one selected Service on eighth child", redirXRDS.getFinalXRD().getSelectedServices().getList().size() == 1);
      Service srv = (Service)redirXRDS.getFinalXRD().getSelectedServices().getList().get(0);
      assertTrue("In correct URI in selected service on eighth child", srv.getURIAt(0).getUriString().equals("http://my.blog.com"));
    }
    catch (Exception e) {
      e.printStackTrace();
      fail("Not expecting exception: " + e);
    }
View Full Code Here

 
  public static XRD createAuthRoot(String uri) {
    XRD xrd = new XRD();

    // construct an authority resolution service
    Service srv = new Service();
    TrustType tt = new TrustType(); // default trust type
    String authMediaType = Tags.CONTENT_TYPE_XRDS + ";"
        + tt.getParameterPair();
    srv.addMediaType(authMediaType, null, Boolean.FALSE);
    srv.addType(Tags.SERVICE_AUTH_RES);
    srv.addURI(uri);

    // add it to the XRD
    xrd.addService(srv);

    return xrd;
View Full Code Here

TOP

Related Classes of org.openxri.xml.Service

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.