![[8.5.5.8 or later]](../ng_v8558.gif)
This topic applies to WebSphere Application Server Liberty V8.5.5.9 and earlier. For the latest Liberty topics, see the WebSphere Application Server Liberty documentation.
Developing a custom user repository for Liberty
You can develop a custom user repository class by implementing the com.ibm.ws.security.wim.RepositoryFactory and com.ibm.ws.security.wim.Repository interfaces that are provided in the Liberty server.
About this task
The repository interfaces enable support to virtually any type of account repository.
Procedure
Example
Repository factory
interface
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");
}
}
Repository
interface
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");
}
}