Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to set custom providers programmatically

3 views
Skip to first unread message

Joy

unread,
Jan 14, 2004, 11:14:57 AM1/14/04
to

Could some one point me to sample java code for configuring a realm. I need to
set custom authentication/authorization providers for the default realm and set
the control flags for the defaultAuthenticator and the custom authenticator.

How do I create MBean for the custom authenticator/authorizer to set it in the
realm?

Peter

unread,
Jan 18, 2004, 9:01:27 AM1/18/04
to

"Joy" <J...@post.to.news.group> wrote in message
news:40056b01$1...@newsgroups.bea.com...

>
> Could some one point me to sample java code for configuring a realm. I
need to
> set custom authentication/authorization providers for the default realm
and set
> the control flags for the defaultAuthenticator and the custom
authenticator.
>

The sample providers have a weblogic.Admin script for modifying providers.
I will ask around if anyone has some java equivalents.


Peter

unread,
Jan 20, 2004, 8:28:25 PM1/20/04
to

"Peter" <PeterB> wrote in message news:400a...@newsgroups.bea.com...

>
> The sample providers have a weblogic.Admin script for modifying providers.
> I will ask around if anyone has some java equivalents.
>
>

I couldn't find anything suitable for a sample. The console does some of
this, but it is much more generic and not suitable for an example. The
console works like this.


1) get attribute name
2) get attribute value (in this case it sounds like an object name, or
perhaps an array of object names
3) get object name of the mbean who's attributes you wish to change
4) get a reference to an mbean server
5) call a setAttribute on the mbean


Joy

unread,
Jan 22, 2004, 11:24:05 AM1/22/04
to

I could not figure out how to create the MBean instance for a provider. I have
tried the following code
MBeanServer homeServer = Helper.getAdminMBeanHome(username, password,
url).getMBeanServer();

String name1 = realmName + "1DefaultAuthenticator";
homeServer.createMBean("weblogic.security.providers.authentication.DefaultAuthenticatorMBean",
new ObjectName("Security:Name=" + name1));

Caught Exception javax.management.NotCompliantMBeanException: The MBean must be
have a concrete class


so, I changed the code to
homeServer.createMBean("weblogic.security.providers.authentication.DefaultAuthenticatorImpl",
new ObjectName("Security:Name=" + name1));

I get the error message as
Caught Exception javax.management.NotCompliantMBeanException: weblogic.security.providers.authentication.DefaultAuthenticatorImpl
does not implement the weblogic.security.providers.authentication.DefaultAuthenticatorImplMBean
interface or the DynamicMBean interface


I even tried

homeServer.createMBean("weblogic.security.providers.authentication.DefaultAuthenticator"
, new ObjectName("Security:Name=" + name1));
Caught ReflectionException javax.management.ReflectionException: The MBean class
could not be loaded by the default loader repository
cause = null
actual exception = java.lang.ClassNotFoundException: weblogic.security.providers.authentication.DefaultAuthenticator

Anyone out there knows how to instantiate the MBean for the provider so that I
can call setAuthenticators method on the realm to set the desired authenticators.

Any prompt help is greatly appreciated.

thanks

Satya Ghattu

unread,
Jan 26, 2004, 11:01:00 AM1/26/04
to Joy
Joy,

Try the attached java client, this should be a start.

Thanks,
-satya

SimpleSecurityClient.java

Joy

unread,
Feb 11, 2004, 4:00:29 PM2/11/04
to

Thanks Satya. That worked. But I am running into RunTimeException when I execute
the program. I copy MyWLProviders.jar into server/mbeantypes dir and restart the
server before attempting to configure the providers for the realm.


I get a java.lang.ClassCastException or
java.lang.ClassCastException: java.lang.NoClassDefFoundError.

Looks like a class loader issue.
I am trying to configure the providers from a client program (no EJBs involved
here). How do I resolve this.

####<Feb 11, 2004 10:42:14 AM PST> <Notice> <WebLogicServer> <man> <myserver>
<main> <<WLS Kernel>> <> <BEA-000360> <Server s
tarted in RUNNING mode>
####<Feb 11, 2004 10:42:14 AM PST> <Notice> <WebLogicServer> <xman> <myserver>
<ListenThread.Default> <<WLS Kernel>> <> <BEA-0
00355> <Thread "ListenThread.Default" listening on port 7001, ip address *.*>
####<Feb 11, 2004 10:46:52 AM PST> <Warning> <RMI> <xman> <myserver> <ExecuteThread:
'1' for queue: 'weblogic.admin.RMI'> <<WL
S Kernel>> <> <BEA-080003> <RuntimeException thrown by rmi server: weblogic.management.internal.RemoteMBeanServerImpl.invoke(L
javax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)
javax.management.RuntimeOperationsException: RuntimeException thrown by the invoke
method of the Dynamic MBean.
java.lang.ClassCastException
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1166)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:765)
at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
--------------- nested within: ------------------
javax.management.RuntimeOperationsException: RuntimeException thrown by the invoke
method of the Dynamic MBean
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1559)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:765)
at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
>
####<Feb 11, 2004 10:56:35 AM PST> <Warning> <RMI> <man> <myserver> <ExecuteThread:
'2' for queue: 'weblogic.admin.RMI'> <<WL
S Kernel>> <> <BEA-080003> <RuntimeException thrown by rmi server: weblogic.management.internal.RemoteMBeanServerImpl.invoke(L
javax.management.ObjectName;Ljava.lang.String;[Ljava.lang.Object;[Ljava.lang.String;)
javax.management.RuntimeOperationsException: RuntimeException thrown by the invoke
method of the Dynamic MBean.
java.lang.ClassCastException: java.lang.NoClassDefFoundError
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1166)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:765)
at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
--------------- nested within: ------------------
javax.management.RuntimeOperationsException: RuntimeException thrown by the invoke
method of the Dynamic MBean
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1559)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:765)
at weblogic.management.internal.RemoteMBeanServerImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
>


----------------------------------------------------------------------------------------------------

>import weblogic.management.*;
>
>import weblogic.management.configuration.*;
>
>import weblogic.management.commo.*;
>import javax.management.*;
>
>//import java.util.Set;
>//import java.util.Iterator;
>
>import weblogic.management.WebLogicMBean;
>import weblogic.management.WebLogicObjectName;
>import javax.management.MBeanInfo;
>import javax.management.ObjectName;
>
>public class SimpleSecurityClient
>{
>
> public static void main(String[] args)
> {
> try {
> // change these to suit u'r environment...
> CommoMBeanServer mbs = Config.getMBeanServer("myserver","t3://localhost:7001",
>"system","gumby1234");
> // create your default authenticator instance
> ObjectInstance oi = mbs.createMBean(Commo.getTypeObjectName("weblogic.security.providers.authentication.DefaultAuthenticator"),
>
> new ObjectName("Security:Name=myrealm1DefaultAuthenticator"));
> // you can use straight JMX to set other attributes or use the
>CommoServer to get the stubs
> // using commo server
> weblogic.security.providers.authentication.DefaultAuthenticatorMBean
>bean =
> (weblogic.security.providers.authentication.DefaultAuthenticatorMBean)
>mbs.getMBean(oi.getObjectName());
> // now call the methods on this bean ...
> // bean.setControlFlag("REQUIRED");
>
> // using staright JMX
> mbs.setAttribute(oi.getObjectName(), new Attribute("ControlFlag","REQUIRED"));
>
> // thats it u r done!
>
>
> } catch (Exception e) {
> e.printStackTrace();
> }
>
>
> }
>}
>

0 new messages