当前位置:首页 > 开发 > 系统架构 > 架构 > 正文

Weblogic9扩展JAAS应用注意点

发表于: 2011-05-24   作者:Dead_knight   来源:转载   浏览次数:
摘要: 一、创建 MBean 定义文件MDF(与Weblogic8一致) 文件名称为:WorkSecurityAuthenticator.xml <?xml version="1.0" ?> <!DOCTYPE MBeanType SYSTEM "commo.dtd"> <MBeanType Name
一、创建 MBean 定义文件MDF(与Weblogic8一致)
文件名称为:WorkSecurityAuthenticator.xml
<?xml version="1.0" ?>
<!DOCTYPE MBeanType SYSTEM "commo.dtd">
<MBeanType 
	Name          = "WorkSecurityAuthenticator"
	DisplayName   = "Work Security Authenticator"
 	Package       = "com.pims.work.auth.security"
	Extends       = "weblogic.management.security.authentication.Authenticator"
	PersistPolicy = "OnUpdate"	
	Description   = "This MBean represents configuration attributes for the WebLogic Authorization provider."
>
	<MBeanAttribute  
	  	Name          = "ProviderClassName"
	  	Type          = "java.lang.String"
	  	Writeable     = "false"
	  	Default       = "&quot;com.pims.work.auth.security.WorkAuthProviderImpl&quot;"		
	  	Description   = "The name of the Java class used to load the WebLogic Authorization provider."
	/>
	
	<MBeanAttribute 
		Name = "Description"
		Type = "java.lang.String"
		Writeable = "false"
		Default = "&quot;Weblogic Default Authorization Provider&quot;"    
		Description = "A short description of the WebLogic Authorization provider."
	/>
	
	<MBeanAttribute 
		Name = "Version" 
		Type = "java.lang.String" 
		Writeable = "false" 
		Default = "&quot;1.0&quot;" 
		Description = "The version of the WebLogic Authorization provider."
	/>
	
</MBeanType>


二、使用 WebLogic MBeanMaker 生成 MBean 类型
java -classpath "D:\bea9\weblogic92\server\lib\mbeantypes\wlManagement.jar;D:\bea9\weblogic92\server\lib\weblogic.jar;D:\bea9\jdk150_12\lib\tools.jar;D:\bea9\jdk150_12\lib\rt.jar;d:\auth" -DMDF="D:\auth\WorkSecurityAuthenticator.xml" -Dfiles="D:\auth" -DcreateStubs="true" weblogic.management.commo.WebLogicMBeanMaker

三、创建运行时类
package com.pims.work.auth.security;

import java.util.HashMap;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
import weblogic.management.security.ProviderMBean;
import weblogic.security.provider.PrincipalValidatorImpl;
import weblogic.security.spi.AuthenticationProviderV2;
import weblogic.security.spi.IdentityAsserterV2;
import weblogic.security.spi.PrincipalValidator;
import weblogic.security.spi.SecurityServices;

public final class WorkAuthProviderImpl implements AuthenticationProviderV2
{   
    private String description;   
    private LoginModuleControlFlag controlFlag;   
    public void initialize(ProviderMBean mbean, SecurityServices services)  
    {      
        WorkSecurityAuthenticatorMBean myMBean = (WorkSecurityAuthenticatorMBean)mbean;      
        description = myMBean.getDescription() + "\n" + myMBean.getVersion();      
        String flag = myMBean.getControlFlag();      
        if (flag.equalsIgnoreCase("REQUIRED")) 
        {        
            controlFlag = LoginModuleControlFlag.REQUIRED;      
        } 
        else if (flag.equalsIgnoreCase("OPTIONAL")) 
        {        
            controlFlag = LoginModuleControlFlag.OPTIONAL;      
        }
        else if (flag.equalsIgnoreCase("REQUISITE")) 
        {        
            controlFlag = LoginModuleControlFlag.REQUISITE;      
        } 
        else if (flag.equalsIgnoreCase("SUFFICIENT")) 
        {        
            controlFlag = LoginModuleControlFlag.SUFFICIENT;      
        } 
        else 
        {       
            throw new IllegalArgumentException("invalid flag value" + flag);      
        }   
    }   
    
    public String getDescription()  
    {      
        return description;  
    }   
    
    public void shutdown()  
    {      
        System.out.println("WorkAuthProviderImpl.shutdown");  
    }  

    private AppConfigurationEntry getConfiguration(HashMap options)   
    {      
        return new AppConfigurationEntry("com.pims.work.auth.security.WorkLoginModuleImpl", controlFlag, options);   
    }   
    
    public AppConfigurationEntry getLoginModuleConfiguration()   
    {      
        HashMap options = new HashMap();      
        return getConfiguration(options);   
    }   
    
    public AppConfigurationEntry getAssertionModuleConfiguration()   
    {      
        HashMap options = new HashMap();      
        options.put("IdentityAssertion","true");      
        return getConfiguration(options);   
    }   
    
    public PrincipalValidator getPrincipalValidator()    
    {      
        return new PrincipalValidatorImpl();   
    }   
    
    public IdentityAsserterV2 getIdentityAsserter()   
    {      
        return null;   
    }
}

其中com.pims.work.auth.security.WorkLoginModuleImpl为JAAS的LoginModule实现类。

四、使用 WebLogic MBeanMaker 创建 MBean JAR 文件 (MJF)
java -classpath "D:\bea9\weblogic92\server\lib\mbeantypes\wlManagement.jar;D:\bea9\weblogic92\server\lib\weblogic.jar;D:\bea9\jdk150_12\lib\tools.jar;D:\bea9\jdk150_12\lib\rt.jar;d:\auth" -DMJF="D:\auth\lib\WorkAuthProvider.jar" -Dfiles="D:\auth" -DcreateStubs="true" weblogic.management.commo.WebLogicMBeanMaker

五、把产生的jar包放到WL_HOME/server/lib/mbeantypes/目录下,并在控制台进行配置。

Weblogic9扩展JAAS应用注意点

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
在前面我介绍了在首选项中来对bstekIDE进行扩展(dorado studio插件定制扩展应用两则 ),这个扩展只能
在前面我介绍了在首选项中来对bstekIDE进行扩展(dorado studio插件定制扩展应用两则 ),这个扩展只能
在前面我介绍了在首选项中来对bstekIDE进行扩展(dorado studio插件定制扩展应用两则 ),这个扩展只能
在前面我介绍了在首选项中来对bstekIDE进行扩展(dorado studio插件定制扩展应用两则 ),这个扩展只能
众所周知,Eclipse开发平台本身就是基于插件体系的,为了实现某个功能,我们可以在Eclipse的基础上以插
众所周知,Eclipse开发平台本身就是基于插件体系的,为了实现某个功能,我们可以在Eclipse的基础上以插
众所周知,Eclipse开发平台本身就是基于插件体系的,为了实现某个功能,我们可以在Eclipse的基础上以插
众所周知,Eclipse开发平台本身就是基于插件体系的,为了实现某个功能,我们可以在Eclipse的基础上以插
转:http://webdancer.is-programmer.com/posts/35983 随机梯度下降算法的基本思想,在前面已经说过
基于springmvc的web应用在初始化时做了什么?application context何时加载?有几种加载方式? 和所
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号