Package org.apache.geronimo.gbean

Examples of org.apache.geronimo.gbean.GBeanData$PriorityComparator


            virtualHosts[i] = virtualHosts[i].trim();
        }
        if (hosts.length > 0 || virtualHosts.length > 0) {
            //use name same as module
            AbstractName hostName = earContext.getNaming().createChildName(webModuleData.getAbstractName(), "Host", "Host");
            GBeanData hostData = new GBeanData(hostName, Host.GBEAN_INFO);
            hostData.setAttribute("hosts", hosts);
            hostData.setAttribute("virtualHosts", virtualHosts);
            earContext.addGBean(hostData);
            webModuleData.setReferencePattern("Host", hostName);
        }
    }
View Full Code Here


            Set securityRoles,
            Map rolePermissions,
            EARContext moduleContext) throws DeploymentException {
        String servletName = servletType.getServletName().getStringValue().trim();
        AbstractName servletAbstractName = moduleContext.getNaming().createChildName(webModuleName, servletName, NameFactory.SERVLET);
        GBeanData servletData;
        Map initParams = new HashMap();
        if (servletType.isSetServletClass()) {
            ClassLoader webClassLoader = moduleContext.getClassLoader();
            String servletClassName = servletType.getServletClass().getStringValue().trim();
            Class servletClass;
            try {
                servletClass = webClassLoader.loadClass(servletClassName);
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("Could not load servlet class " + servletClassName, e); // TODO identify web app in message
            }
            Class baseServletClass;
            try {
                baseServletClass = webClassLoader.loadClass(Servlet.class.getName());
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("Could not load javax.servlet.Servlet in web classloader", e); // TODO identify web app in message
            }
            if (baseServletClass.isAssignableFrom(servletClass)) {
                servletData = new GBeanData(servletAbstractName, JettyServletHolder.GBEAN_INFO);
                servletData.setAttribute("servletClass", servletClassName);
            } else {
                servletData = new GBeanData(pojoWebServiceTemplate);
                servletData.setAbstractName(servletAbstractName);
                //let the web service builder deal with configuring the gbean with the web service stack
//                Object portInfo = portMap.get(servletName);
//                if (portInfo == null) {
//                    throw new DeploymentException("No web service deployment info for servlet name " + servletName); // TODO identify web app in message
//                }
                boolean configured = false;
                for (Iterator iterator = webServiceBuilder.iterator(); iterator.hasNext();) {
                    WebServiceBuilder serviceBuilder = (WebServiceBuilder) iterator.next();
                    if (serviceBuilder.configurePOJO(servletData, servletName, module, servletClassName, moduleContext)) {
                        configured = true;
                        break;
                    }
                }
                if (!configured) {
                    throw new DeploymentException("POJO web service: " + servletName + " not configured by any web service builder");
                }
            }
        } else if (servletType.isSetJspFile()) {
            servletData = new GBeanData(servletAbstractName, JettyServletHolder.GBEAN_INFO);
            servletData.setAttribute("jspFile", servletType.getJspFile().getStringValue().trim());
            //TODO MAKE THIS CONFIGURABLE!!! Jetty uses the servlet mapping set up from the default-web.xml
            servletData.setAttribute("servletClass", jspServletClassName);
            initParams.put("development", "false");
        } else {
            throw new DeploymentException("Neither servlet class nor jsp file is set for " + servletName); // TODO identify web app in message
        }

        // link to previous servlet, if there is one, so that we
        // preserve the <load-on-startup> ordering.
        // http://issues.apache.org/jira/browse/GERONIMO-645
        if (null != previousServlet) {
            servletData.addDependency(previousServlet);
        }

        //TODO in init param setter, add classpath if jspFile is not null.
        servletData.setReferencePattern("JettyServletRegistration", webModuleName);
        servletData.setAttribute("servletName", servletName);
        ParamValueType[] initParamArray = servletType.getInitParamArray();
        for (int j = 0; j < initParamArray.length; j++) {
            ParamValueType paramValueType = initParamArray[j];
            initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim());
        }
        servletData.setAttribute("initParams", initParams);
        if (servletType.isSetLoadOnStartup()) {
            Integer loadOnStartup = new Integer(servletType.xgetLoadOnStartup().getStringValue());
            servletData.setAttribute("loadOnStartup", loadOnStartup);
        }

        Set mappings = (Set) servletMappings.get(servletName);
        servletData.setAttribute("servletMappings", mappings == null ? Collections.EMPTY_SET : mappings);

        //run-as
        if (servletType.isSetRunAs()) {
            servletData.setAttribute("runAsRole", servletType.getRunAs().getRoleName().getStringValue().trim());
        }

        processRoleRefPermissions(servletType, securityRoles, rolePermissions);

        try {
View Full Code Here

            try {
                configurationObjectName = Configuration.getConfigurationObjectName(configId);
            } catch (MalformedObjectNameException e) {
                throw new InvalidConfigException(e);
            }
            GBeanData configData = new GBeanData(configurationObjectName, Configuration.GBEAN_INFO);
            configData.setAttribute("id", configId);
            configData.setAttribute("domain", "test");
            configData.setAttribute("server", "bar");
            configData.setAttribute("gBeanState", NO_OBJECTS_OS);

            try {
                kernel.loadGBean(configData, Configuration.class.getClassLoader());
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to register configuration", e);
View Full Code Here

                    try {
                        loginModuleName = NameFactory.getComponentName(null, null, null, null, name, NameFactory.LOGIN_MODULE, j2eeContext);
                    } catch (MalformedObjectNameException e) {
                        throw new DeploymentException("cannot construct login module use name from parts,", e);
                    }
                    GBeanData loginModuleGBeanData = new GBeanData(loginModuleName, LoginModuleGBean.GBEAN_INFO);
                    loginModuleGBeanData.setAttribute("loginDomainName", name);
                    loginModuleGBeanData.setAttribute("loginModuleClass", className);
                    loginModuleGBeanData.setAttribute("options", options);
                    loginModuleGBeanData.setAttribute("serverSide", new Boolean(serverSide));

                    context.addGBean(loginModuleGBeanData);
                } else {
                    throw new DeploymentException("Unknown abstract login module type: " + abstractLoginModule.getClass());
                }
                ObjectName thisName;
                try {
                    thisName = NameFactory.getComponentName(null, null, null, null, name, "LoginModuleUse", j2eeContext);
                } catch (MalformedObjectNameException e) {
                    throw new DeploymentException("cannot construct login module use name from parts,", e);
                }
                GBeanData loginModuleUseGBeanData = new GBeanData(thisName, JaasLoginModuleUse.GBEAN_INFO);
                loginModuleUseGBeanData.setAttribute("controlFlag", controlFlag);
                loginModuleUseGBeanData.setReferencePattern("LoginModule", loginModuleName);
                if (nextName != null) {
                    loginModuleUseGBeanData.setReferencePattern("Next", nextName);
                }
                context.addGBean(loginModuleUseGBeanData);
                nextName = thisName;
            }
        } finally {
View Full Code Here

    private ObjectName serverInfoName;
    private GBeanData serverInfoGBean;

    protected void setUpInsecureAppContext() throws Exception {

        GBeanData app = new GBeanData(webModuleName, TomcatWebAppContext.GBEAN_INFO);
        app.setAttribute("webAppRoot", new File("target/var/catalina/webapps/war1/").toURI());
        app.setAttribute("webClassPath", new URI[]{});
        app.setAttribute("configurationBaseUrl", new File("target/var/catalina/webapps/war1/WEB-INF/web.xml").toURL());
        app.setAttribute("componentContext", Collections.EMPTY_MAP);
        app.setReferencePattern("Container", containerName);
        OnlineUserTransaction userTransaction = new OnlineUserTransaction();
        app.setAttribute("userTransaction", userTransaction);
        app.setReferencePattern("TransactionContextManager", tcmName);
        app.setReferencePattern("TrackedConnectionAssociator", ctcName);
        app.setAttribute("contextPath", "/test");

        start(app);
    }
View Full Code Here

    }

    protected void setUpJAASSecureAppContext() throws Exception {
        //Will use Context Level Security
        ObjectName jaccBeanName = NameFactory.getComponentName(null, null, null, null, "foo", NameFactory.JACC_MANAGER, moduleContext);
        GBeanData jaccBeanData = new GBeanData(jaccBeanName, ApplicationPolicyConfigurationManager.GBEAN_INFO);
        PermissionCollection excludedPermissions= new Permissions();
        PermissionCollection uncheckedPermissions= new Permissions();
        ComponentPermissions componentPermissions = new ComponentPermissions(excludedPermissions, uncheckedPermissions, new HashMap());
        Map contextIDToPermissionsMap = new HashMap();
        contextIDToPermissionsMap.put(POLICY_CONTEXT_ID, componentPermissions);
        jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap);
        jaccBeanData.setAttribute("principalRoleMap", new HashMap());
        jaccBeanData.setAttribute("roleDesignates", new HashMap());
        start(jaccBeanData);

        //Set a context level Realm and ignore the Engine level to test that
        //the override along with a Security Realm Name set overrides the Engine
        Map initParams = new HashMap();
        initParams.put("userClassNames","org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
        initParams.put("roleClassNames","org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
        contextRealmName = NameFactory.getWebComponentName(null, null, null, null, "tomcatContextRealm", "WebResource", moduleContext);
        GBeanData contextRealm = new GBeanData(contextRealmName, RealmGBean.GBEAN_INFO);
        contextRealm.setAttribute("className", "org.apache.geronimo.tomcat.realm.TomcatJAASRealm");
        contextRealm.setAttribute("initParams", initParams);
        start(contextRealm);

        //Force a new realm name and ignore the application name
        SecurityHolder securityHolder = new SecurityHolder();
        securityHolder.setSecurityRealm(REALM_NAME);

        GBeanData app = new GBeanData(webModuleName, TomcatWebAppContext.GBEAN_INFO);
        app.setAttribute("webAppRoot", new File("target/var/catalina/webapps/war3/").toURI());
        app.setAttribute("webClassPath", new URI[]{});
        app.setAttribute("securityHolder", securityHolder);
        app.setAttribute("configurationBaseUrl", new File("target/var/catalina/webapps/war3/WEB-INF/web.xml").toURL());
        app.setAttribute("contextPath", "/securetest");
        app.setReferencePattern("TomcatRealm",contextRealmName);
        app.setReferencePattern("RoleDesignateSource", jaccBeanName);

        OnlineUserTransaction userTransaction = new OnlineUserTransaction();
        app.setAttribute("userTransaction", userTransaction);
        app.setReferencePattern("TransactionContextManager", tcmName);
        app.setReferencePattern("TrackedConnectionAssociator", ctcName);

        app.setAttribute("componentContext", Collections.EMPTY_MAP);
        app.setReferencePattern("Container", containerName);
        app.setAttribute("kernel", null);

        start(app);
    }
View Full Code Here

                                               PermissionCollection checked)
            throws Exception {

        //Will use the Engine level security
        ObjectName jaccBeanName = NameFactory.getComponentName(null, null, null, null, "foo", NameFactory.JACC_MANAGER, moduleContext);
        GBeanData jaccBeanData = new GBeanData(jaccBeanName, ApplicationPolicyConfigurationManager.GBEAN_INFO);
        Map contextIDToPermissionsMap = new HashMap();
        contextIDToPermissionsMap.put(POLICY_CONTEXT_ID, componentPermissions);
        jaccBeanData.setAttribute("contextIdToPermissionsMap", contextIDToPermissionsMap);
        jaccBeanData.setAttribute("principalRoleMap", principalRoleMap);
        jaccBeanData.setAttribute("roleDesignates", roleDesignates);
        start(jaccBeanData);

        SecurityHolder securityHolder = new SecurityHolder();
        securityHolder.setChecked(checked);
        securityHolder.setExcluded(componentPermissions.getExcludedPermissions());
        securityHolder.setPolicyContextID(POLICY_CONTEXT_ID);
        securityHolder.setDefaultPrincipal(defaultPrincipal);
        securityHolder.setSecurityRealm("Geronimo");
        GBeanData app = new GBeanData(webModuleName, TomcatWebAppContext.GBEAN_INFO);
        app.setAttribute("classLoader", cl);
        app.setAttribute("webAppRoot", new File("target/var/catalina/webapps/war3/").toURI());
        app.setAttribute("webClassPath", new URI[]{});
        app.setAttribute("contextPriorityClassLoader", Boolean.FALSE);
        app.setAttribute("securityHolder", securityHolder);
        app.setAttribute("configurationBaseUrl", new File("target/var/catalina/webapps/war3/WEB-INF/web.xml").toURL());
        app.setAttribute("contextPath", "/securetest");
        app.setReferencePattern("RoleDesignateSource", jaccBeanName);

        OnlineUserTransaction userTransaction = new OnlineUserTransaction();
        app.setAttribute("userTransaction", userTransaction);
        app.setReferencePattern("TransactionContextManager", tcmName);
        app.setReferencePattern("TrackedConnectionAssociator", ctcName);

        app.setAttribute("componentContext", Collections.EMPTY_MAP);
        app.setReferencePattern("Container", containerName);
        start(app);

        return webModuleName;
    }
View Full Code Here

        GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] {makeGerMD("d1", "l1"), makeGerMD("d2", "l2")};
        MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] {makeMDR("n1", "d1"), makeMDR("n2", "d2")};
        ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
        ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
        ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
        namingContext.addGBean(new GBeanData(n1, null));
        namingContext.addGBean(new GBeanData(n2, null));
        ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder);
        Map context = builder.getContext();
        assertEquals(2, context.size());
    }
View Full Code Here

        GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] {makeGerMD("d1", "module1", "l1"), makeGerMD("d2", "module1", "l2")};
        MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] {makeMDR("n1", "d1"), makeMDR("n2", "d2")};
        ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
        ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
        ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
        namingContext.addGBean(new GBeanData(n1, null));
        namingContext.addGBean(new GBeanData(n2, null));
        ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder);
        Map context = builder.getContext();
        assertEquals(2, context.size());
    }
View Full Code Here

    }

    protected void setUpSecurity() throws Exception {

        loginConfigurationName = new ObjectName("geronimo.security:type=LoginConfiguration");
        loginConfigurationGBean = new GBeanData(loginConfigurationName, GeronimoLoginConfiguration.getGBeanInfo());
        Set configurations = new HashSet();
        configurations.add(new ObjectName("geronimo.server:j2eeType=SecurityRealm,*"));
        configurations.add(new ObjectName("geronimo.server:j2eeType=ConfigurationEntry,*"));
        loginConfigurationGBean.setReferencePatterns("Configurations", configurations);

        securityServiceName = new ObjectName("geronimo.server:j2eeType=SecurityService");
        securityServiceGBean = new GBeanData(securityServiceName, SecurityServiceImpl.GBEAN_INFO);
        securityServiceGBean.setReferencePattern("ServerInfo", serverInfoName);
        securityServiceGBean.setAttribute("policyConfigurationFactory", "org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory");
        securityServiceGBean.setAttribute("policyProvider", "org.apache.geronimo.security.jacc.GeronimoPolicy");

        loginServiceName = new ObjectName("test:name=TestLoginService");
        loginServiceGBean = new GBeanData(loginServiceName, JaasLoginService.GBEAN_INFO);
        loginServiceGBean.setReferencePattern("Realms", new ObjectName("geronimo.server:j2eeType=SecurityRealm,*"));
        loginServiceGBean.setAttribute("algorithm", "HmacSHA1");
        loginServiceGBean.setAttribute("password", "secret");

        propertiesLMName = new ObjectName("geronimo.security:type=LoginModule,name=Geronimo");
        propertiesLMGBean = new GBeanData(propertiesLMName, LoginModuleGBean.GBEAN_INFO);
        propertiesLMGBean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
        propertiesLMGBean.setAttribute("serverSide", Boolean.TRUE);
        Properties options = new Properties();
        options.setProperty("usersURI", "src/test-resources/data/users.properties");
        options.setProperty("groupsURI", "src/test-resources/data/groups.properties");
        propertiesLMGBean.setAttribute("options", options);
        propertiesLMGBean.setAttribute("loginDomainName", "geronimo-properties-realm");

        ObjectName testUseName = new ObjectName("geronimo.security:type=LoginModuleUse,name=properties");
        GBeanData lmUseGBean = new GBeanData(testUseName, JaasLoginModuleUse.getGBeanInfo());
        lmUseGBean.setAttribute("controlFlag", "REQUIRED");
        lmUseGBean.setReferencePattern("LoginModule", propertiesLMName);

        propertiesRealmName = new ObjectName("geronimo.server:j2eeType=SecurityRealm,name=geronimo-properties-realm");
        propertiesRealmGBean = new GBeanData(propertiesRealmName, GenericSecurityRealm.GBEAN_INFO);
        propertiesRealmGBean.setReferencePattern("ServerInfo", serverInfoName);
        propertiesRealmGBean.setAttribute("realmName", "Geronimo");
        propertiesRealmGBean.setReferencePattern("LoginModuleConfiguration", testUseName);
        propertiesRealmGBean.setReferencePattern("LoginService", loginServiceName);
        Principal.PrincipalEditor principalEditor = new Principal.PrincipalEditor();
        principalEditor.setAsText("metro=org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
        propertiesRealmGBean.setAttribute("defaultPrincipal", principalEditor.getValue());

        propertiesRealmName2 = new ObjectName("geronimo.server:j2eeType=SecurityRealm,name=geronimo-properties-realm-2");
        propertiesRealmGBean2 = new GBeanData(propertiesRealmName2, GenericSecurityRealm.GBEAN_INFO);
        propertiesRealmGBean2.setReferencePattern("ServerInfo", serverInfoName);
        propertiesRealmGBean2.setAttribute("realmName", REALM_NAME);
        propertiesRealmGBean2.setReferencePattern("LoginModuleConfiguration", testUseName);
        propertiesRealmGBean2.setReferencePattern("LoginService", loginServiceName);
        Principal.PrincipalEditor principalEditor2 = new Principal.PrincipalEditor();
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gbean.GBeanData$PriorityComparator

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.