Développement d'un référentiel d'utilisateurs personnalisé pour Liberty
Vous pouvez développer une classe de référentiel d'utilisateurs personnalisé en implémentant les interfaces com.ibm.ws.security.wim.RepositoryFactory et com.ibm.ws.security.wim.Repository fournies avec le serveur Liberty.
Pourquoi et quand exécuter cette tâche
Les interfaces de référentiel activent le support de tout type de référentiel de comptes.
Procédure
Exemple
Interface
de fabrique de référentiel
package com.myorg;
import java.util.Map;
import org.osgi.service.component.ComponentContext;
import com.ibm.websphere.security.wim.exception.WIMException;
import com.ibm.ws.security.wim.Repository;
import com.ibm.ws.security.wim.RepositoryFactory;
public class CustomRepositoryFactory implements RepositoryFactory {
@Override
public Repository getRepository(Map<String, Object> properties) throws WIMException {
System.out.println("getRepository " + properties);
return new CustomRepository(properties);
}
public void activate(ComponentContext cc, Map<String, Object> properties) {
System.out.println("In activate");
}
public void deactivate(ComponentContext cc) {
System.out.println("In deactivate");
}
}
Interface de référentiel
package com.myorg;
import java.util.Map;
import com.ibm.websphere.security.wim.exception.WIMException;
import com.ibm.websphere.security.wim.model.Root;
import com.ibm.ws.security.wim.Repository;
import com.ibm.ws.security.wim.RepositoryConfiguration;
public class CustomRepository extends RepositoryConfiguration implements Repository {
public CustomRepository(Map<String, Object> properties) {
System.out.println("Constructor with " + properties);
}
@Override
public Root create(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
@Override
public Root delete(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
@Override
public Root get(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
@Override
public String getRealm() {
return "customRepository";
}
@Override
public Root login(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
@Override
public Root search(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
@Override
public Root update(Root arg0) throws WIMException {
throw new WIMException("Method not supported");
}
}
Rubrique Tâche