`
新来的菜鸟
  • 浏览: 131209 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

关于 Invalid Subject

 
阅读更多

1.【问题描述】:

java.lang.SecurityException: [Security:090398]Invalid Subject: V_EGIS_IMAGE_EGIS_GENERAL_QUERY_001

 

2.【原因分析】

client JVM把错误的subject传递给了Remote JVM

什么是subject subject就像是一个经过了Remote JVM数字签名的身份文件。

Subject是怎么生成的?是把用户密码送给Remote JVM,经过Remote JVM验证并进行数字签名后发送给Client JVM

Invalid Subject是什么意思?就是Remote JVM收到了不是自己签过名的Subject数据。

为什么Remote JVM收到了不是自己签名的Subject数据? Client JVM的应用代码没有控制好EJB 调用的Context

远程调用很多,Client JVM怎么选择使用哪个Subject?如果在建立EJBInitialContext的时候提供了用户、密码那么就会登陆到远程JVM生成新的subjectClient JVM的线程就会和这个subject绑定。如果建立EJBInitialContext的时候没有提供用户、密码,那么线程就会使用线程当前运行身份的subject传递给Remote Subject。注意:如果存在Context嵌套,那么线程的subject就会以堆栈的形式存放起来,如果没有程序的控制,线程永远都会使用栈顶的subject来作为运行身份。进行Context Close的时候永远都是把栈顶的subject pop出来。当Context嵌套而且没有遵循使用完成马上关闭的原则,那么当前栈顶的Subject就会存在很多种可能,如果当前的调用Context没有重新登陆到Remote JVM,那么就会使用栈顶的subject传递给Remote JVM,这个subject是什么?有多种可能,那么就会Invalid Subject了。

其次,在本地线程派发子进程打开ctx的过程中也会产生类似的问题。但是pafa3.5.4已经解决。

 

3. 【解决方案】

首先可以借用pafaAC的标准,配置成普通的bean实例,在使用的过程中只需要按照配置的名字引用实例即可。

配置如下:

    Map result=null;

        try {

            // 取得Initial Context

     

        

           ImageRemote imageRemote = (ImageRemote) context

           .getBean("viewImageEJB");

            // 查找EJB

           //ImageHome imageHome = (ImageHome) ctx.lookup("com.palic.image.application.app.facade.Image");

          

           result=imageRemote.getImageTicket(imageMap);

          

<bean id="viewImageJndiTemplate"

       class="com.paic.pafa.app.lwc.core.naming.JndiTemplate"

       lazy-init="true">

       <description>

           访问影像系统模板,参数值在context-gccps.properties.xml配置

       </description>

       <property name="environment">

           <props>

              <prop key="java.naming.provider.url">

                  ${viewimage.jndi.url}

              </prop>

              <prop key="java.naming.factory.initial">

                  weblogic.jndi.WLInitialContextFactory

              </prop>

              <prop key="java.naming.security.principal">

                  ${viewimage.jndi.principal}

              </prop>

              <prop key="java.naming.security.credentials">

                  ${viewimage.jndi.credentials}

              </prop>

           </props>

       </property>

    </bean>   

   

   

    <bean id="viewImageEJB"

        class="com.paic.pafa.app.lwc.service.remoting.access.ejb.SmartRemoteStatelessSessionProxyFactoryBean"

       lazy-init="true">

       <property name="jndiName">

           <value>com.palic.image.application.app.facade.Image</value>

       </property>

       <property name="businessInterface">

           <value>

              com.palic.image.application.app.facade.ImageRemote

           </value>

       </property>

       <property name="jndiTemplate">

           <ref local="viewImageJndiTemplate" />

       </property>

    </bean>

此处的仿照pafaAC可以使用自己的ejb接口,例如ima接口

其次,可以自己获取context,但是切记在打开的过程中如果获得远程的remote接口后一定要close掉防止在close的时候篡改栈顶的内容。请注意的是:之前提供的解决方案由于个人水平的有限,是存在一定的问题的,因为在获得remote接口后关闭ctx后调用远程方法时是需要wls的认证信息的,也就是要缓存subject传入调用的方法,此处引用了一部同事的代码提供给大家参考:

是使用了反射的机制获取method,调用wlsSecurity.runAs(internalSubject, action);其中internalSubject,是缓存的wlssubjectaction调用run方法执行的结果通过函数返回,此处使用了java的一个动态代理的技术,就是InvocationHandlerEJBHomeInvocationHandler其实是一个处理类,他代理的类作为参数传进来,并在调用被代理类的方法的时候调用invoke方法执行函数并回调action接口的run方法,返回结果。

EJBHomeInvocationHandler处理时发现被代理类执行的是create的时候(也就是拿remote接口的时候)将再次生成EJBInvocationHandler处理类,代理执行过程中的result对象也就是remote对象,并处理此对象调用的方法。执行invoke方法并回调run方法。

分享到:
评论
1 楼 toopoo 2012-07-03  
平安的              

相关推荐

    swatchrc 过滤策略文件

    mail address=root, subject=warning: Invalid user throttle 01:00 watchfor /authentication failure/ mail address=root, subject=warning: authentication failure throttle 01:00 watchfor /...

    发送邮件发送,先提一下SMTP

    objMailMessage.Subject = "邮件发送标题:你好";//发送邮件的标题 objMailMessage.Body = "邮件发送标内容:测试一下是否发送成功!";//发送邮件的内容 objMailMessage.Attachments.Add( objMailAttachment );...

    Cody‘s_Data_Cleaning_Techniques_Using_SAS_(Second_Edtion)

    Loo Looking for Duplicates and "n" Observations per Subject Introduction 117 Eliminating Duplicates by Using PROC SORT 117 Detecting Duplicates by Using DATA Step Approaches 123 Using PROC FREQ to ...

    RegexBuddy3.6.0最新注册版

    Test: Debug Here and Debug Till End triggered an "invalid class typecast" error if the test subject editor was in hexadecimal mode. Test: If a regular expression contained an inverted range with a \...

    NBU mysql备份管理

    DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. VERITAS TECHNOLOGIES LLC SHALL NOT BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH THE FURNISHING, PERFORMANCE, OR USE OF THIS ...

    air_man:高频 Airbrake 错误的电子邮件通知

    }.yml# edit config.ymlbundle exec rake report邮件 Subject: AirMan: 270.05/hour Faraday::Error::ClientError Invalid certificateDetails athttps://company.airbrake.io/groups/12313123last retrieved notice...

    Recover4all Professional

    Subject to Your acceptance of, and compliance with, the terms and conditions of this license agreement, Licensor grants to You a limited, non-exclusive, non-transferable license (i) to use the ...

    Vagaa哇嘎画时代--体验群体智慧的力量!

    Please note that the Third Party Software may be subject to different licences or other arrangements, which you should read carefully. By installing and using this Third Party Software you accept ...

    AVG 破解版

    1. If using a software version subject to costs, the Licensee must have a valid license code made out to the Licensee in order to be able to install, use and update the software. 2. The Licensee may ...

    Sakemail

    retrieved and SendMessage is a boolean function (maybe someone has pressed the cancel btn).- Fixed a bug when the subject field is too large.9/2/981.5.1- Fixed a bug with a message within a message ...

    JAVA_API1.6文档(中文)

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口...

    Universal-USB-Installer

    安装linux工具源码 (UUI) Universal USB Installer ?...This Open Source tool falls under the GNU General Public License Version 2 Source Code is made available at time of download, from the official UUI ...

    数位板压力测试

    sdk LCS/Telegraphics Wintab* Interface Specification 1.1: 16- and 32-bit API Reference By Rick Poyner Revised February 11, 2012 This specification was developed in response to a perceived need for a...

    hydra 7.2 win32

    295 entries (294 tries invalid logins, 1 valid). Every test was run three times (only for "1 task" just once), and the average noted down. P A R A L L E L T A S K S SERVICE 1 4 8 16 32 50 64 100 128...

    Senfore_DragDrop_v4.1

    Please include the words "Drag Drop" in the subject of any email regarding these components. ------------------------------------------- 6. Bug reports: ------------------------------------------- ...

    java api最新7.0

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口。 ...

    JDK_1_6 API

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口。...

    JavaAPI1.6中文chm文档 part1

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口...

    JavaAPI中文chm文档 part2

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口...

    [Java参考文档]

    javax.security.auth.x500 此包包含应该用来在 Subject 中存储 X500 Principal 和 X500 Private Crendentials 的类。 javax.security.cert 为公钥证书提供类。 javax.security.sasl 包含用于支持 SASL 的类和接口...

Global site tag (gtag.js) - Google Analytics