All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.jasmine.deployme.module.security.Security Maven / Gradle / Ivy

The newest version!
/**
 * JASMINe Deploy ME [Managed Element]
 * Copyright (C) 2012 Bull S.A.S.
 * Copyright (C) 2012 France Telecom R&D
 * Contact: [email protected]
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: Security.java 10000 2012-05-02 14:52:40Z cazauxj $
 * --------------------------------------------------------------------------
 */
package org.ow2.jasmine.deployme.module.security;

import org.ow2.jasmine.deployme.module.AbstractDeploymeModule;
import org.ow2.jasmine.deployme.api.modules.UnsupportDeploymeModuleException;
import org.ow2.jonas.tools.configurator.api.JonasConfigurator;
import org.ow2.jasmine.deployme.v2.generated.SecurityType;
import org.ow2.jasmine.deployme.v2.generated.AdminType;
import org.ow2.jasmine.deployme.v2.generated.UserType;

import java.util.List;

/**
 * Security module
 */
public class Security extends AbstractDeploymeModule {

    /**
     * {@inheritDoc}
     */
    public boolean isSupport(final Object configuration) {
        return SecurityType.class.isInstance(configuration);
    }

    /**
     * {@inheritDoc}
     */
    public void applyConfiguration(final JonasConfigurator configurator, final Object object) throws UnsupportDeploymeModuleException {
        if (isSupport(object)) {
            SecurityType configuration = SecurityType.class.cast(object);
            if (configuration != null) {
                if (configuration.isJmxSecured() != null) {
                    configurator.setJmxSecured(configuration.isJmxSecured());
                }
                List admins = configuration.getAdmin();
                if (admins != null) {
                    for (AdminType admin: admins) {
                        configurator.addAdmin(admin.getName(), admin.getPassword());
                    }
                }
                List users = configuration.getUser();
                if (users != null) {
                    for (UserType user: users) {
                        configurator.addUser(user.getName(), user.getPassword(), user.getRoles(), null, user.getDescription());
                    }
                }
            }
        } else {
            throw new UnsupportDeploymeModuleException("Object " + object.getClass().getName() + " is not support");
        }
    }

    /**
     * {@inheritDoc}
     */
    public String getJOnASService() {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy