步骤二、使用MbeanMaker实用工具来处理MDF文件,并生成MBean和桩:
D:\>java -classpath "D:\bea\weblogic81\server\lib\mbeantypes\wlManagement.jar;D:
\bea\weblogic81\server\lib\weblogic.jar;D:\bea\jdk142_05\lib\tools.jar;D:\bea\jd
k142_05\lib\rt.jar;d:\src" -DcreateStubs="true" weblogic.management.commo.WebLog
icMBeanMaker -MDF d:\src\ImepAuthenticator.xml -files d:\src
Parsing the MBean definition file: d:\src\ImepAuthenticator.xml
Generating the source files...
Generating the MBean interface file...
Generating the MBean implementation file...
Compiling the implementation file...
Compiling these files d:\src\ImepSecurityAuthenticatorImpl.java
Generating the MBI generator file...
Compiling the MBI generator file...
Compiling these files d:\src\ImepSecurityAuthenticatorMBI.java
Creating the MBI file...
Deleting the MBI generator temp files.......
Done.
步骤三、通过com.imep.security.ImepAuthProviderImpl类中设置JAAS验证模块
private AppConfigurationEntry getConfiguration(HashMap hashmap) { hashmap.put("database", new ImepAuthDatabase()); return new AppConfigurationEntry("com.imep.security.ImepLoginModuleImpl", controlFlag, hashmap); }
其中com.imep.security.ImepLoginModuleImpl实现LoginModule
步骤四、在com.imep.security.ImepLoginModuleImpl验证模块中,实现自定义验证:
实现源码在附件中
步骤五、将以上代码打成jar包,并通过WebLogicMBeanMaker打成MJF包:
D:\>java -classpath "D:\bea\weblogic81\server\lib\mbeantypes\wlManagement.jar;D:
\bea\weblogic81\server\lib\weblogic.jar;D:\bea\jdk142_05\lib\tools.jar;D:\bea\jd
k142_05\lib\rt.jar;d:\src" -DcreateStubs="true" weblogic.management.commo.WebLog
icMBeanMaker -MJF ImepAuthenticatorProvider.jar -files d:\src
Compiling the files...
Compiling these files d:\src\ImepSecurityAuthenticatorImpl.java
d:\src\ImepSecurityAuthenticatorMBean.java
d:\src\ImepSecurityAuthenticatorMBI.java
Creating the MJF...
MJF is created.
Done.
步骤六、将MJF包:
ImepAuthenticatorProvider.jar 放置到
D:\bea\weblogic81\server\lib\mbeantypes\下,
并登录weblogic的console控制台,在
domain->Security->Realms->myrealm->roviders->Authentication
中添加Imep Security Authenticator即可。