當前位置: 首頁>>代碼示例>>Java>>正文


Java RMISecurityManager類代碼示例

本文整理匯總了Java中java.rmi.RMISecurityManager的典型用法代碼示例。如果您正苦於以下問題:Java RMISecurityManager類的具體用法?Java RMISecurityManager怎麽用?Java RMISecurityManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RMISecurityManager類屬於java.rmi包,在下文中一共展示了RMISecurityManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findTransactionManager

import java.rmi.RMISecurityManager; //導入依賴的package包/類
private TransactionManager findTransactionManager(String uri) throws IOException, ClassNotFoundException {
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    // Creating service template to find transaction manager service by matching fields.
    Class<?>[] classes = new Class<?>[] {net.jini.core.transaction.server.TransactionManager.class};
    // Name sn = new Name("*");
    ServiceTemplate tmpl = new ServiceTemplate(null, classes, new Entry[] {});

    // Creating a lookup locator
    LookupLocator locator = new LookupLocator(uri);
    ServiceRegistrar sr = locator.getRegistrar();

    TransactionManager tm = (TransactionManager) sr.lookup(tmpl);
    return tm;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:TransactionHelper.java

示例2: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public static void main(String[] args) throws Throwable {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    System.out.print("login: ");
    String login = br.readLine();
    System.out.println();

    System.out.print("password: ");
    String password = br.readLine();
    System.out.println();

    AuthRMIClientSocketFactory.setHostAuthData("127.0.0.1",
            new AuthData(login, password));

    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    TestController test = (TestController) Naming.lookup(TestController.RMI_BINDING_NAME);

    System.out.println(test.f());
}
 
開發者ID:yashprit,項目名稱:rmi-auth,代碼行數:24,代碼來源:Main.java

示例3: runTestSingle

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * Runs test server process.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runTestSingle(int config) throws Exception {
    try {
        System.err.println("Test server started.");
        System.setSecurityManager(new RMISecurityManager());
        setEnvironmentForConfig(config);
        initServer();
        mainTestBody();
        System.err.println("Test server complete.");
        SubProcess.tellOut();
    } finally {
        System.err.println("Test server closing.");
        unexportObjects();
    }
    System.err.println("Test server exiting.");
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:ConnectionTest.java

示例4: runRegistry

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * Runs registry process, wait for READY and exits with export
 * or stays on if input stream is closed.
 *
 * @param   config
 *          Number of the configuration to run.
 *
 * @throws  Exception
 *          If some error occurs.
 */
private void runRegistry(int config) throws Exception {
    System.err.println("Registry starting");
    System.setSecurityManager(new RMISecurityManager());
    setEnvironmentForConfig(config);
    Registry reg = LocateRegistry.createRegistry(REGISTRY_PORT);
    System.err.println("Registry initialized, telling READY to parent");
    SubProcess.tellOut();
    System.err.println("Expecting READY from parent");

    try {
        SubProcess.expectIn();
        UnicastRemoteObject.unexportObject(reg, true);
        System.err.println("Registry exiting");
    } catch (EOFException e) {
        System.err.println("EOFException caught, registry stays on");
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:28,代碼來源:DGCTest.java

示例5: ContextScriptView

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * Constructor for creating the context view panel
 * 
 * @param dispatcher
 *            Remote dispatcher to use.
 */
public ContextScriptView(SignatureDispatchment dispatcher, BrowserModel model) {
	super(new BorderLayout());
	// needed for exerting the service
	this.model = model;
	if (System.getSecurityManager() == null)
		System.setSecurityManager(new RMISecurityManager());

	if (dispatcher instanceof SignatureDispatcherForProvider)
		provider = ((SignatureDispatcherForProvider)dispatcher).getProvider();
	else
		provider = ((SignatureDispatcherForCataloger)dispatcher).getProvider();
	
	tabbedPane = new JTabbedPane();

	inViewer = new EditorView("", false);
	
	tabbedPane.addTab("Browser", null,
			createBrowserPanel(null), "Browser");
	add(tabbedPane, BorderLayout.CENTER);
}
 
開發者ID:mwsobol,項目名稱:SORCER,代碼行數:27,代碼來源:ContextScriptView.java

示例6: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public static void main(String[] args) throws RemoteException,
		MalformedURLException {
	System.setSecurityManager(new RMISecurityManager() {
		public void checkPermission(Permission perm) {
		};
	});
	try {
		ReportIPServer.setServerHost(System
				.getProperty("java.rmi.server.hostname"));
	} catch (UnknownHostException e2) {
		e2.printStackTrace();
		System.exit(1);
	}
	initRegistry();
	exportExecutor();
	/*
	 * This is just to avoid the Registry from being Garbage Collected.
	 */
	while (true) {
		try {
			ReportIPServer.doit();
			Thread.sleep(SLEEP_MINUTES * 6000);
		} catch (InterruptedException e) {
		}
	}
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:27,代碼來源:ClientExecutor.java

示例7: LoadClassStringString

import java.rmi.RMISecurityManager; //導入依賴的package包/類
private void LoadClassStringString(String clase, boolean url) {
    SecurityManager smOld = System.getSecurityManager();
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        }
    });
    try {
        if (url) {
            RMIClassLoader.loadClass(new URL("file://" + pathOwnClass),
                    clase);
        } else {
            RMIClassLoader.loadClass("file://" + pathOwnClass, clase);
        }
    } catch (Throwable e) {
        fail("Failed with: " + e);
    } finally {
        System.setSecurityManager(smOld);
    }

}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:21,代碼來源:TestRMIClassLoader.java

示例8: testLoadClassStringStringClassLoader006

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public final void testLoadClassStringStringClassLoader006() {
    SecurityManager smOld = System.getSecurityManager();
    System.setSecurityManager(new RMISecurityManager() {
        public void checkPermission(Permission perm) {
        }
    });
    try {
        RMIClassLoader
                .loadClass(
                        "file://" + pathOwnClass,
                        "ar.org.fitc.test.rmi.server.testclasses.LoaderClassTest001",
                        null);
    } catch (Throwable e) {
        fail("Should not raise an exception but raised: " + e);
    } finally {
        System.setSecurityManager(smOld);
    }
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:19,代碼來源:TestRMIClassLoader.java

示例9: test

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public int test(final String host, final int port) {

        System.setProperty("java.security.policy", "NoPolicy!");
        Policy.getPolicy().refresh();
        System.setSecurityManager(new RMISecurityManager());
        try {
            ServerInterface obj = (ServerInterface) Naming.lookup("rmi://"
                    + host + ":" + port + "/Server");
            obj.remoteMethod("1 v pole ne voin");
            System.out.println("SecurityException wasn't thrown");

            return Result.FAIL;
        } catch (Throwable ex) {
            Throwable th = ex;
            while (th != null) {
                if (th instanceof SecurityException) {
                    return Result.PASS;
                }
                th = th.getCause();
            }
            ex.printStackTrace();
            return Result.FAIL;
        }
    }
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:25,代碼來源:BSTest.java

示例10: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * This main program registers an instance of MovieDatabaseImpl in
 * an RMI registry.
 */
public static void main(String[] args) {
  String host = args[0];
  int port = Integer.parseInt(args[1]);

  // Install an RMISecurityManager, if there is not a
  // SecurityManager already installed
  if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
  }

  String name = "rmi://" + host + ":" + port + "/MovieDatabase";

  try {
    MovieDatabase db  = new MovieDatabaseImpl();
    Naming.rebind(name, db);

  } catch (RemoteException | MalformedURLException ex) {
    ex.printStackTrace(System.err);
  }

}
 
開發者ID:DavidWhitlock,項目名稱:PortlandStateJava,代碼行數:26,代碼來源:MovieDatabaseImpl.java

示例11: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public static void main(String[] args) {
  String host = args[0];
  int port = Integer.parseInt(args[1]);
  Long actor = Long.parseLong(args[2]);

  // Install an RMISecurityManager, if there is not a
  // SecurityManager already installed
  if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
  }

  String name = "rmi://" + host + ":" + port + "/MovieDatabase";

  try {
    MovieDatabase db = 
      (MovieDatabase) Naming.lookup(name);
    db.getFilmography(actor).forEach(System.out::println);

  } catch (RemoteException | NotBoundException | MalformedURLException ex) {
    ex.printStackTrace(System.err);
  }

}
 
開發者ID:DavidWhitlock,項目名稱:PortlandStateJava,代碼行數:24,代碼來源:GetFilmography.java

示例12: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * Basic server main.  This class is executable with a command line
 * something like this:
 * 
 * java -Djava.rmi.server.codebase="base.of.classpath" \
 *      -cp ".;../../../../common/lib/xerces.jar" \
 *      -Djava.security.policy=rmi.policy \
 *      -DdatabasesFile=../databases.xml \
 *      ca.sqlpower.sql.DBConnectionSpecServerImpl
 */
public static void main(String args[]) throws RemoteException{

	// Create and install a security manager
	if (System.getSecurityManager() == null) {
		System.setSecurityManager(new RMISecurityManager());
	}

	DBConnectionSpecServerImpl obj =
			new DBConnectionSpecServerImpl();

	obj.xmlFileName = System.getProperty("databasesFile");
	if (obj.xmlFileName == null) {
		System.out.println(
			"no databases file specified.  Please add -DdatabaseFile=filename to the command line.");
	} else {
		try {
			java.rmi.registry.LocateRegistry.createRegistry(1099);
			Naming.rebind("///DBConnectionSpecServer", obj);
			System.out.println("DBConnectionSpecServer bound in registry");
		} catch (Exception e) {
			System.out.println(
				"DBConnectionSpecImpl err: " + e.getMessage());
			e.printStackTrace();
		}
	}
}
 
開發者ID:SQLPower,項目名稱:sqlpower-library,代碼行數:37,代碼來源:DBConnectionSpecServerImpl.java

示例13: securitySetup

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public static void securitySetup() {
	System.setProperty("java.security.policy","file:./my.policy");
	// Create and install a security manager
	if (System.getSecurityManager() == null) {
		System.setSecurityManager(new RMISecurityManager());
	}
}
 
開發者ID:erwinvaneyk,項目名稱:Dragons-Arena,代碼行數:8,代碼來源:Server.java

示例14: main

import java.rmi.RMISecurityManager; //導入依賴的package包/類
public static void main(String[] args) throws Throwable {
    // Create and install a security manager
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new RMISecurityManager());
    }

    Naming.rebind(TestController.RMI_BINDING_NAME,
            new TestControllerRmiImpl(TestController.PORT, csf, ssf));

    while (true) {
        Thread.sleep(100);
    }
}
 
開發者ID:yashprit,項目名稱:rmi-auth,代碼行數:14,代碼來源:Main.java

示例15: setupSecurity

import java.rmi.RMISecurityManager; //導入依賴的package包/類
/**
 * Set up security manager and policy, if not set already.
 */
static void setupSecurity() {
    if (System.getSecurityManager() != null)
        return;

    /* As of 1.4, it is too late to set the security policy
     * file at this point so these line have been commented out.
     */
    //System.setProperty("java.security.policy",
    //      Main.class.getResource("/bench/rmi/policy.all").toString());
    System.setSecurityManager(new RMISecurityManager());
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:15,代碼來源:Main.java


注:本文中的java.rmi.RMISecurityManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。