问题
I am looking for a way to apply Role based security on existing Proxy WSDLs of WSO2 ESB using Java API.
Using org.wso2.carbon.proxyadmin.stub.ProxyServiceAdminStub I could manage to enable security for unsecured proxy service, but unable to find a way to apply Role based security (please note the roles are coming from WSO2 Identity Server). I understand it's possible to perform this action with Wso2 ESB management console, but is there is a way to handle it through Java API? Any carbon backend web service available?
回答1:
Sample Client here
This helped in disabling and enabling security as well as applying Role based security for a given proxy service. This is what I was looking for. Hope it helps some one out there...
public void applySecurity(String serviceName, String policyId,
String[] userGroups, String[] trustedKeyStoreArray,
String privateStore)
throws SecurityAdminServiceSecurityConfigExceptionException, RemoteException {
ApplySecurity applySecurity;
applySecurity = new ApplySecurity();
applySecurity.setServiceName(serviceName);
applySecurity.setPolicyId("scenario" + policyId);
applySecurity.setTrustedStores(trustedKeyStoreArray);
applySecurity.setPrivateStore(privateStore);
applySecurity.setUserGroupNames(userGroups);
securityAdminServiceStub.applySecurity(applySecurity);
log.info("Security Applied");
}
来源:https://stackoverflow.com/questions/25567198/apply-role-security-to-wso2-esb-proxy-using-java-api