Package net.jini.core.constraint

Examples of net.jini.core.constraint.InvocationConstraints


      if (unfulfilledRequirements == null &&
    unfulfilledPreferences == null)
      {
    return InvocationConstraints.EMPTY;
      } else {
    return new InvocationConstraints(unfulfilledRequirements,
             unfulfilledPreferences);
      }
  }
View Full Code Here


  }

  // Both non-null need to run though map check
  final int count = mappings.length / 2;
  for (int i = 0; i < mappings.length; i+=2) {     
      final InvocationConstraints c1 =
    methodConstraints1.getConstraints(mappings[i]);
      final InvocationConstraints c2 =
    methodConstraints2.getConstraints(mappings[i+1]);
      if (!c1.equals(c2)) {
    return false;
      }
  }
View Full Code Here

   * If there are relative constraints, create new method constraints
   * to set on the underlying proxy before invoking a method.
   */
  MethodConstraints convertedConstraints = null;
  if (clientConstraints != null) {
      InvocationConstraints relativeConstraints =
    clientConstraints.getConstraints(method);
      InvocationConstraints absoluteConstraints =
    relativeConstraints.makeAbsolute();
      if (relativeConstraints != absoluteConstraints) {
    convertedConstraints =
        new BasicMethodConstraints(absoluteConstraints);
      }
View Full Code Here

  String method = "ServerCapabilities.checkConstraints";
  System.err.println("\nTesting " + method + ":");
  for (Iterator i = testCases.entrySet().iterator(); i.hasNext();) {
      Map.Entry entry = (Map.Entry) i.next();
      InvocationConstraints c = (InvocationConstraints) entry.getKey();
      System.err.println("  trying: " + c);
      InvocationConstraints u = serverEndpoint.checkConstraints(c);
      System.err.println("returned: " + u);
      if (!entry.getValue().equals(u)) {
    throw new RuntimeException(
        "TEST FAILED: incorrect constraints returned by " +
        method);
      }
  }

  Endpoint endpoint =
      serverEndpoint.enumerateListenEndpoints(new ListenContext() {
    public ListenCookie addListenEndpoint(ListenEndpoint le)
        throws IOException
    {
        return le.listen(new RD()).getCookie();
    }
      });

  method = "OutboundRequest.getUnfulfilledConstraints";
  System.err.println("\nTesting " + method + ":");
  for (Iterator i = testCases.entrySet().iterator(); i.hasNext();) {
      Map.Entry entry = (Map.Entry) i.next();
      InvocationConstraints c = (InvocationConstraints) entry.getKey();
      System.err.println("  trying: " + c);
      OutboundRequestIterator iter = endpoint.newRequest(c);
      OutboundRequest request = iter.next();
      InvocationConstraints u = request.getUnfulfilledConstraints();
      System.err.println("returned: " + u);
      if (!entry.getValue().equals(u)) {
    throw new RuntimeException(
        "TEST FAILED: incorrect constraints returned by " +
        method);
View Full Code Here

      new AuthPermission("getSubject"),
      new SocketPermission("*:1024-", "accept,connect,listen"),
      new AuthenticationPermission("testClient3", "connect")};
  */

  InvocationConstraints emptyConstraints =
      InvocationConstraints.EMPTY;

  InvocationConstraints integrityRequiredConstraints =
      new InvocationConstraints(Integrity.YES, null);

  InvocationConstraints integrityPreferredConstraints =
      new InvocationConstraints(null, Integrity.YES);

  tests = new Test[] {
      /* -- preference tests -- */
      new EndpointTest( // test preference, delegation necessary
    "PreferenceConstraintTestDelegationPreferred",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]})},
        new InvocationConstraint[] {
      Integrity.NO, // will be ignored
      new ClientMinPrincipal(cps[1]),
      Delegation.YES}),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true),
      new EndpointTest( // test preference, delegation not necessary
    "PreferenceConstraintTestDelegationNotPreferred",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]})},
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2]), // not necessary
      Integrity.YES,
      Confidentiality.YES}), // preferred, but not necessary
    integrityPreferredConstraints, /* clientUnfulfilledCs */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, true, false),
      /* -- permission tests -- */
      new EndpointTest(
    "ClientPermissionNoSocketPermTest",
    new Permission[0],   /* clientPerms = default + auth */
    false,
    null,         /* serverPerms, default to the right set */
    true,
    defaultPermsNoSocketPerm),
      new EndpointTest(
    "ServerPermissionNoSocketPermTest",
    null,         /* clientPerms, default to the right set */
    true,
    new Permission[0],   /* serverPerms = default + auth */
    false,
    defaultPermsNoSocketPerm),
      new EndpointTest(
    "ClientPermissionNoAuthPermTest",
    defaultPermsWithSocketPerm, /* clientPerms */
    false,
    null,         /* serverPerms, default to the right set */
    true,
    null),
      new EndpointTest(
    "ServerPermissionNoAuthPermtest",
    null,         /* clientPerms, default to the right set */
    true,
    defaultPermsWithSocketPerm, /* serverPerms */
    false,
    null),
      /* -- connection time constraint tests -- */
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintClientPassTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionAbsoluteTime(
          System.currentTimeMillis() + 1000 * 1800)},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintAlternativesClientPassTest",
    new InvocationConstraints(
        new ConstraintAlternatives(
      new InvocationConstraint[] {
          new ConnectionAbsoluteTime(
        System.currentTimeMillis() + 1000 * 1800),
          new ConnectionAbsoluteTime(3)}),
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintClientFailTest1",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionAbsoluteTime(3)},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintClientFailTest2",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionAbsoluteTime(
          System.currentTimeMillis() + 1000 * 1800),
      new ConnectionAbsoluteTime(3)},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintServerPassTest1",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionAbsoluteTime(3)},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionAbsoluteTimeConstraintServerPassTest2",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionAbsoluteTime(
          System.currentTimeMillis() + 1000 * 1800)},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionRelativeTimeConstraintClientPassTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionRelativeTime(1000 * 1800)},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ConnectionRelativeTimeConstraintServerFailTest",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConnectionRelativeTime(1000 * 1800)},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null, null, false, false),
      /* -- authentication tests -- */
      new EndpointTest(
    "AuthenticatonYESTest",
    new InvocationConstraints(
        new InvocationConstraint[] {ClientAuthentication.YES},
        null),
    emptyConstraints, /* clientUnfulfilledCs */
    new InvocationConstraints(
        new InvocationConstraint[] {ServerAuthentication.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "AuthenticationNOTest1",
    new InvocationConstraints(
        new InvocationConstraint[] {ClientAuthentication.NO},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "AuthenticationNOTest2",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {ServerAuthentication.NO},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    null, null, false, false),
      /* -- unfulfilled constraints tests -- */
      new EndpointTest(
    "UnfulfilledConstraintClientIntegrityRequiredTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      ClientAuthentication.YES, Integrity.YES},
        null),
    integrityRequiredConstraints, /* clientUnfulfilledCs */
    new InvocationConstraints(
        new InvocationConstraint[] {ServerAuthentication.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "UnfulfilledConstraintClientIntegrityPreferredTest",
    new InvocationConstraints(
        null, new InvocationConstraint[] {Integrity.YES}),
    integrityPreferredConstraints, /* clientUnfulfilledCs */
    new InvocationConstraints(
        new InvocationConstraint[] {ServerAuthentication.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "UnfulfilledConstraintServerIntegrityRequiredTest",
    new InvocationConstraints(
        new InvocationConstraint[] {ClientAuthentication.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {Integrity.YES},
        null),
    integrityRequiredConstraints, /* clientUnfulfilledCs */
    null, null, false, false),
      new EndpointTest(
    "UnfulfilledConstraintServerIntegrityPreferredTest",
    new InvocationConstraints(
        new InvocationConstraint[] {ClientAuthentication.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    new InvocationConstraints(
        null, new InvocationConstraint[] {Integrity.YES}),
    integrityPreferredConstraints, /* clientUnfulfilledCs */
    null, null, false, false),
      /* -- principal constraint tests -- */
      new EndpointTest(
    "ClientPrincipalConstraintValidMinMaxTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[2], cps[3]})},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, false),
      new EndpointTest(
    "ClientPrincipalConstraintInvalidMinMaxTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[3]})},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      new EndpointTest(
    "ClientPrincipalConstraintNonKerberosPrincipalTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(
          new TestPrincipal("CPCT3testPrincipal"))},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      new EndpointTest(
    "ServerPrincipalConstraintValidServerMinTest",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ServerPrincipalConstraintInvalidServerMinTest",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ServerMinPrincipal(sps[0])},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    null, null, false, false),
      new EndpointTest(
    "ServerPrincipalConstraintNonKerberosServerMinTest",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(
          new TestPrincipal("SPCT3testPrincipal"))},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    null, null, false, false),
      new EndpointTest(
    "ClientMaxPrincipalConstraintClientSideTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMaxPrincipal(
          new Principal[] {cps[1], cps[2], cps[3]}),
      new ClientMaxPrincipal(
          new Principal[] {cps[1], cps[2]}),
      new ClientMaxPrincipal(cps[3])},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    null, null, false, false),
      new EndpointTest(
    "ClientMaxPrincipalConstraintServerSideTest",
    null,
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMaxPrincipal(
          new Principal[] {cps[1], cps[2], cps[3]}),
      new ClientMaxPrincipal(
          new Principal[] {cps[1], cps[3]}),
      new ClientMaxPrincipal(cps[2])},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    null, null, false, false),
      /* -- integrity tests -- */
      new EndpointTest(
    "IntegrityYESRequiredTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Integrity.YES},
        null),
    integrityRequiredConstraints, /* clientUnfulfilledConstrain */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Integrity.YES},
        null),
    integrityRequiredConstraints, /* serverUnfulfilledConstrain */
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    false, false),
      new EndpointTest(
    "IntegrityYESPreferredTest",
    new InvocationConstraints(
        null,
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Integrity.YES}),
    integrityPreferredConstraints, /* clientUnfulfilledConstrain */
    new InvocationConstraints(
        null,
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Integrity.YES}),
    integrityPreferredConstraints, /* serverUnfulfilledConstrain */
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    false, false),
      new EndpointTest(
    "ClientIntegrityNOTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Integrity.NO},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, false),
      new EndpointTest(
    "ServerIntegrityNOTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1])}, null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Integrity.NO},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    false, false),
      /* -- constraint alternatives tests -- */
      new EndpointTest(
    "ClientConstraintAlternativesPassTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2]),
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMaxPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMaxPrincipal(cps[3])})},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      new EndpointTest(
    "ClientConstraintAlternativesFailTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[0]),
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMaxPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMaxPrincipal(cps[3])})},
        null),
    null, // clientUnfulfilledConstraints, null indicates failure
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      new EndpointTest(
    "ServerConstraintAlternativesPassTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2])},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMinPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMaxPrincipal(
            new Principal[] {cps[2], cps[3]})}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      new EndpointTest(
    "ServerConstraintAlternativesFailTest1",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[0])},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMinPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMaxPrincipal(
            new Principal[] {cps[2], cps[3]})}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    new KerberosPrincipal[] {cps[0]}, null, false, false),
      new EndpointTest(
    "ServerConstraintAlternativesFailTest2",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[0])},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ClientMinPrincipal(
            new Principal[] {cps[0], cps[2]}),
        new ClientMinPrincipal(
            new Principal[] {cps[0], cps[3]})}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    new KerberosPrincipal[] {cps[0]}, null, false, false),
      /* -- confidentiality tests -- */
      new EndpointTest(
    "ConfidentialityYESTest1", // only client requests
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Confidentiality.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Integrity.YES},
        null),
    integrityRequiredConstraints, /* serverUnfulfilledConstrain */
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    true, false),
      new EndpointTest(
    "ConfidentialityYESTest2", // only server requests
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]})},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Confidentiality.YES},
        null),
    null, // serverUnfulfilledConstraints, null indicates failure
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    false, false),
      new EndpointTest(
    "ConfidentialityYESTest3", // both client and server request
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Confidentiality.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Confidentiality.YES},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    true, false),
      new EndpointTest(
    "ClientConfidentialityNOTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1], cps[2]}),
      Confidentiality.NO},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, false),
      new EndpointTest(
    "ServerConfidentialityNOTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1])}, null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[0], cps[1]}),
      new ServerMinPrincipal(defaultServerPrincipal),
      Confidentiality.NO},
        null),
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]},
    new KerberosPrincipal[] {defaultServerPrincipal},
    false, false),
      /* -- delegation tests -- */
      new EndpointTest(
    "DelegationYESTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[2], cps[3]}),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, true),
      new EndpointTest(
    "DelegationNOTest",
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[2]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[2], cps[3]}),
      Delegation.NO},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[2]}, null, false, false),
      /* -- data tests -- */
      new EndpointTest(
    "OneWriteShortDataNoEncryptionTest",
    oneShortArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneShortArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true, null),
      new EndpointTest(
    "MultiWriteShortDataNoEncryptionTest",
    multiShortArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    multiShortArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true, null),
      new EndpointTest(
    "OneWriteLongDataNoEncryptionTest1",
    oneLongArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneLongArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true, null),
      new EndpointTest(
    "OneWriteLongDataNoEncryptionTest2",
    oneLongArray3, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneLongArray4, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true, null),
      new EndpointTest(
    "MultiWriteLongDataNoEncryptionTest",
    multiLongArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    multiLongArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, false, true, null),
      new EndpointTest(
    "OneWriteShortDataWithEncryptionTest",
    oneShortArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Confidentiality.YES,
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneShortArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, true, true, null),
      new EndpointTest(
    "MultiWriteShortDataWithEncryptionTest",
    multiShortArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Confidentiality.YES,
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    multiShortArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, true, true, null),
      new EndpointTest(
    "OneWriteLongDataWithEncryptionTest1",
    oneLongArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Confidentiality.YES,
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneLongArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, true, true, null),
      new EndpointTest(
    "OneWriteLongDataWithEncryptionTest2",
    oneLongArray3, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Confidentiality.YES,
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    oneLongArray4, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, true, true, null),
      new EndpointTest(
    "MultiWriteLongDataWithEncryptionTest",
    multiLongArray1, null, true,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      Confidentiality.YES,
      Delegation.YES},
        null),
    emptyConstraints, /* clientUnfulfilledConstraints */
    multiLongArray2, null, true,
    null,
    emptyConstraints, /* serverUnfulfilledConstraints */
    new KerberosPrincipal[] {cps[1]}, null, true, true, null),
      /* -- server capability tests -- */
      new ServerCapabilityTest(
    "ServerCapabilityNullConstraintsTest",
    serverEndpoint, null,
    null,             /* constraints */
    emptyConstraints, /* unfulfilledConstraints */
    "null constraints, should not return", /* returnErrMsg */
    null,             /* nullPointerExceptionErrMsg */
    "unsupportedConstraintException thrown",
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityNoAuthenticationPermissionTest",
    serverEndpoint, defaultPermsNoSocketPerm,
    null,             /* constraints */
    emptyConstraints, /* unfulfilledConstraints */
    "null constraints, should not return", /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    "unsupportedConstraintException thrown",
    null),            /* securityExceptionErrMsg */
      new ServerCapabilityTest(
    "ServerCapabilitySubjectNoCredentialPermissionTest",
    serverEndpointNoCred, null,
    null,             /* constraints */
    emptyConstraints, /* unfulfilledConstraints */
    "null constraints, should not return", /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    null,             /* unsupportedConstraintExceptionErrMsg */
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityValidPrincipalConstraintsTest",
    serverEndpoint, null,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[2], cps[3]}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    emptyConstraints, /* unfulfilledConstraints */
    null,             /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    "unsupportedConstraintException thrown",
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityConstraintAlternativesPassTest",
    serverEndpoint, null,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMinPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMaxPrincipal(cps[3])}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    emptyConstraints, /* unfulfilledConstraints */
    null,             /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    "unsupportedConstraintException thrown",
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityConstraintAlternativesFailTest",
    serverEndpoint, null,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ConstraintAlternatives(
          new InvocationConstraint[] {
        new ServerMinPrincipal(sps[3]),
        new ClientMinPrincipal(
            new Principal[] {cps[1], cps[2]}),
        new ClientMinPrincipal(
            new Principal[] {cps[2], cps[3]})}),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    null,             /* unfulfilledConstraints */
    "invalid constraints, should not return", /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    null,             /* unsupportedConstraintExceptionErrMsg */
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityInvalidPrincipalConstraintsTest1",
    serverEndpoint, null,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(
          new Principal[] {cps[1], cps[2]}),
      new ClientMaxPrincipal(cps[3]),
      new ServerMinPrincipal(defaultServerPrincipal)},
        null),
    emptyConstraints, /* unfulfilledConstraints */
    "conflict constraints, should not return", /* returnErrMsg */
    "NullPointerException thrown", /* nullPointerExceptionErrMsg */
    null,             /* unsupportedConstraintExceptionErrMsg */
    "SecurityException thrown when perms granted"),
      new ServerCapabilityTest(
    "ServerCapabilityInvalidPrincipalConstraintsTest2",
    serverEndpoint, null,
    new InvocationConstraints(
        new InvocationConstraint[] {
      new ClientMinPrincipal(cps[1]),
      new ClientMaxPrincipal(
                            new Principal[] {cps[1], cps[2], cps[3]}),
      new ServerMinPrincipal(sps[2])},
View Full Code Here

      }
      String method = "InboundRequest.checkConstraints";
      System.err.println("\n| Testing " + method + ":");
      for (Iterator i = testCases.entrySet().iterator(); i.hasNext();) {
    Map.Entry entry = (Map.Entry) i.next();
    InvocationConstraints c =
        (InvocationConstraints) entry.getKey();
    System.err.println("|   trying: " + c);
    InvocationConstraints u;
    try {
        u = request.checkConstraints(c);
    } catch (UnsupportedConstraintException e) {
        synchronized (lock) {
      inboundRequestFailure = new RuntimeException(
View Full Code Here

     TestConnectTimeout.class.getClassLoader(),
     new Class[] { Ping.class, RemoteMethodControl.class },
     invocationHandler);

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    new ConnectionRelativeTime(TIMEOUT),
    null
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    ConstraintAlternatives.create(new InvocationConstraint[] {
        new ConnectionRelativeTime(TIMEOUT),
        new ConnectionRelativeTime(TIMEOUT + 1)
    }),
    null
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    null,
    new ConnectionRelativeTime(TIMEOUT)))));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    null,
    ConstraintAlternatives.create(new InvocationConstraint[] {
        new ConnectionRelativeTime(TIMEOUT),
        new ConnectionRelativeTime(TIMEOUT + 1)
    })
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    new ConnectionAbsoluteTime(System.currentTimeMillis()),
    null
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    ConstraintAlternatives.create(new InvocationConstraint[] {
        new ConnectionAbsoluteTime(System.currentTimeMillis()),
        new ConnectionAbsoluteTime(System.currentTimeMillis() + 1)
    }),
    null
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    null,
    new ConnectionAbsoluteTime(System.currentTimeMillis())
      ))
  ));

  tryProxy(proxy.setConstraints(
      new BasicMethodConstraints(new InvocationConstraints(
    null,
    ConstraintAlternatives.create(new InvocationConstraint[] {
        new ConnectionAbsoluteTime(System.currentTimeMillis()),
        new ConnectionAbsoluteTime(System.currentTimeMillis() + 1)
    })
View Full Code Here

        Object proxy = ProxyTrustUtil.newProxyInstance(
                new RMCTEImpl(), ptih);
        Method m = RemoteMethodControl.class.getDeclaredMethod(
                "setConstraints", new Class[] { MethodConstraints.class });
        MethodConstraints mc = new BasicMethodConstraints(
                new InvocationConstraints(
                    new InvocationConstraint[] { ClientAuthentication.YES },
                    null));
        Object res = ptihInvoke(ptih, proxy, m, new Object[] { mc });

        if (mImpl.getSetConstraintsNum() != 1) {
View Full Code Here

        }
        proxy = new RMCImpl();
        m = RemoteMethodControl.class.getDeclaredMethod(
                "setConstraints", new Class[] { MethodConstraints.class });
        MethodConstraints mc = new BasicMethodConstraints(
                new InvocationConstraints(
                    new InvocationConstraint[] { ClientAuthentication.YES },
                    null));

        try {
            ptihInvoke(ptih, proxy, m, new Object[] { mc });
View Full Code Here

     * @throws NullPointerException {@inheritDoc}
     */
    public InvocationConstraints getConstraints(Method method) {
  String name = method.getName();
  Class[] types = null;
  InvocationConstraints sc = null;
    outer:
  for (int i = 0; i < descs.length; i++) {
      MethodDesc desc = descs[i];
      String dname = desc.name;
      if (dname == null) {
View Full Code Here

TOP

Related Classes of net.jini.core.constraint.InvocationConstraints

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.