@SuppressWarnings("unused")
  private static void callShibbAsWS()
      throws MalformedURLException, SNAAExceptionException, AuthenticationExceptionException {

    SNAA port = WisebedServiceHelper.getSNAAService("http://*****:*****@wisebed1.itm.uni-luebeck.de");
    auth1.setPassword("xxx");

    List<AuthenticationTriple> authTriples = new ArrayList<AuthenticationTriple>();
    authTriples.add(auth1);
    port.authenticate(authTriples);
    Action action = new Action();
    action.setAction("sth");
    port.isAuthorized(new ArrayList<SecretAuthenticationKey>(), action);
  }
Exemplo n.º 2
0
  protected Map<String, Set<AuthenticationTriple>> getIntersectionPrefixSetAT(
      List<AuthenticationTriple> authenticationData) throws SNAAExceptionException {

    if (authenticationData == null) {
      throw createSNAAException("Argument authenticationData must not be null!");
    }

    // WS Endpoint URL -> Set<URN Prefixes> for intersection of authenticationData
    Map<String, Set<AuthenticationTriple>> intersectionPrefixSet =
        new HashMap<String, Set<AuthenticationTriple>>();

    for (AuthenticationTriple authenticationTriple : authenticationData) {

      for (Entry<String, Set<String>> entry : prefixSet.entrySet()) {
        if (entry.getValue().contains(authenticationTriple.getUrnPrefix())) {
          Set<AuthenticationTriple> set =
              intersectionPrefixSet.get(authenticationTriple.getUrnPrefix());
          if (set == null) {
            set = new HashSet<AuthenticationTriple>();
            intersectionPrefixSet.put(entry.getKey(), set);
          }
          set.add(authenticationTriple);
        }
      }

      // check if federator federates the urn prefix found in the authentication triple
      boolean found = false;
      for (Set<AuthenticationTriple> triples : intersectionPrefixSet.values()) {
        for (AuthenticationTriple triple : triples) {
          if (triple.getUrnPrefix().equals(authenticationTriple.getUrnPrefix())) {
            found = true;
          }
        }
      }

      if (!found) {
        throw createSNAAException(
            "No endpoint known for URN prefix " + authenticationTriple.getUrnPrefix());
      }
    }

    return intersectionPrefixSet;
  }
  @SuppressWarnings("unused")
  private static void callFederatorAsWS()
      throws MalformedURLException, SNAAExceptionException, AuthenticationExceptionException {

    SNAA port = WisebedServiceHelper.getSNAAService("http://*****:*****@wisebed1.itm.uni-luebeck.de");
    auth1.setPassword("xxx");
    authTriples.add(auth1);

    AuthenticationTriple auth2 = new AuthenticationTriple();
    auth2.setUrnPrefix("urn:wisebed:dummy1");
    auth2.setUsername("*****@*****.**");
    auth2.setPassword("xxx");
    authTriples.add(auth2);

    AuthenticationTriple auth3 = new AuthenticationTriple();
    auth3.setUrnPrefix("urn:wisebed:dummy2");
    auth3.setUsername("*****@*****.**");
    auth3.setPassword("xxx");
    authTriples.add(auth3);

    AuthenticationTriple auth4 = new AuthenticationTriple();
    auth4.setUrnPrefix("urn:wisebed:shib2");
    auth4.setUsername("*****@*****.**");
    auth4.setPassword("xxx");
    authTriples.add(auth4);

    try {
      List<SecretAuthenticationKey> keys = port.authenticate(authTriples);
      log.info("Got authentication keys: " + keys);
      Action action = new Action();
      action.setAction("sth");
      boolean b = port.isAuthorized(new ArrayList<SecretAuthenticationKey>(), action);
      log.info("Is authorized: " + b);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }