Package org.apache.geronimo.security

Examples of org.apache.geronimo.security.GeronimoSecurityException


     * @param role The role that is to be mapped to a set of principals.
     * @param principals The set of principals that are to be mapped to to role.
     * @throws org.apache.geronimo.security.GeronimoSecurityException if the mapping principals to the same role twice occurs.
     */
    public void addRoleMapping(String role, Collection principals) throws GeronimoSecurityException {
        if (!configured) throw new GeronimoSecurityException("Must call configure() first");

        try {
            RoleMappingConfiguration roleMapper = (RoleMappingConfiguration) policyConfiguration;

            if (!roleNames.contains(role)) throw new GeronimoSecurityException("Role does not exist in this configuration");

            roleMapper.addRoleMapping(role, principals);
        } catch (ClassCastException cce) {
            throw new GeronimoSecurityException("Policy configuration object does not implement RoleMappingConfiguration", cce.getCause());
        } catch (PolicyContextException pe) {
            throw new GeronimoSecurityException("Method addRoleMapping threw an exception", pe.getCause());
        }
    }
View Full Code Here


        PolicyConfiguration other;

        try {
            other = factory.getPolicyConfiguration(link.getContextID(), false);
        } catch (PolicyContextException e) {
            throw new GeronimoSecurityException("Unable to find policy configuration with that id", e);
        }

        if (other != null) {
            try {
                policyConfiguration.linkConfiguration(other);
            } catch (PolicyContextException e) {
                throw new GeronimoSecurityException("Unable to link configuration", e.getCause());
            }

        }
    }
View Full Code Here

     */
    public void delete() throws GeronimoSecurityException {
        try {
            policyConfiguration.delete();
        } catch (PolicyContextException e) {
            throw new GeronimoSecurityException("Unable to delete configuration", e.getCause());
        }
    }
View Full Code Here

     */
    public void commit() throws GeronimoSecurityException {
        try {
            policyConfiguration.commit();
        } catch (PolicyContextException e) {
            throw new GeronimoSecurityException("Unable to commit configuration", e.getCause());
        }
    }
View Full Code Here

     */
    public boolean inService() throws GeronimoSecurityException {
        try {
            return policyConfiguration.inService();
        } catch (PolicyContextException e) {
            throw new GeronimoSecurityException("Unable to obtain inService state", e.getCause());
        }
    }
View Full Code Here

        realmName = (String) options.get("realm");
        kernelName = (String) options.get("kernel");
        try {
            Kernel kernel = Kernel.getKernel(kernelName);

            if (kernel == null) throw new GeronimoSecurityException("No kernel found by the name of " + kernelName);

            loginService = (LoginServiceMBean) MBeanProxyFactory.getProxy(LoginServiceMBean.class, kernel.getMBeanServer(), LoginService.LOGIN_SERVICE);

            this.loginModuleId = loginService.allocateLoginModule(realmName);
        } catch (Exception e) {
            throw (GeronimoSecurityException) new GeronimoSecurityException("Initialize error: " + e.toString() + "\n").initCause(e);
        }
    }
View Full Code Here

        Subject defaultSubject = new Subject();

        DefaultPrincipal principal = securityConfig.getDefaultPrincipal();

        RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal.getPrincipal(), principal.getRealmName());
        if (realmPrincipal == null) throw new GeronimoSecurityException("Unable to create realm principal");
        PrimaryRealmPrincipal primaryRealmPrincipal = ConfigurationUtil.generatePrimaryRealmPrincipal(principal.getPrincipal(), principal.getRealmName());
        if (primaryRealmPrincipal == null) throw new GeronimoSecurityException("Unable to create primary realm principal");

        defaultSubject.getPrincipals().add(realmPrincipal);
        defaultSubject.getPrincipals().add(primaryRealmPrincipal);

        result.setSubject(defaultSubject);
View Full Code Here

            this.groups.putAll(groups);

            log.info("SQL Realm - " + getRealmName() + " - refresh");
        } catch (SQLException sqle) {
            log.info("SQL Realm - " + getRealmName() + " - refresh failed");
            throw new GeronimoSecurityException(sqle);
        }
    }
View Full Code Here

                                Class clazz = Class.forName(principal.getClass1());
                                Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class});
                                p = (java.security.Principal) constructor.newInstance(new Object[]{principal.getName()});
                                set.add(new RealmPrincipal(realm.getRealmName(), p));
                            } catch (InstantiationException e) {
                                throw new GeronimoSecurityException(e);
                            } catch (IllegalAccessException e) {
                                throw new GeronimoSecurityException(e);
                            } catch (ClassNotFoundException e) {
                                throw new GeronimoSecurityException(e);
                            } catch (NoSuchMethodException e) {
                                throw new GeronimoSecurityException(e);
                            } catch (InvocationTargetException e) {
                                throw new GeronimoSecurityException(e);
                            }
                        }
                        super.addRoleMapping(role.getRoleName(), set);
                    }
                }
View Full Code Here

    public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
        debug = "true".equalsIgnoreCase((String) options.get("debug"));
        String uri = (String) options.get("uri");
        String realm = (String) options.get("realm");

        if (uri == null) throw new GeronimoSecurityException("Initialize error: uri to sercurity service is not set");
        if (realm == null) throw new GeronimoSecurityException("Initialize error: realm name not specified");

        try {
            connectURI = new URI(uri);
            remoteLoginService = RemoteLoginServiceFactory.create(connectURI.getHost(), connectURI.getPort());

            SerializableACE entry = remoteLoginService.getAppConfigurationEntry(realm);

            final String finalClass = entry.getLoginModuleName();
            wrapper = (LoginModule) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
                    return Class.forName(finalClass, true, classLoader).newInstance();
                }
            });

            HashMap map = new HashMap(entry.getOptions());
            map.put(LOGIN_SERVICE, remoteLoginService);

            wrapper.initialize(subject, callbackHandler, sharedState, map);

            if (debug) {
                System.out.print("[GeronimoLoginModule] Debug is  " + debug + " uri " + uri + " realm " + realm + "\n");
            }
        } catch (PrivilegedActionException pae) {
            Exception e = pae.getException();
            if (e instanceof InstantiationException) {
                throw (GeronimoSecurityException) new GeronimoSecurityException("Initialize error:" + e.getCause().getMessage()).initCause(e.getCause());
            } else {
                throw (GeronimoSecurityException) new GeronimoSecurityException("Initialize error: " + e.toString()).initCause(e);
            }
        } catch (URISyntaxException e) {
            throw (GeronimoSecurityException) new GeronimoSecurityException("Initialize error: " + e.toString()).initCause(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.security.GeronimoSecurityException

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.