Package net.jini.security

Examples of net.jini.security.BasicProxyPreparer


    createServiceID()));

  /* Get the activation system */
  ProxyPreparer actSysPreparer = (ProxyPreparer) config.getEntry(
      "com.sun.jini.example.hello.Server", "activationSystemPreparer",
      ProxyPreparer.class, new BasicProxyPreparer());
  ActivationSystem actSys =
      (ActivationSystem) actSysPreparer.prepareProxy(
    ActivationGroup.getSystem());

  /* Create the activation group */
  ActivationGroupID gid = actSys.registerGroup(groupDesc);

  /* Create the activation descriptor */
  ActivationDesc actDesc =
      new ActivationDesc(
    gid, ActivatableServer.class.getName(),
    null /* location */, data, true /* restart */);

  /* Register the activation descriptor */
  ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
      "com.sun.jini.example.hello.Server", "activationIdPreparer",
      ProxyPreparer.class, new BasicProxyPreparer());
  ActivationID aid = (ActivationID) actIdPreparer.prepareProxy(
      actSys.registerObject(actDesc));

  /* Activate the server */
  aid.activate(true);
 
View Full Code Here


  throws ConfigurationException, RemoteException
    {
  /* Prepare the activation ID */
  ProxyPreparer actIdPreparer = (ProxyPreparer) config.getEntry(
      "com.sun.jini.example.hello.Server", "activationIdPreparer",
      ProxyPreparer.class, new BasicProxyPreparer());
  aid = (ActivationID) actIdPreparer.prepareProxy(aid);

  /* Provide the activation ID to the exporter */
  return (Exporter) config.getEntry(
      "com.sun.jini.example.hello.Server", "exporter", Exporter.class,
View Full Code Here

  }

        /* Retrieve the server proxy preparer from the configuration */
  ProxyPreparer preparer = (ProxyPreparer) config.getEntry(
      "com.sun.jini.example.hello.Client",
      "preparer", ProxyPreparer.class, new BasicProxyPreparer());

        /* Create the filter to pass to the SDM for proxy preparation */
        ServiceItemFilter filter = new ProxyPreparerFilter(preparer);

  /* Look up the remote server (SDM performs proxy preparation) */
 
View Full Code Here

  /* activation-specific initialization */
  if (activationID != null) {
      ProxyPreparer activationIdPreparer = (ProxyPreparer)
    Config.getNonNullEntry(
        config, COMPONENT, "activationIdPreparer",
        ProxyPreparer.class, new BasicProxyPreparer());
      ProxyPreparer activationSystemPreparer = (ProxyPreparer)
    Config.getNonNullEntry(
        config, COMPONENT, "activationSystemPreparer",
        ProxyPreparer.class, new BasicProxyPreparer());

      this.activationID = (ActivationID)
    activationIdPreparer.prepareProxy(activationID);
      activationSystem = (ActivationSystem)
    activationSystemPreparer.prepareProxy(
View Full Code Here

    Naming.lookup("//" + h + ":" + p +
            "/java.rmi.activation.ActivationSystem");
            ProxyPreparer activationSystemPreparer =
    (ProxyPreparer) Config.getNonNullEntry(config,
        START_PACKAGE, "activationSystemPreparer",
        ProxyPreparer.class, new BasicProxyPreparer());
      sys = (ActivationSystem) activationSystemPreparer.prepareProxy(sys);
  } catch (Exception e) {
      throw new ActivationException(
          "ActivationSystem @ " + host + ":" + port +
    " could not be obtained", e);
View Full Code Here

        /* Proxy preparers */
        registrarPreparer = (ProxyPreparer)config.getEntry
                                                   (COMPONENT_NAME,
                                                    "registrarPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        registrationPreparer = (ProxyPreparer)config.getEntry
                                                   (COMPONENT_NAME,
                                                    "registrationPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        serviceLeasePreparer = (ProxyPreparer)config.getEntry
                                                   (COMPONENT_NAME,
                                                    "serviceLeasePreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        /* Task manager */
        try {
            taskMgr = (TaskManager)config.getEntry(COMPONENT_NAME,
                                                   "taskManager",
                                                   TaskManager.class);
View Full Code Here

        listenerPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                   (config,
                                                    COMPONENT_NAME,
                                                    "listenerPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        /* Get the proxy preparers for the lookup locators to join */
        locatorToJoinPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                   (config,
                                                    COMPONENT_NAME,
                                                    "locatorToJoinPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        /* Get the proxy preparers for the lookup locators to discover */
        locatorToDiscoverPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                 (config,
                                                  COMPONENT_NAME,
                                                  "locatorToDiscoverPreparer",
                                                  ProxyPreparer.class,
                                                  new BasicProxyPreparer());
        if(persistent) {
            /* Retrieve the proxy preparers that will only be applied during
             * the state recovery process below, when any previously stored
             * listeners or locators are recovered from persistent storage.
             */
            recoveredListenerPreparer =
             (ProxyPreparer)Config.getNonNullEntry(config,
                                                   COMPONENT_NAME,
                                                   "recoveredListenerPreparer",
                                                   ProxyPreparer.class,
                                                   new BasicProxyPreparer());
            recoveredLocatorToJoinPreparer =
             (ProxyPreparer)Config.getNonNullEntry
                                             (config,
                                              COMPONENT_NAME,
                                              "recoveredLocatorToJoinPreparer",
                                              ProxyPreparer.class,
                                              new BasicProxyPreparer());
            recoveredLocatorToDiscoverPreparer =
             (ProxyPreparer)Config.getNonNullEntry
                                         (config,
                                          COMPONENT_NAME,
                                          "recoveredLocatorToDiscoverPreparer",
                                          ProxyPreparer.class,
                                          new BasicProxyPreparer());


            /* Get the log directory for persisting this service's state */
            persistDir = (String)Config.getNonNullEntry(config,
                                                        COMPONENT_NAME,
                                                        "persistenceDirectory",
                                                        String.class);
            /* Recover the state that was persisted on prior runs (if any) */
            log = new ReliableLog(persistDir, new LocalLogHandler());
            inRecovery = true;
            log.recover();
            inRecovery = false;
        }//endif(persistent)

        /* For the two persistent versions of this service (activatable and
         * non-activatable), state recovery is complete. For the non-persistent
         * version of this service, no state recovery occurred (because it
         * wasn't necessary).
         *
         * For the two persistent versions, there is a circumstance in which
         * 'one time', initial items must be retrieved from the configuration:
         * when the service is started for the very first time. For the
         * non-persistent version, those items will be retrieved every time
         * the service is started.
         *
         * The flag 'initialStartup' is used below to determine whether
         * or not to retrieve the initial configuration items. This is the
         * only purpose for that flag.
         *
         * For either persistent version of the service, the flag's value
         * will be changed to false during the startup process only when
         * there already exists a 'snapshot' of the service's state from
         * a previous run. This is because the flag's value is only
         * changed during the recovery of the snapshot (see the method
         * recoverSnapshot()). Note that the only time such a snapshot
         * should NOT already exist at startup, is when the service is
         * being started for the very first time. Thus, when either
         * persistent version of the service is started for the first
         * time, the service's configuration is consulted for the initial
         * values of the items below; otherwise, when the service is being
         * re-started (after a crash for example), the values used for
         * those items will be the values retrieved above during recovery
         * of the service's persistent state.
         *
         * With respect to the non-persistent version of the service, the
         * values of the items below will always be retrieved at startup.
         * This is because the non-persistent version of the service never
         * attempts to recover previously stored state; thus, the flag's
         * value will never change. Note that this will be true even if a
         * snapshot exists from a previous run of one of the persistent
         * versions of the service.
         *
         * The service's Uuid is also handled here.
         */
        if(initialStartup) {
            if(log != null) {
                snapshotWt = ((Float)config.getEntry
                                         (COMPONENT_NAME,
                                          "initialPersistenceSnapshotWeight",
                                          float.class,
                                          new Float(snapshotWt))).floatValue();
                snapshotThresh =
                       Config.getIntEntry
                                  (config,
                                   COMPONENT_NAME,
                                   "initialPersistenceSnapshotThreshold",
                                   snapshotThresh, 0, Integer.MAX_VALUE);
            }//endif(log != null)
            leaseBound = Config.getLongEntry(config,
                                             COMPONENT_NAME,
                                             "initialLeaseBound",
                                             leaseBound, 0, Long.MAX_VALUE);
            /* Get any additional attributes with which to associate this
             * service when registering it with any lookup services.
             */
            Entry[] initAttrs = (Entry[])config.getEntry
                                                   (COMPONENT_NAME,
                                                    "initialLookupAttributes",
                                                    Entry[].class,
                                                    null );
            if(initAttrs != null) {
                ArrayList attrsList
                   = new ArrayList(thisServicesAttrs.length+initAttrs.length);
                for(int i=0;i<thisServicesAttrs.length;i++) {
                    attrsList.add(thisServicesAttrs[i]);
                }//end loop
                for(int i=0;i<initAttrs.length;i++) {
                    attrsList.add(initAttrs[i]);
                }//end loop
                thisServicesAttrs = (Entry[])attrsList.toArray
                                                (new Entry[attrsList.size()]);
            }//endif(initAttrs != null)

            /* Get the initial groups this service should join. */
            thisServicesGroups =
                 (String[])config.getEntry(COMPONENT_NAME,
                                           "initialLookupGroups",
                                           String[].class,
                                           thisServicesGroups);
            /* Get the initial locators this service should join. */
            thisServicesLocators =
                     (LookupLocator[])config.getEntry(COMPONENT_NAME,
                                                      "initialLookupLocators",
                                                      LookupLocator[].class,
                                                      new LookupLocator[0]);
            if(thisServicesLocators == null) {
                thisServicesLocators = new LookupLocator[0];
            }//endif

            /* Generate the private, universally unique (over space and time)
             * ID that will be used by the outer proxy to test for equality
             * with other proxies.
             */
            proxyID = UuidFactory.generate();
        }//endif(initialStartup)

        /* The proxyID should never be null at this point. It should have
         * been either recovered from the persisted state, or generated above.
         */
        if(proxyID == null) throw new NullPointerException("proxyID == null");

        /* Get the various configurable constants */
        leaseMax = Config.getLongEntry(config,
                                       COMPONENT_NAME,
                                       "leaseMax",
                                       leaseMax, 0, Long.MAX_VALUE);
        /* Take a snapshot of the current state to "clean up" the log file,
         * and to record the items set above.
         */
  if(log != null) log.snapshot();
        /* The service ID used to register this service with lookup services
         * is always derived from the proxyID that is associated with the
         * service for the lifetime of the service.
         */
        serviceID = new ServiceID(proxyID.getMostSignificantBits(),
                                  proxyID.getLeastSignificantBits());
        /* Get a general-purpose task manager for this service */
        taskMgr = (TaskManager)Config.getNonNullEntry
                                          (config,
                                           COMPONENT_NAME,
                                           "taskManager",
                                           TaskManager.class,
                                           new TaskManager(10,1000*15,1.0f) );
        /* Get the discovery manager to pass to this service's join manager. */
        try {
            joinMgrLDM  =
                (DiscoveryManagement)Config.getNonNullEntry
                                                  (config,
                                                   COMPONENT_NAME,
                                                   "discoveryManager",
                                                   DiscoveryManagement.class);
            if( joinMgrLDM instanceof DiscoveryGroupManagement ) {
                String[] groups0 =
                           ((DiscoveryGroupManagement)joinMgrLDM).getGroups();
                if(    (groups0 == DiscoveryGroupManagement.ALL_GROUPS)
                    || (groups0.length != 0) )
                {
                    throw new ConfigurationException
                                 ("discoveryManager entry must be configured "
                                  +"to initially discover/join NO_GROUPS");
                }//endif
            } else {// !(joinMgrLDM instanceof DiscoveryGroupManagement)
                throw new ConfigurationException
                                       ("discoveryManager entry must "
                                        +"implement DiscoveryGroupManagement");
            }//endif
            if( joinMgrLDM instanceof DiscoveryLocatorManagement ) {
                LookupLocator[] locs0 =
                        ((DiscoveryLocatorManagement)joinMgrLDM).getLocators();
                if( (locs0 != null) && (locs0.length != 0) ) {
                    throw new ConfigurationException
                                 ("discoveryManager entry must be configured "
                                  +"to initially discover/join no locators");
                }//endif
            } else {// !(joinMgrLDM instanceof DiscoveryLocatorManagement)
                throw new ConfigurationException
                                     ("discoveryManager entry must "
                                      +"implement DiscoveryLocatorManagement");
            }//endif
        } catch (NoSuchEntryException e) {
            joinMgrLDM
               = new LookupDiscoveryManager(DiscoveryGroupManagement.NO_GROUPS,
                                            new LookupLocator[0], null,config);
        }

        /* Handle items and duties related to exporting this service. */
        ServerEndpoint endpoint = TcpServerEndpoint.getInstance(0);
        InvocationLayerFactory ilFactory = new BasicILFactory();
        Exporter defaultExporter = new BasicJeriExporter(endpoint,
                                                         ilFactory,
                                                         false,
                                                         true);
        /* For the activatable server */
        if(activationID != null) {
            ProxyPreparer aidPreparer =
              (ProxyPreparer)Config.getNonNullEntry(config,
                                                    COMPONENT_NAME,
                                                    "activationIdPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
            ProxyPreparer aSysPreparer =
              (ProxyPreparer)Config.getNonNullEntry(config,
                                                    COMPONENT_NAME,
                                                    "activationSystemPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
            activationID = (ActivationID)aidPreparer.prepareProxy
                                                               (activationID);
            activationSystem = (ActivationSystem)aSysPreparer.prepareProxy
                                                            (activationSystem);
            defaultExporter = new ActivationExporter(activationID,
View Full Code Here

            if (testCase > 10) {
                verify = true;
                testCase -= 10;
            }
           
            BasicProxyPreparer bpp = callConstructor(
                    testCase, verify, mc, perm);
            bpp.hashCode()
        }           
    }
View Full Code Here

            if (testCase > 10) {
                verify = true;
                testCase -= 10;
            }
           
            BasicProxyPreparer bpp = callConstructor(
                    testCase, verify, mc, perm);
            if (bpp.toString().length() == 0){
                throw new TestException(
                        "toString method should return non empty string");
            }
        }           
    }
View Full Code Here

            int testCase,
            boolean verify,
            MethodConstraints methodConstraints,
            Permission[] permissions) {
        if (testCase == 0) { // constructor without arguments
            return new BasicProxyPreparer();
        } else if (testCase == 2) { // constructor with 2 arguments
            return new BasicProxyPreparer(verify, permissions);
        } else { // constructor with 3 arguments
            return new BasicProxyPreparer(verify,
                    methodConstraints, permissions);
        }
    }
View Full Code Here

TOP

Related Classes of net.jini.security.BasicProxyPreparer

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.