2016-08-04 38 views
1

我使用了此鏈接中的信息https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.wlp.doc/ae/twlp_dev_prog_login_auth_data.html根據我從本討論主題獲得的信息。 https://developer.ibm.com/answers/questions/261209/websphere-liberty-profile-and-j2c-authdata-retriev-1.html否爲DefaultPrincipalMapping配置的LoginModules WAS Libert y配置文件8.5.5.9

DefaultPrincipalMapping程序化登錄是可用的,應該可以工作。我配置了更新到Liberty配置文件v 8.5.5.9的所有內容,但是我的代碼在[err] javax.security.auth.login.LoginException處拋出了異常:沒有爲javax.security.auth.login.LoginContext處的DefaultPrincipalMapping [err]配置LoginModules。的init(LoginContext.java:264)[ERR]在javax.security.auth.login.LoginContext中。(LoginContext.java:417)這是我的代碼段..

 Context context = new InitialContext(); 
    String user = (String) context.lookup("cell/persistent/ADBindUser"); 
    String password = (String) context.lookup("cell/persistent/ADBindPwd"); 

    Map<String, String> map = new HashMap<String, String>(); 
    map.put(Constants.MAPPING_ALIAS, "WPSBIND"); 

//的CallbackHandler的callbackHandler = // WSMappingCallbackHandlerFactory.getInstance()。getCallbackHandler(map,null);

 CallbackHandler callbackHandler =new WSMappingCallbackHandler(map, null); 

    LoginContext loginContext = 
     new LoginContext("DefaultPrincipalMapping", callbackHandler); 
    try{ 
     loginContext.login(); 
    }catch(LoginException le) { 

    } 

任何人都可以告訴我我在這裏失蹤。

+0

你可以添加你的'server.xml'嗎?你添加了'passwordUtilities-1.0'功能嗎? – Gas

回答

-1

而不是"DefaultPrincipalMapping"登錄配置"system.DEFAULT"爲我做了這份工作。 最後一絲藏在documentation

system.DEFAULT

用於登錄指定任何JAAS配置時。

...

的system.WEB_INBOUND和system.DEFAULT配置有按以下順序進行 默認登錄模塊:哈希表userNameAndPassWord,則在 證書,並令牌。 WSLogin配置將proxy login module 作爲默認登錄模塊,代理將所有操作都委託給system.DEFAULT中的實際登錄模塊。

WSLogin失敗的情況下,該應用程序使用例如一個Unrecognized Callback作爲回調的org.jboss.security.auth.callback.UsernamePasswordHandler。如果應用程序無法修改,system.DEFAULT提供了一個替代方案。

相關問題