開發 Liberty 的自訂使用者儲存庫
您可以實作 Liberty 伺服器提供的 com.ibm.ws.security.wim.RepositoryFactory 和 com.ibm.ws.security.wim.Repository 介面來開發自訂使用者儲存庫類別。
關於這項作業
儲存庫介面能夠支援幾近任何類型的帳戶儲存庫。
程序
範例
儲存庫 Factory 介面
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");
}
}
儲存庫介面
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");
}
}
作業主題