Package net.jini.core.constraint

Examples of net.jini.core.constraint.InvocationConstraints


    public void run() throws Exception {
        try {

            // setup infrastructure needed by test
            request = new FakeInboundRequest(null);
            InvocationConstraints constraints = InvocationConstraints.EMPTY;
            Object[] args = {};
            Object retVal = new Object();
            Throwable exc = new Exception();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(baos);
View Full Code Here


        // Preferences
        HashSet prefs = new HashSet();

        // InvocationConstraints object #1 (argument #1)
        InvocationConstraints icArg1;

        // InvocationConstraints object #2 (argument #2)
        InvocationConstraints icArg2;

        // The expected InvocationConstraints object
        InvocationConstraints icExp;

        /*
         * +++++ TestCase #1 +++++
         */
        tc[0] = new TestCase(null, null, InvocationConstraints.EMPTY);

        /*
         * +++++ TestCase #2 +++++
         */
        tc[1] = new TestCase(InvocationConstraints.EMPTY,
                InvocationConstraints.EMPTY, InvocationConstraints.EMPTY);

        /*
         * +++++ TestCase #3 +++++
         */
        tc[2] = new TestCase(null, InvocationConstraints.EMPTY,
                InvocationConstraints.EMPTY);

        /*
         * +++++ TestCase #4 +++++
         */
        tc[3] = new TestCase(InvocationConstraints.EMPTY, null,
                InvocationConstraints.EMPTY);

        /*
         * +++++ TestCase #5 +++++
         */
        // Requirements
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Preferences
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);
        tc[4] = new TestCase(null, new InvocationConstraints(reqs, prefs),
                new InvocationConstraints(reqs, prefs));

        /*
         * +++++ TestCase #6 +++++
         */
        // Requirements
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Preferences
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);
        tc[5] = new TestCase(InvocationConstraints.EMPTY,
                new InvocationConstraints(reqs, prefs),
                new InvocationConstraints(reqs, prefs));

        /*
         * +++++ TestCase #7 +++++
         */
        // Requirements
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Preferences
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);
        tc[6] = new TestCase(new InvocationConstraints(reqs, prefs), null,
                new InvocationConstraints(reqs, prefs));

        /*
         * +++++ TestCase #8 +++++
         */
        // Requirements
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Preferences
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);
        tc[7] = new TestCase(new InvocationConstraints(reqs, prefs),
                InvocationConstraints.EMPTY, new InvocationConstraints(reqs,
                prefs));

        /*
         * +++++ TestCase #9 +++++
         */
        // Reqs for InvocationConstraints #1
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        // Prefs for InvocationConstraints #1
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);

        // InvocationConstraints #1
        icArg1 = new InvocationConstraints(reqs, prefs);
       
        // Reqs for InvocationConstraints #2
        reqs.clear();
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Prefs for InvocationConstraints #2
        prefs.clear();
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);

        // InvocationConstraints #2
        icArg2 = new InvocationConstraints(reqs, prefs);
       
        // Reqs for the expected InvocationConstraints object
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);
        // Prefs for the expected InvocationConstraints object
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);

        // The expected InvocationConstraints object
        icExp = new InvocationConstraints(reqs, prefs);
        tc[8] = new TestCase(icArg1, icArg2, icExp);

        /*
         * +++++ TestCase #10 +++++
         */
        // Reqs for InvocationConstraints #1
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        // Duplicate req
        reqs.add(Integrity.YES);

        // Prefs for InvocationConstraints #1
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        // Duplicate pref
        prefs.add(Integrity.NO);
        // Pref that is duplicate of reqs in InvocationConstraints #2
        prefs.add(Integrity.YES);

        // InvocationConstraints #1
        icArg1 = new InvocationConstraints(reqs, prefs);
       
        // Reqs for InvocationConstraints #2
        reqs.clear();
        // Duplicate req
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);

        // Prefs for InvocationConstraints #2
        prefs.clear();
        // Pref that is duplicate of reqs in InvocationConstraints #1
        prefs.add(ClientAuthentication.YES);
        // Duplicate pref
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);

        // InvocationConstraints #2
        icArg2 = new InvocationConstraints(reqs, prefs);
       
        // Reqs for the expected InvocationConstraints object
        reqs.clear();
        reqs.add(ClientAuthentication.YES);
        reqs.add(Confidentiality.YES);
        reqs.add(Delegation.YES);
        reqs.add(Integrity.YES);
        reqs.add(ServerAuthentication.YES);

        // Prefs for the expected InvocationConstraints object
        prefs.clear();
        prefs.add(ClientAuthentication.NO);
        prefs.add(Confidentiality.NO);
        prefs.add(Delegation.NO);
        prefs.add(Integrity.NO);
        prefs.add(ServerAuthentication.NO);

        // The expected InvocationConstraints object
        icExp = new InvocationConstraints(reqs, prefs);
        tc[9] = new TestCase(icArg1, icArg2, icExp);
    }
View Full Code Here

         */
        public boolean combine() {
            logger.log(Level.FINE, "InvocationConstraints.combine(arg1, arg2)");
            logger.log(Level.FINE, "arg1:: " + ic_arg1);
            logger.log(Level.FINE, "arg2:: " + ic_arg2);
            InvocationConstraints ic_returned =
                    InvocationConstraints.combine(ic_arg1, ic_arg2);
            logger.log(Level.FINE, "Expected:: " + ic_expected);
            logger.log(Level.FINE, "Returned:: " + ic_returned);
            return (ic_expected.equals(ic_returned));
        }
View Full Code Here

        logger.log(Level.INFO, "======================================");
       
        // 1
        String name = "someMethod";
        InvocationConstraint ic = Delegation.YES;
        InvocationConstraints constraints = new InvocationConstraints(
                ic, null);
        MethodDesc methodDesc1 = new MethodDesc(name, constraints);
        MethodDesc methodDesc2 = new MethodDesc(constraints);
        MethodDesc [] descs = {methodDesc1, methodDesc2};
        BasicMethodConstraints bmc1 = new BasicMethodConstraints(descs);
View Full Code Here

        logger.log(Level.INFO, "======================================");
       
        // 1
        String name = "someMethod";
        InvocationConstraint ic = Delegation.YES;
        InvocationConstraints constraints = new InvocationConstraints(
                ic, null);
        MethodDesc methodDesc1 = new MethodDesc(name, constraints);
        MethodDesc methodDesc2 = new MethodDesc(constraints);
        MethodDesc [] descs = {methodDesc1, methodDesc2};
        BasicMethodConstraints bmc1 = new BasicMethodConstraints(descs);
View Full Code Here

        logger.log(Level.INFO, "======================================");
       
        // 1
        String name = "equals";
        InvocationConstraint ic = Delegation.YES;
        InvocationConstraints constraints = new InvocationConstraints(
                ic, null);
        MethodDesc methodDesc = new MethodDesc(name, constraints);
        MethodDesc [] descs = {methodDesc};
        BasicMethodConstraints bmc = new BasicMethodConstraints(descs);
        Method mEquals = Object.class.getDeclaredMethod(name,
                new Class[] { Object.class });
        InvocationConstraints returnedConstraints =
                bmc.getConstraints(mEquals);
        if (!constraints.equals(returnedConstraints)) {
            throw new TestException(
                    "Invalid constraints was returned");
        }

        // 2
        String name1 = "hashCode";
        Method mHashCode = Object.class.getDeclaredMethod(name1,
                new Class[] {});
        returnedConstraints = bmc.getConstraints(mHashCode);
        InvocationConstraints emptyConstraints = new InvocationConstraints(
                (InvocationConstraint) null, null);
        if (!emptyConstraints.equals(returnedConstraints)) {
            throw new TestException(
                    "Empty constraints should be returned");
        }

        // 3
        String name2 = "*ashCode";
        InvocationConstraint ic2 = Delegation.NO;
        InvocationConstraints constraints2 = new InvocationConstraints(
                ic2, null);
        MethodDesc methodDesc2 = new MethodDesc(name2, constraints2);
        String name3 = "*shCode";
        InvocationConstraint ic3 = Integrity.NO;
        InvocationConstraints constraints3 = new InvocationConstraints(
                ic3, null);
        MethodDesc methodDesc3 = new MethodDesc(name3, constraints3);
        MethodDesc [] descs3 = {methodDesc, methodDesc2, methodDesc3};
        bmc = new BasicMethodConstraints(descs3);
        returnedConstraints = bmc.getConstraints(mHashCode);
View Full Code Here

        Util.log(Util.CALLS,
            "Entering ServerEndpoint.checkConstraints(constraints)");
        Util.log(Util.STACK);
        Util.log(Util.PARAMS, "Parameter constraints: " + constraints);
        Statistics.increment(className, "supportsConstraints");
        InvocationConstraints b = endpoint.checkConstraints(constraints);
        Util.log(Util.RETURN, "Returning constraints: " + b);
        Util.log(Util.CALLS, "Leaving ServerEndpoint.checkConstraints");
        return b;
    }
View Full Code Here

      client = (Principal) cIter.next();
      assert client != null;
        } else {
      client = null;
        }
        InvocationConstraints unfulfilledConstraints =
      getUnfulfilledConstraints(
          suite, client, server, constraints);
        if (unfulfilledConstraints != null) {
      if (logger.isLoggable(Level.FINE)) {
          logger.log(Level.FINE,
View Full Code Here

  {
      check(requestHandle);
      if (constraints == null) {
    throw new NullPointerException("Constraints cannot be null");
      }
      InvocationConstraints result = getUnfulfilledConstraints(
    cipherSuite, clientPrincipal, serverPrincipal, constraints);
      if (result == null) {
    UnsupportedConstraintException uce =
        new UnsupportedConstraintException(
      "Constraints are not supported: " + constraints);
View Full Code Here

         */
        public boolean createObject() {
            logger.log(Level.FINE, "new InvocationConstraints(reqs, prefs)");
            logger.log(Level.FINE, "reqs :: " + reqs);
            logger.log(Level.FINE, "prefs:: " + prefs);
            InvocationConstraints ic = null;

            /*
             * Try to create InvocationConstraints object
             */
            try {
                ic = new InvocationConstraints(reqs, prefs);
            } catch (Exception e) {
                logger.log(Level.FINE,
                        "Exception has been thrown while creating"
                        + "InvocationConstraints object: " + e);
                return false;
            }

            /*
             * Get requirements from the created InvocationConstraints object
             * and compare with the requirements specified while creation of
             * this object.
             */
            Set r = ic.requirements();
            logger.log(Level.FINE,
                    "reqs in InvocationConstraints object:: " + r);

            if (!reqs.equals(r)) {
                return false;
            }

            /*
             * Get preferences from the created InvocationConstraints object
             * and compare with the preferences specified while creation of
             * this object.
             */
            Set p = ic.preferences();
            logger.log(Level.FINE,
                    "prefs in InvocationConstraints object:: " + p);

            if (!prefs.equals(p)) {
                return false;
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.