activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "scott.d.dagastino" <scott.d.dagast...@lmco.com>
Subject activemq authentication through plugins
Date Tue, 09 Sep 2008 18:19:07 GMT

I'm attempting to write my own plugin authentication module for activemq.  I
have created a bean that extends the broker plugin and register it with
activemq.xml " <bean
class="com.lmco.fltwinds.security.FltwindsAuthentication"/>".  it will fire
off the constructor with no problem but I want it to register the
userid/password (hard coded for now) with the activemq core so if
someone(user) is attempting to logon with invalid userid/password then it
will reject the connection request.  I will eventually pull the
userid/password from a database. 
1.  how do I get the userid/password into the security core through the
plugin without having to restart activemq
2.   how do I get the "installBroker" method to fire in my custom plugin.

Here is the plugin code I have created:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   SimpleAuthenticationPlugin.java

package com.lmco.fltwinds.security;

import java.util.*;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.jaas.GroupPrincipal;
import org.apache.activemq.security.AuthenticationUser;
import org.apache.activemq.security.SimpleAuthenticationBroker;

// Referenced classes of package org.apache.activemq.security:
//            SimpleAuthenticationBroker, AuthenticationUser

public class FltwindsAuthentication
    implements BrokerPlugin
{

    public FltwindsAuthentication() {
    	System.out.println("Hello world from my own plugin...:  Current time: "
+ new Date());
    	AuthenticationUser user = new AuthenticationUser("SysAdm", "SysAdm",
"Groupa");
    	List list = new ArrayList();
    	list.add(user);
    	setUsers(list);
    }
    
    public Broker installPlugin(Broker broker)
    {
    	System.out.println("SDD install plugin");
        return new SimpleAuthenticationBroker(broker, userPasswords,
userGroups);
    }

    public Map getUserGroups()
    {
        return userGroups;
    }

    public void setUsers(List users)
    {
        userPasswords = new HashMap();
        userGroups = new HashMap();
        AuthenticationUser user;
        Set groups;
        for(Iterator it = users.iterator(); it.hasNext();
userGroups.put(user.getUsername(), groups))
        {
            user = (AuthenticationUser)it.next();
            userPasswords.put(user.getUsername(), user.getPassword());
            groups = new HashSet();
            String name;
            for(StringTokenizer iter = new StringTokenizer(user.getGroups(),
","); iter.hasMoreTokens(); groups.add(new GroupPrincipal(name)))
                name = iter.nextToken().trim();

        }

    }

    public void setUserGroups(Map userGroups)
    {
        this.userGroups = userGroups;
    }

    public Map getUserPasswords()
    {
        return userPasswords;
    }

    public void setUserPasswords(Map userPasswords)
    {
        this.userPasswords = userPasswords;
    }

    private Map userPasswords;
    private Map userGroups;
}

-- 
View this message in context: http://www.nabble.com/activemq-authentication-through-plugins-tp19398185p19398185.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message