设为首页 收藏本站
查看: 883|回复: 0

[经验分享] Weblogic扩展JAAS身份验证案例

[复制链接]

尚未签到

发表于 2017-2-16 06:13:12 | 显示全部楼层 |阅读模式
步骤一、首先通过MDF的XML文件定义验证提供程序,文件路径为:d:\src\ImepAuthenticator.xml

<?xml version="1.0" ?>
<!DOCTYPE MBeanType SYSTEM "commo.dtd">
<!-- MBean Definition File (MDF) for the Sample Authenticator.
Copyright (c) 2003 by BEA Systems, Inc.  All Rights Reserved.
-->
<!-- Declare your mbean.
Since it is for an authenticator, it must extend the
weblogic.management.security.authentication.Authenticator mbean.
The Name and DisplayName must be the same.
They specify the name that will appear on the
console for this provider.
Set the PeristPolicy to "OnUpdate" so that if an attribute
value is changed, the new value is written to disk immediately.
See the "Developing Security Services" manual for more info.
Note that since this is an xml document, you can't use double
quotes directly.  Instead you need to use &quot;
Note that setting "Writeable" to "false" on an attribute
makes the attribute read-only.  The default is read-write.
-->
<MBeanType
Name          = "ImepSecurityAuthenticator"
DisplayName   = "Imep Security Authenticator"
Package       = "com.imep.security"
Extends       = "weblogic.management.security.authentication.Authenticator"
PersistPolicy = "OnUpdate"
>
<!-- You must set the value of the ProviderClassName attribute
(inherited from the weblogic.management.security.Provider mbean)
to the name of the java class you wrote that implements the
weblogic.security.spi.AuthenticationProvider interface.
You can think of the provider's mbean as the factory
for your provider's runtime implementation.
-->
<MBeanAttribute
Name          = "roviderClassName"
Type          = "java.lang.String"
Writeable     = "false"
Default       = "&quot;com.imep.security.ImepAuthProviderImpl&quot;"
/>
<!-- You must set the value of the Description attribute
(inherited from the weblogic.management.security.Provider mbean)
to a brief description of your provider.
It is displayed in the console.
-->
<MBeanAttribute
Name          = "Description"
Type          = "java.lang.String"
Writeable     = "false"
Default       = "&quot;Authenticator used for the MedRec sample application only&quot;"
/>
<!-- You must set the value of the Version attribute
(inherited from the weblogic.management.security.Provider mbean)
to your provider's version.  There is no required format.
-->
<MBeanAttribute
Name          = "Version"
Type          = "java.lang.String"
Writeable     = "false"
Default       = "&quot;1.0&quot;"
/>
<!-- Add any custom attributes for your provider here.
The sample authenticator does not have any custom attributes.
Note: custom attributes do not appear in the
console in WLS 7.0.  Use the admin command line tool
(java weblogic.Admin) to view and set their values.
Refer to the "Developing Security Services" manual
for more info on defining custom attributes.
-->
</MBeanType>


步骤二、使用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即可。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-342639-1-1.html 上篇帖子: 解决一个weblogic的jar包冲突问题 下篇帖子: Hibernate3.X使用weblogic布署相关问题解决
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表