Integrating Flux Security with WebSphere

VERSION 3 Published

Created on: 04-Jun-2007 17:01 by flux - Last Modified:  26-Feb-2008 16:11 by Guest

Configuring Flux to run inside of an application server can make administration easier and can allow greater ease of integration with your current applications.

The following shows how to configure a Secure Flux engine in WebSphere. This document assumes that you are starting Flux using a servlet inside of WebSphere. This document consists of two parts: setting up the Flux configuration and setting up the Websphere configuration. A sample servlet follows at the end.

Set up Flux Configuration

To use Flux security with WebSphere, the following lines of code must be present in the engine configuration.

config.setSecurityEnabled(true);
config.setSecurityPolicyFile("C:/flux-7-3-1/fluxjaas.policy");
config.setSecurityConfigurationFile("C:/flux-7-3-1/fluxjaas.config");
Make sure the file directories above reflect your installation directory of Flux.

In order to use Flux security, you must also use RemoteSecurity when creating your Flux engine configuration. The following is an example of using RemoteSecurity.

RemoteSecurity rs = fluxFactory.makeRemoteSecurity(config, e);
server = rs.login("user","password");
*Set up WebSphere Configuration*

To configure WebSphere you first need to open the Integrated Solutions Console.

The following steps show a detailed example of how to configure Flux security in WebSphere.
  • On the left side menu of the Integrated Solutions Console, expand "Security" and select "Secure administration, applications, and infrastructures."
  • Next, expand "Java Authentication and Authorization Service" in the right side menu box and select "Application logins."
  • Create a new "Application login" with the name "flux-security-configuration" and click Apply.
  • Click on the "JAAS login modules."
  • Create a new "JAAS login module."
  • Enter "flux.security.FluxLoginModule" as the "Module class name", check "Use login module proxy", and set "Authentication strategy" to "REQUIRED." Then Save the changes.
  • WebSphere is now configured with Flux security.

The next step is to deploy your servlet in WebSphere. Once the EAR/WAR file has been deployed and started, you should have a working Secure Flux engine running in WebSphere.

If the engine does not appear to be working correctly, check to make sure that you have the correct flux.jar as well as any JDBC drivers that your engine will need in the lib directory of your WAR or EAR file.

Sample Servlet

import flux.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.rmi.RemoteException;
import java.io.IOException;
 
public class EngineAsRMIOne extends HttpServlet {
    Factory fluxFactory = null;
    static Engine server = null;
 
    public EngineAsRMIOne() {
 
    } // constructor
 
    public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
        System.out.println("In the service method");
    } // service()
 
    private void createServer() throws EngineException, RemoteException {
        if (server == null) {
            fluxFactory = Factory.makeInstance();
            Configuration config = fluxFactory.makeConfiguration();
            config.setRegistryPort(1099);
            config.setDatabaseType(DatabaseType.MYSQL);
            config.setDriver("com.mysql.jdbc.Driver");
            config.setUrl("jdbc:mysql://localhost:3306/flux");
            config.setJdbcUsername("root");
            config.setJdbcPassword("admin");
            config.setTablePrefix("FLUX_");
            config.setMaxConnections(5);
            config.setSecurityEnabled(true);
            config.setSecurityPolicyFile("C:/flux-7-3-1/fluxjaas.policy");
            config.setSecurityConfigurationFile("C:/flux-7-3-1/fluxjaas.config");
 
            try {
                Engine e = fluxFactory.makeEngine(config);
                RemoteSecurity rs = fluxFactory.makeRemoteSecurity(config, e);
                server = rs.login("admin","admin");
                server.start();
            }
            catch(Exception ee) {
                System.out.println("error when initializing engine");
                ee.printStackTrace();
            }
        }
    } // createServer()
 
    public void init() throws ServletException {
        System.out.println("In the init.Flux");
        super.init();
        System.out.println("called my super Flux");
        try {
            createServer();
            System.out.println("called create Flux");
            new ServerThread().start();
            System.out.println("created new server thread Flux");
        }catch (RemoteException e) {
            throw new ServletException(e);
        }
 
        catch (Exception e) {
            System.out.println("Flux Engine Exception Flux");
            e.printStackTrace();
        }
        System.out.println("server Flux" + server);
    } // init()
 
    public void destroy() {
        if (server != null) {
            try {
                server.dispose();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            catch (EngineException fluxE) {
                // ignore
            }
        }
 
        if (server != null) {
            try {
                for (int i = 0; !server.isDisposed() && i < 10; i++) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // ignore
                    }
                }
            } catch (EngineException e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
        super.destroy();
    } // destroy()
 
    public static class ServerThread extends Thread {
        public void run() {
            System.out.println("In the run Flux");
            try {
                while (!server.isDisposed()) {
                    try {
                        Thread.sleep(1000);
                        System.out.println("Flux is sleeping");
                        if (server != null) {
                            if (server.isDisposed()) {
                                break;
                            }
                        }
                    } catch (InterruptedException e) {
                        // ignore
                    }
                }
                System.out.println("I'm outside of run's while loop Flux");
            } catch (EngineException e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } // run()
    } // ServerThread
}
Average User Rating
(0 ratings)




There are no comments on this document