3

我正在尝试从独立的 java 应用程序中查找 EJB。我正在考虑 WebSphere Application Server 6.1,但如果有人知道如何为另一个应用程序服务器执行此操作,它可能会让我朝着正确的方向前进。

我目前在做什么:

        initialContext= new InitialContext(env);
    initialContext.lookup("");

    lc = new LoginContext("WSLogin", new WSCallbackHandlerImpl("wasadmin", "defaultWIMFileBasedRealm", "wasadmin"));
    lc.login();
    subject = lc.getSubject();
    WSSubject.setRunAsSubject(subject);

这不起作用...我的主题仍然是“/未验证”,当我尝试查找 EJB 时出现错误。在执行应用程序时,我还为 VM 指定了以下参数:

-Dcom.ibm.CORBA.ConfigURL="C:\was\profiles\AppSrv01\properties\sas.client.props" -Djava.security.auth.login.config="C:\was\profiles\AppSrv01\properties\ wsjaas_client.conf"

4

1 回答 1

1

对于 WebSphere 6,试图从同样部署在同一个 WebSphere 中的 servlet(Jersey-RESTful WAR)访问安全 EJB;这是有效的代码

     Properties prop = new Properties();

    prop.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB");   
    prop.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
    prop.put("java.naming.provider.url", "corbaloc:iiop:localhost:9810");
    prop.put("com.ibm.CORBA.securityEnabled", "true");
    prop.put("com.ibm.CORBA.validateBasicAuth", "true");


    Context ctx;
    try {
        ctx = new InitialContext(prop);

        System.out.println("Resolved Inital Context");
        Object ejbHome = ctx.lookup("");
        System.out.println("Resolved Home OperationManagerEJB");
        logger.info("So far so good, tryining to Login ");
        LoginContext lc;
        lc = new LoginContext("WSLogin",new WSCallbackHandlerImpl("username","password"));
        lc.login();

        logger.info("Login Suceeded with omc_user");
        WSSubject.setRunAsSubject(lc.getSubject()); //This is one key call 
        logger.info("Setting the authorization sibject");

参考

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frtrb_secprobs.html

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Fxsec_jaas.html

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Fxsec_jaas.html

于 2012-12-10T11:01:43.733 回答