commit() メソッドをオーバーライドして _userPrincipal を置き換えるか、getSubject().getPrincipals().add(new PrincipalImpl("user")) を使用して独自の実装をアタッチしようとしました。どちらも期待どおりに機能していませんでした。
どのようなエラーが発生しますか?
とにかく、あなたの問題はこのプロセスの 3 番目のステップにあると思います。SecurityContext は BASIC_AUTH、FORM_AUTH、CLIENT_CERT_AUTH、DIGEST_AUTH のみを AuthenticationScheme として定義するため、おそらく SecurityContext はセキュリティ スキームまたはタイプの実装を認識できません。ただし、これらの手順を試すことができます。うまくいくことを願っています。
A- Java Authentication and Authorization Service (JAAS) LoginModule を実装するか、com.sun.appserv.security.AppservPasswordLoginModule を拡張する
public class MyLoginModule extends AppservPasswordLoginModule {
@Override
protected void authenticateUser() throws LoginException {
if (!authenticate(_username, _password)) {
//Login fails
throw new LoginException("LoginFailed");
}
String[] myGroups = getGroupNames(_username);
commitUserAuthentication(myGroups);
}
private boolean authenticate(String username, String password) {
/*
Check the credentials against the authentication source, return true if authenticated, return false otherwise
*/
return true;
}
private String[] getGroupNames(String username) {
// Return the list of groups this user belongs to.
}
B- レルム クラスの実装。
public class MyRealm extends AppservRealm {
@Override
public void init(Properties props)
throws BadRealmException, NoSuchRealmException {
//here you initialize the realm
}
@Override
public String getAuthType() {
return "Custom Realm";
}
}
C- レルムと LoginModule をサーバーにインストールして構成する。
このためには、JSR 196 を見て、javax.security.auth.message.module.ServerAuthModule を実装して独自の SAM を作成する必要があります。以下のリンクを見てください。
https://blogs.oracle.com/enterprisetechtips/entry/adding_authentication_mechanisms_to_the