웹 서비스에 HTTP 기본 인증을 구현하려고하지만 ObjectDB를 사용하여 자격 증명을 저장하려고합니다. 이 일을 할 수있는 방법이 있습니까? 나는 커스텀 영역이 필요하다고 생각합니다. 누군가 이미 이미 그렇게 했으므로, 그렇다면 손을 들어주세요. 그렇지 않으면 구현을 도와주세요. 이미 맞춤 영역을 만드는 기본 사항을 확인했습니다. 어떻게 든 JDBCRealm과 작동하도록 만들 수 있습니까? 아니면 더 직접적으로 GlassDB에서 ObjectDB 서버를 사용하는 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
:
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에 대한 JDBC 드라이버가 없음을
슬프게도it turned out 내가 지금까지 무슨 짓을
는하여 Realm
의 기지 ObjectDB가 아직 없습니다. 그러나 제안을하는 것이 자유롭게 느껴 져라!
미리 감사드립니다.