On Tue, Sep 9, 2008 at 12:19 PM, scott.d.dagastino
<[EMAIL PROTECTED]> wrote:
>
> 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;
> }

I'd suggest creating an implementation of the BrokerPlugin to wrap
your BrokerFilter. The BrokerPlugin allow you to create an instance of
the BrokerFilter and expose the BrokerFilter configuration via the
plugin configuration in the activemq.xml.

Bruce
-- 
perl -e 'print unpack("u30","D0G)[EMAIL 
PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/

Blog: http://bruceblog.org/

Reply via email to