Desarrollo de un repositorio de usuario personalizado para Liberty
Puede desarrollar una clase de repositorio de usuarios personalizado implementando las interfaces com.ibm.ws.security.wim.RepositoryFactory y com.ibm.ws.security.wim.Repository que se proporcionan en el servidor de Liberty.
Acerca de esta tarea
Las interfaces de repositorio habilitan el soporte de casi cualquier tipo de repositorio de cuenta.
Procedimiento
Ejemplo
Interfaz de fábrica de
repositorio
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");
}
}
Interfaz de repositorio
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");
}
}
Tema de tarea