Je souhaite implémenter l'authentification de base HTTP pour mes services Web, mais je souhaite également utiliser ObjectDB pour stocker les informations d'identification. Est-ce qu'il y a un moyen de faire ça? Je suppose que je suis dans le besoin d'un domaine personnalisé, et aussi, que quelqu'un l'a déjà fait avant, alors si oui, veuillez lever la main. Sinon, aidez-moi s'il vous plaît avec la mise en œuvre. J'ai déjà vérifié les bases de la création de domaines personnalisés. Est-il possible de le faire fonctionner avec JDBCRealm, ou plus directement, est-il possible de créer une ressource JDBC dans GlassFish qui utilise le serveur ObjectDB?Domaine personnalisé pour ObjectDB, utilisant ObjectDB avec l'authentification HTTP Basic
Ce que je l'ai fait jusqu'à présent est la base du Realm
:
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.");
}
}
et 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];
}
}
MISE À JOUR
Malheureusement it turned out qu'il n'y a pas de pilote JDBC pour ObjectDB pour le moment. N'hésitez pas à faire des suggestions cependant!
Merci d'avance!