WebアプリケーションをTomcatで起動して実行しています。今、WebLogic 12c内でアプリケーション(warファイル)を実行する必要があります。私は十分な情報を見つけることができませんでしたWebLogic用JAAS設定
:
1)は、warファイル内のweb.xmlファイルと一緒に必須weblogic.xmlのですか?チュートリアルでは、weblogic.xmlでコンテキストやその他の設定を設定することについて言及していますが、必須ではありません。
2)WebLogic内でJAASレルムを設定する必要があります。私はレルムを設定しようとしましたが、何かが設定に縛られているのを知らないのです。誰かが私に適切なチュートリアルを指し示すことができるか、JAASセットアップに必要なステップを提供できますか?
私は-Djava.security.auth.login.config =%DOMAIN_HOME%\ jaas.configをstartWebLogic.cmdファイル内に追加しました。
以下は私のログインモジュールのコードです:チュートリアルの一部で
public class AuthLoginModule implements LoginModule {
private static Logger logger = Logger.getLogger(AuthLoginModule.class);
// initial state
private Subject subject;
private CallbackHandler callbackHandler;
private Map<String, ?> sharedState;
private Map<String, ?> options;
// the authentication status
private boolean succeeded = false;
private boolean commitSucceeded = false;
// username and password
private String username;
private String password;
Map<String,String> userData = new HashMap<String,String>();
private AuthPrincipal userPrincipal;
public AuthLoginModule() throws WebAuthServiceException {
super();
}
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
this.setSharedState(sharedState);
this.setOptions(options);
String appName = options.get(WebAuthConstants.APP_UNIQUE_NAME).toString();
logger.info("AppName in AuthLoginModule: " + appName);
}
public boolean login() throws LoginException {
if (callbackHandler == null)
throw new LoginException("Error: no CallbackHandler available " + "to garner authentication information from the user");
Callback[] callbacks = new Callback[2];
callbacks[0] = new NameCallback("user name: ");
callbacks[1] = new PasswordCallback("password: ", false);
try {
callbackHandler.handle(callbacks);
username = ((NameCallback) callbacks[0]).getName();
char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword();
if (tmpPassword == null) {
// treat a NULL password as an empty password
tmpPassword = new char[0];
}
password = new String(tmpPassword);
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
throw new LoginException("User name or password is empty");
}
} catch (java.io.IOException ioe) {
throw new LoginException(ioe.toString());
} catch (UnsupportedCallbackException uce) {
throw new LoginException("Error: " + uce.getCallback().toString() + " not available to garner authentication information " + "from the user");
}
String validateUserCredData = validateUserCred();
if (validateUserCredData!=null) {
if(JsonUtil.jsonFromString(validateUserCredData).get("statusCode").getAsInt()== HttpStatus.SC_UNAUTHORIZED) {
userData.put(DataConstants._USER_PWD_STATUS, DataConstants._RESET_USER_PWD);
}
succeeded = true;
} else {
succeeded = false;
}
return succeeded;
}
private String validateUserCred() {
try {
logger.info("Started validating user credentials for: " + username);
// If there is no error then user allowed to access all
UserClientService UserClientService = ClientServiceFactory.getInstance().getUserService();
return UserClientService.validateUserCredentials(username, password);
} catch (Throwable e) {
logger.error("Exception while authentication user against Service API, Error Code: ", e);
}
return null;
}
public boolean commit() throws LoginException {
if (succeeded == false) {
return false;
} else {
// add a Principal (authenticated identity) to the Subject
// assume the user we authenticated is the SamplePrincipal
userPrincipal = new AuthPrincipal(username, password, userData);
if (!subject.getPrincipals().contains(userPrincipal))
subject.getPrincipals().add(userPrincipal);
logger.info("Login Module successfully added user principal");
// in any case, clean out state
username = null;
password = null;
commitSucceeded = true;
return true;
}
}
public boolean abort() throws LoginException {
if (succeeded == false) {
return false;
} else if (succeeded == true && commitSucceeded == false) {
// login succeeded but overall authentication failed
succeeded = false;
username = null;
password = null;
userPrincipal = null;
} else {
// overall authentication succeeded and commit succeeded,
// but someone else's commit failed
logout();
}
return true;
}
public boolean logout() throws LoginException {
subject.getPrincipals().remove(userPrincipal);
succeeded = false;
succeeded = commitSucceeded;
username = null;
password = null;
userPrincipal = null;
logger.info("Login Module successfully removed user principal after successful logout");
return true;
}
public Map<String, ?> getSharedState() {
return sharedState;
}
public void setSharedState(Map<String, ?> sharedState) {
this.sharedState = sharedState;
}
public Map<String, ?> getOptions() {
return options;
}
public void setOptions(Map<String, ?> options) {
this.options = options;
}
}
、私は、WebLogicへの特定の書かれたLoginModuleを見ることができましたが、私はそれがJ2EEを次のようにLoginModuleは任意のサーバ用に変更するべきではない気がします。
ご協力いただければ幸いです。
'realm'はあなたが望むタグだとは思わないでください。 StackOverflowのRealmタグは、Realm Mobile Databaseに関連付けられています。 – teotwaki
ありがとう、タグを削除しました。 – Azim
以前はWebLogicにSSO製品を統合しました。 LoginModuleにWebLogic固有のPrincipalオブジェクトを作成する必要があるため、Principalを作成する部分はWebLogicにかなりバインドされています。私が試したことは、手動で設定を行うことです。私はそれをWebLogicのやり方で行い、MBeanを生成し、WebLogicのWebコンソールを使用して構成を作成しました。これを参照できます。https://docs.oracle.com/cd/E12890_01/ales/docs32/dvspisec/progrmng.html –