Package org.apache.geronimo.gbean.jmx

Examples of org.apache.geronimo.gbean.jmx.GBeanMBean


        final Kernel kernel = new Kernel("geronimo.kernel", "geronimo");
        try {
            kernel.boot();

            GBeanMBean config;
            ObjectInputStream ois = new ObjectInputStream(cl.getResourceAsStream("META-INF/config.ser"));
            try {
                GBeanData gbeanData = new GBeanData();
                gbeanData.readExternal(ois);
                config = new GBeanMBean(gbeanData, cl);
            } finally {
                ois.close();
            }
            final ObjectName configName = kernel.getConfigurationManager().load(config, cl.getResource("/"));
View Full Code Here


    protected ObjectName propertiesCE;

    public void setUp() throws Exception {
        super.setUp();

        GBeanMBean gbean;

        gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
        gbean.setAttribute("baseDirectory", ".");
        kernel.loadGBean(serverInfo, gbean);
        kernel.startGBean(serverInfo);

        gbean = new GBeanMBean("org.apache.geronimo.security.jaas.GeronimoLoginConfiguration");
        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
        kernel.loadGBean(loginConfiguration, gbean);

        gbean = new GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
        propertiesRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=properties-realm");
        gbean.setAttribute("realmName", "properties-realm");
        gbean.setAttribute("maxLoginModuleAge", new Long(1 * 1000));
        gbean.setAttribute("usersURI", (new File(new File("."), "src/test-data/data/users.properties")).toURI());
        gbean.setAttribute("groupsURI", (new File(new File("."), "src/test-data/data/groups.properties")).toURI());
        gbean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfo));
        kernel.loadGBean(propertiesRealm, gbean);

        gbean = new GBeanMBean("org.apache.geronimo.security.jaas.ConfigurationEntryRealmLocal");
        propertiesCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=properties");
        gbean.setAttribute("applicationConfigName", "properties");
        gbean.setAttribute("realmName", "properties-realm");
        gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
        gbean.setAttribute("options", new Properties());
        kernel.loadGBean(propertiesCE, gbean);

        kernel.startGBean(loginConfiguration);
        kernel.startGBean(propertiesRealm);
        kernel.startGBean(propertiesCE);
View Full Code Here

        conn.prepareStatement("INSERT INTO Groups VALUES ('dog', 'gracie');").executeUpdate();
        conn.prepareStatement("INSERT INTO Groups VALUES ('cat', 'metro');").executeUpdate();

        conn.close();

        GBeanMBean gbean = new GBeanMBean("org.apache.geronimo.security.realm.providers.SQLSecurityRealm");
        sqlRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=sql-realm");
        gbean.setAttribute("realmName", "sql-realm");
        gbean.setAttribute("maxLoginModuleAge", new Long(1 * 1000));
        gbean.setAttribute("connectionURL", hsqldbURL);
        gbean.setAttribute("user", "loginmodule");
        gbean.setAttribute("password", "password");
        gbean.setAttribute("userSelect", "SELECT UserName, Password FROM Users");
        gbean.setAttribute("groupSelect", "SELECT GroupName, UserName FROM Groups");
        kernel.loadGBean(sqlRealm, gbean);
        kernel.startGBean(sqlRealm);
    }
View Full Code Here

        realm.getPrincipals().add(principal);
        role.getRealms().add(realm);

        securityConfig.getRoleMappings().add(role);

        GBeanMBean app = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO);

        app.setAttribute("kernel", kernel);
        app.setAttribute("uri", URI.create("war3/"));
        app.setAttribute("componentContext", null);
        OnlineUserTransaction userTransaction = new OnlineUserTransaction();
        app.setAttribute("userTransaction", userTransaction);
        app.setAttribute("webClassPath", new URI[0]);
        app.setAttribute("contextPriorityClassLoader", Boolean.FALSE);
        app.setAttribute("configurationBaseUrl", Thread.currentThread().getContextClassLoader().getResource("deployables/"));
        app.setAttribute("securityConfig", securityConfig);
        app.setAttribute("policyContextID", "TEST");

        app.setAttribute("contextPath", "/test");

        app.setReferencePattern("TransactionContextManager", tcmName);
        app.setReferencePattern("TrackedConnectionAssociator", tcaName);
        app.setReferencePatterns("JettyContainer", containerPatterns);
        start(appName, app);

        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
        connection.setInstanceFollowRedirects(false);
        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
View Full Code Here

    protected ObjectName simpleCE;

    public void setUp() throws Exception {
        super.setUp();

        GBeanMBean gbean;

        gbean = new GBeanMBean(ServerInfo.GBEAN_INFO);
        serverInfo = new ObjectName("geronimo.system:role=ServerInfo");
        gbean.setAttribute("baseDirectory", ".");
        kernel.loadGBean(serverInfo, gbean);
        kernel.startGBean(serverInfo);

        gbean = new GBeanMBean("org.apache.geronimo.security.jaas.GeronimoLoginConfiguration");
        loginConfiguration = new ObjectName("geronimo.security:type=LoginConfiguration");
        kernel.loadGBean(loginConfiguration, gbean);

        Properties options = new Properties();
        options.put("group", "it");

        gbean = new GBeanMBean("org.apache.geronimo.security.realm.providers.SimpleSecurityRealm");
        simpleRealm = new ObjectName("geronimo.security:type=SecurityRealm,realm=simple-realm");
        gbean.setAttribute("realmName", "simple-realm");
        gbean.setAttribute("loginModuleName", TestLoginModule.class.getName());
        gbean.setAttribute("options", options);
        gbean.setAttribute("maxLoginModuleAge", new Long(24 * 60 * 60 * 1000));
        kernel.loadGBean(simpleRealm, gbean);

        gbean = new GBeanMBean("org.apache.geronimo.security.jaas.ConfigurationEntryRealmLocal");
        simpleCE = new ObjectName("geronimo.security:type=ConfigurationEntry,jaasId=properties");
        gbean.setAttribute("applicationConfigName", "simple");
        gbean.setAttribute("realmName", "simple-realm");
        gbean.setAttribute("controlFlag", LoginModuleControlFlag.REQUIRED);
        gbean.setAttribute("options", new Properties());
        kernel.loadGBean(simpleCE, gbean);

        kernel.startGBean(loginConfiguration);
        kernel.startGBean(simpleRealm);
        kernel.startGBean(simpleCE);
View Full Code Here

        tcaName = new ObjectName("geronimo.test:role=ConnectionTrackingCoordinator");

        kernel = new Kernel("geronimo.kernel", "test");
        kernel.boot();
        mbServer = kernel.getMBeanServer();
        container = new GBeanMBean(JettyContainerImpl.GBEAN_INFO);

        serverInfoGBean = new GBeanMBean(ServerInfo.GBEAN_INFO);
        serverInfoName = new ObjectName("geronimo.system:role=ServerInfo");
        serverInfoGBean.setAttribute("baseDirectory", ".");

        connectorGBean = new GBeanMBean(HTTPConnector.GBEAN_INFO);
        connectorGBean.setAttribute("port", new Integer(5678));
        connectorGBean.setReferencePatterns("JettyContainer", containerPatterns);

        jaasRealmGBean = new GBeanMBean("org.apache.geronimo.jetty.JAASJettyRealm");
        jaasRealmName = new ObjectName("geronimo.jetty:role=JaasRealm");
        jaasRealmGBean.setReferencePatterns("JettyContainer", containerPatterns);
        jaasRealmGBean.setAttribute("name", "Test JAAS Realm");
        jaasRealmGBean.setAttribute("loginModuleName", "jaasTest");

        securityServiceGBean = new GBeanMBean("org.apache.geronimo.security.SecurityService");
        securityServiceName = new ObjectName("geronimo.security:type=SecurityService");
        securityServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
        securityServiceGBean.setAttribute("policyConfigurationFactory", "org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory");

        loginServiceGBean = new GBeanMBean("org.apache.geronimo.security.jaas.LoginService");
        loginServiceName = new ObjectName("geronimo.security:type=LoginService");
        loginServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
        loginServiceGBean.setAttribute("reclaimPeriod", new Long(1000 * 1000));
        loginServiceGBean.setAttribute("algorithm", "HmacSHA1");
        loginServiceGBean.setAttribute("password", "secret");

        propertiesRealmGBean = new GBeanMBean("org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm");
        propertiesRealmName = new ObjectName("geronimo.security:type=SecurityRealm,realm=demo-properties-realm");
        propertiesRealmGBean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfoName));
        propertiesRealmGBean.setAttribute("realmName", "demo-properties-realm");
        propertiesRealmGBean.setAttribute("maxLoginModuleAge", new Long(1 * 1000));
        propertiesRealmGBean.setAttribute("usersURI", (new File(new File("."), "src/test-resources/data/users.properties")).toURI());
        propertiesRealmGBean.setAttribute("groupsURI", (new File(new File("."), "src/test-resources/data/groups.properties")).toURI());

        start(serverInfoName, serverInfoGBean);
        start(propertiesRealmName, propertiesRealmGBean);
        start(containerName, container);
        start(securityServiceName, securityServiceGBean);
        start(loginServiceName, loginServiceGBean);
        start(jaasRealmName, jaasRealmGBean);
        start(connectorName, connectorGBean);

        tm = new GBeanMBean(GeronimoTransactionManager.GBEAN_INFO);
        tm.setAttribute("defaultTransactionTimeoutSeconds", new Integer(10));
        Set patterns = new HashSet();
        patterns.add(ObjectName.getInstance("geronimo.server:j2eeType=JCAManagedConnectionFactory,*"));
        tm.setReferencePatterns("ResourceManagers", patterns);
        start(tmName, tm);
        tcm = new GBeanMBean(TransactionContextManager.GBEAN_INFO);
        tcm.setReferencePattern("TransactionManager", tmName);
        start(tcmName, tcm);
        ctc = new GBeanMBean(ConnectionTrackingCoordinator.GBEAN_INFO);
        start(tcaName, ctc);
    }
View Full Code Here

        kernel.invoke(storeName, "install", new Object[] {source}, new String[] {"java.net.URL"});
        assertTrue(new File(root, "1/META-INF/config.ser").exists());
        assertEquals(new File(root, "1").toURL(),
            kernel.invoke(storeName, "getBaseURL", new Object[] {uri}, new String[] {"java.net.URI"}));

        GBeanMBean config = (GBeanMBean) kernel.invoke(storeName, "getConfiguration", new Object[] {uri}, new String[] {"java.net.URI"});
        assertEquals(uri, config.getAttribute("ID"));
    }
View Full Code Here

        try {
            kernel = new Kernel("test.kernel", "geronimo");
            kernel.boot();

            gbeanName1 = new ObjectName("geronimo.test:name=MyMockGMBean1");
            GBeanMBean mockBean1 = new GBeanMBean(MockGBean.getGBeanInfo());
            mockBean1.setAttribute("value", "1234");

            gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2");
            GBeanMBean mockBean2 = new GBeanMBean(MockGBean.getGBeanInfo());
            mockBean2.setAttribute("gbeanEnabled", Boolean.FALSE);
            mockBean2.setAttribute("value", "1234");

            Map gbeans = new HashMap();
            gbeans.put(gbeanName1, mockBean1);
            gbeans.put(gbeanName2, mockBean2);
            state = Configuration.storeGBeans(gbeans);

            root = new File(System.getProperty("java.io.tmpdir") + "/config-store");
            recursiveDelete(root);
            root.mkdir();

            storeName = new ObjectName("geronimo.test:role=ConfigurationStore,name=LocalConfigStore");
            GBeanData store = new GBeanData(storeName, LocalConfigStore.getGBeanInfo());
            store.setAttribute("root", root.toURI());

            kernel.loadGBean(store, getClass().getClassLoader());
            kernel.startGBean(storeName);

            GBeanMBean gbean = new GBeanMBean(Configuration.GBEAN_INFO);
            uri = new URI("test");
            gbean.setAttribute("ID", uri);
            gbean.setAttribute("gBeanState", state);


            sourceFile = File.createTempFile("test", ".car");
            source = sourceFile.toURL();
            JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(sourceFile)));
            jos.putNextEntry(new ZipEntry("META-INF/config.ser"));
            ObjectOutputStream oos = new ObjectOutputStream(jos);
            gbean.getGBeanData().writeExternal(oos);
            oos.flush();
            jos.closeEntry();
            jos.close();
        } catch (Exception e) {
            if (sourceFile != null) {
View Full Code Here

public class AppClientBuilderTest extends TestCase {

    public void testAppClientGBean() throws Exception {
        Kernel kernel = new Kernel("testDomain");
        kernel.boot();
        GBeanMBean gbean = new GBeanMBean(AppClientModuleBuilder.class.getName(), AppClientModuleBuilder.class.getClassLoader());
        kernel.loadGBean(new ObjectName("testDomain:test=test"), gbean);

    }
View Full Code Here

            is.close();
        }

        URI configId;
        try {
            GBeanMBean config = loadConfig(configurationDir);
            configId = (URI) config.getAttribute("ID");
            index.setProperty(configId.toString(), configurationDir.getName());
        } catch (Exception e) {
            delete(configurationDir);
            throw new InvalidConfigException("Unable to get ID from downloaded configuration", e);
        }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gbean.jmx.GBeanMBean

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.