Package net.jini.core.constraint

Examples of net.jini.core.constraint.ConstraintAlternatives


  }
  if (principalConstraints.contains(cl)) {
      return constraint;
  }
  if (constraint instanceof ConstraintAlternatives) {
      ConstraintAlternatives ca = (ConstraintAlternatives) constraint;
      Collection dist = new ArrayList();
      for (Iterator i = ca.elements().iterator(); i.hasNext(); ) {
    Object d = distill((InvocationConstraint) i.next(), request);
    if (d == SUPPORTED) {
        return SUPPORTED;
    } else if (d instanceof InvocationConstraint) {
        dist.add(d);
View Full Code Here


        Set principals = clientSubject.getPrincipals(KerberosPrincipal.class);
        return new ClientMaxPrincipal(principals);
    }

    public ConstraintAlternatives getConstraintAlternatives1() {
        return new ConstraintAlternatives(new InvocationConstraint[] {
            new ClientMinPrincipal(clientSubject.getPrincipals()),
            new ClientMinPrincipal(new KerberosPrincipal("dummy"))
        });
    }
View Full Code Here

            new ClientMinPrincipal(new KerberosPrincipal("dummy"))
        });
    }

    public ConstraintAlternatives getConstraintAlternatives2() {
        return new ConstraintAlternatives(new InvocationConstraint[] {
            new ClientMinPrincipal(clientSubject.getPrincipals()),
            new ClientMinPrincipal(new KerberosPrincipal("dummy"))
        });
    }
View Full Code Here

            new ClientMinPrincipal(new KerberosPrincipal("dummy"))
        });
    }

    public ConstraintAlternatives getServerMinPrincipal() {
        return new ConstraintAlternatives(new InvocationConstraint[] {
            new ServerMinPrincipal(serverSubject.getPrincipals()),
            new ServerMinPrincipal(new KerberosPrincipal("dummy"))
        });
    }
View Full Code Here

            new ClientMaxPrincipal(new Principal[] { tp1, tp2 }),
            new ServerMinPrincipal(new Principal[] { tp1, tp2 }),
            new ClientMinPrincipal(new Principal[] { tp1, tp3, tp2 }),
            new ClientMaxPrincipal(new Principal[] { tp1, tp3, tp2 }),
            new ServerMinPrincipal(new Principal[] { tp1, tp3, tp2 }),
            new ConstraintAlternatives(new InvocationConstraint[] {
                Delegation.YES,
                Integrity.YES,
                ClientAuthentication.YES }),
            new ConstraintAlternatives(new InvocationConstraint[] {
                Delegation.YES,
                Confidentiality.YES,
                ClientAuthentication.YES }),
            new BasicMethodConstraints(
                    new BasicMethodConstraints.MethodDesc[] { md1, md2 }),
View Full Code Here

    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(
View Full Code Here

                callConstructor(testCase, coll, NullPointerException.class);
            } else if (testCase == CONSTRUCTOR__ARRAY_ILL_EL_ALT) {
                callConstructor(testCase,
                        new InvocationConstraint[] {
                                Delegation.YES,
                                new ConstraintAlternatives(
                                        new InvocationConstraint[] {
                                                Delegation.YES,
                                                Delegation.NO
                                        }),
                                Delegation.NO
                        }, IllegalArgumentException.class);
            } else if (testCase == CONSTRUCTOR__COLL_ILL_EL_ALT) {
                Collection coll = new ArrayList();
                coll.add(Delegation.YES);
                coll.add(new ConstraintAlternatives(
                        new InvocationConstraint[] {
                                Delegation.YES,
                                Delegation.NO
                        }));
                coll.add(Delegation.NO);
View Full Code Here

            for (int i = 0; i < ic.length; i++) {
                argBeforeInvoke.add(ic[i]);
            }
        }
        ConstraintAlternatives constraint = null;

        try {
            constraint = new ConstraintAlternatives(ic);
            // If some Exception is expected
            if (       tc == CONSTRUCTOR__ARRAY_NULL
                    || tc == CONSTRUCTOR__ARRAY_NULL_EL
                    || tc == CONSTRUCTOR__ARRAY_ILL_EL_ALT
                    || tc == CONSTRUCTOR__ARRAY_EL_NOT_ENOUGH) {
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor " + e);
            // If no Exception is expected
            if (tc == CONSTRUCTOR__ARRAY) {
                throw new TestException("Exception while invoking constructor ",
                        e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + constraint.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (constraint == null) {
            throw new TestException("Constraint object hasn't been created");
        }
        checkElements(constraint, argBeforeInvoke);

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */
        argAfterInvoke.clear();

        for (int i = 0; i < ic.length; i++) {
            argAfterInvoke.add(ic[i]);
        }
        logger.log(Level.INFO, "argAfterInvoke:: " + argAfterInvoke);

        if (!argBeforeInvoke.equals(argAfterInvoke)) {
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Create ConstraintAlternatives object using create() method
         * and compare it with the ConstraintAlternatives object created with
         * constructor.
         */
        InvocationConstraint constraintBefore = null;

        try {
            constraintBefore =
                    ConstraintAlternatives.create((InvocationConstraint[]) ic);
        } catch (Exception e) {
            throw new TestException("Exception is thrown while invoking"
                    + " ConstraintAlternatives.create() method", e);
        }

        // Change argument passed to the constructor
        for (int i = 0; i < ic.length; i++) {
            ic[i] = null;
        }

        // Comparing 2 ConstraintAlternatives objects
        if (!constraint.equals(constraintBefore)) {
            throw new TestException("The argument passed to the"
                    + " constructor is retained");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't retained");

        /*
         * Verify that duplicates are removed.
         */
        checkDuplicates(constraint.elements());
        logger.log(Level.FINE, "Duplicates have been removed");
    }
View Full Code Here

         */
        if (tc == CONSTRUCTOR__COLL) {
            argBeforeInvoke.clear();
            argBeforeInvoke.addAll(c);
        }
        ConstraintAlternatives constraint = null;

        try {
            constraint = new ConstraintAlternatives(c);
            // If some Exception is expected
            if (       tc == CONSTRUCTOR__COLL_NULL
                    || tc == CONSTRUCTOR__COLL_NULL_EL
                    || tc == CONSTRUCTOR__COLL_ILL_EL_ALT
                    || tc == CONSTRUCTOR__COLL_EL_NOT_ENOUGH
                    || tc == CONSTRUCTOR__COLL_EL_NOT_IC) {
                throw new TestException("Instead of " + ex + " no Exception"
                        + " has been thrown while invoking constructor");
            }
        } catch (Exception e) {
            logger.log(Level.FINE, "Exception while invoking constructor " + e);
            // If no Exception is expected
            if (tc == CONSTRUCTOR__COLL) {
                throw new TestException("Exception while invoking constructor ",
                        e);
            }

            // If some Exception is expected
            if (!ex.equals(e.getClass())) {
                logger.log(Level.FINE, "Expected Exception:: " + ex);
                logger.log(Level.FINE, "Thrown   Exception:: " + e.getClass());
                throw new TestException("Instead of " + ex + " "
                        + e.getClass() + " has been thrown while"
                        + " invoking constructor");
            } else {
                return;
            }
        }

        // logger.log(Level.INFO, "Returned object: " + constraint.toString());

        /*
         * Verify that the corresponding constraint object is created.
         */
        if (constraint == null) {
            throw new TestException("Constraint object hasn't been created");
        }
        checkElements(constraint, argBeforeInvoke);

        /*
         * Verify that the argument passed to the constructor isn't modified.
         * Compare argument for the constructor before and after invoking the
         * constructor.
         */
        argAfterInvoke.clear();
        argAfterInvoke.addAll(c);

        if (!argBeforeInvoke.equals(argAfterInvoke)) {
            throw new TestException("The argument passed to the constructor"
                    + " is modified");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't modified");

        /*
         * Verify that the argument passed to the constructor isn't retained;
         * subsequent changes to that argument have no effect on the instance
         * created. Create ConstraintAlternatives object using create() method
         * and compare it with the ConstraintAlternatives object created with
         * constructor.
         */
        InvocationConstraint constraintBefore = null;

        try {
            constraintBefore = ConstraintAlternatives.create((Collection) c);
        } catch (Exception e) {
            throw new TestException("Exception is thrown while invoking"
                    + " ConstraintAlternatives.create() method", e);
        }

        // Change argument passed to the constructor
        c.clear();
        // Comparing 2 ConstraintAlternatives objects
        if (!constraint.equals(constraintBefore)) {
            throw new TestException("The argument passed to the"
                    + " constructor is retained");
        }
        logger.log(Level.FINE,
                "The argument passed to the constructor isn't retained");

        /*
         * Verify that duplicates are removed.
         */
        checkDuplicates(constraint.elements());
        logger.log(Level.FINE, "Duplicates have been removed");
    }
View Full Code Here

            set.add(Delegation.NO);
            set.add(Integrity.YES);
            set.add(Integrity.NO);
            set.add(ServerAuthentication.YES);
            set.add(ServerAuthentication.NO);
            obj = new ConstraintAlternatives(set);
        } catch (Exception e) {
            throw new TestException("Exception has been thrown while creating"
                    + " ConstraintAlternatives object", e);
        }
    }
View Full Code Here

TOP

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

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.