WebサービスのHTTP基本認証を実装したいのですが、ObjectDBを使用して資格情報を格納することもできます。これを行う方法はありますか?私はカスタム領域を必要としていると思うし、誰かが既にこれをしていたと思うので、もしそうなら、手を挙げてください。それ以外の場合は、実装を手伝ってください。カスタムレルムの作成の基本を確認しました。何らかの形でJDBCRealmで動作させることは可能ですか、より直接的には、ObjectDBサーバーを使用するGlassFishでJDBCリソースを作成することは可能ですか?ObjectDBのカスタムレルム(HTTPの基本認証でObjectDBを使用)
package objectdbrealm;
import com.sun.appserv.security.AppservRealm;
import com.sun.enterprise.security.auth.realm.BadRealmException;
import com.sun.enterprise.security.auth.realm.InvalidOperationException;
import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
import com.sun.enterprise.security.auth.realm.NoSuchUserException;
import java.util.Enumeration;
import java.util.Properties;
public class ObjectDbRealm extends AppservRealm {
@Override
public void init(Properties properties) throws BadRealmException, NoSuchRealmException {
//initialize the realm
}
@Override
public String getAuthType() {
return "ObjectDB Realm";
}
@Override
public Enumeration getGroupNames(String string) throws InvalidOperationException, NoSuchUserException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
、およびLoginModule
::悲しいことit turned outにはJDBCドライバが存在しないこと
package objectdbrealm;
import com.sun.appserv.security.AppservPasswordLoginModule;
import com.sun.enterprise.security.auth.login.common.LoginException;
public class ObjectDbLoginModule extends AppservPasswordLoginModule {
@Override
protected void authenticateUser() throws LoginException {
if (!authenticate(_username, _passwd)) {
//Login fails
throw new LoginException((new StringBuilder()).append("Login Failed for:").append(_username).toString());
}
String[] groups = getGroupNames(_username);
commitUserAuthentication(groups);
}
private boolean authenticate(String username, char[] 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.
return new String[0];
}
}
UPDATE
私がこれまでRealm
の拠点となってやった
まだObjectDBです。しかし、お気軽に提案してください!
ありがとうございます!