use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse in project identity-api-server by wso2.
the class ServerIdpManagementService method updateOutboundConnectors.
/**
* Update outbound provisioning connector config.
*
* @param idpId Identity Provider resource ID.
* @param outboundConnectorRequest Outbound provisioning connector request.
* @return OutboundConnectorListResponse.
*/
public OutboundConnectorListResponse updateOutboundConnectors(String idpId, OutboundProvisioningRequest outboundConnectorRequest) {
try {
IdentityProvider idp = IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader.getTenantDomainFromContext(), true);
if (idp == null) {
throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId);
}
// Need to create a clone, since modifying the fields of the original object, will modify the cached
// IDP object.
IdentityProvider idpToUpdate = createIdPClone(idp);
updateOutboundConnectorConfig(idpToUpdate, outboundConnectorRequest);
IdentityProvider updatedIdp = IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, idpToUpdate, ContextLoader.getTenantDomainFromContext());
return createOutboundProvisioningResponse(updatedIdp);
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP, null);
}
}
use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse in project identity-api-server by wso2.
the class ServerIdpManagementService method createOutboundProvisioningResponse.
private OutboundConnectorListResponse createOutboundProvisioningResponse(IdentityProvider idp) {
ProvisioningConnectorConfig[] connectorConfigs = idp.getProvisioningConnectorConfigs();
List<OutboundConnectorListItem> connectors = new ArrayList<>();
if (connectorConfigs != null) {
for (ProvisioningConnectorConfig connectorConfig : connectorConfigs) {
OutboundConnectorListItem connectorListItem = new OutboundConnectorListItem();
connectorListItem.setConnectorId(base64URLEncode(connectorConfig.getName()));
connectorListItem.setName(connectorConfig.getName());
connectorListItem.setIsEnabled(connectorConfig.isEnabled());
connectorListItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT + "/%s/provisioning/outbound-connectors/%s", idp.getResourceId(), base64URLEncode(connectorConfig.getName()))).toString());
connectors.add(connectorListItem);
}
}
OutboundConnectorListResponse outboundConnectorListResponse = new OutboundConnectorListResponse();
outboundConnectorListResponse.setDefaultConnectorId(idp.getDefaultProvisioningConnectorConfig() != null ? base64URLEncode(idp.getDefaultProvisioningConnectorConfig().getName()) : null);
outboundConnectorListResponse.setConnectors(connectors);
return outboundConnectorListResponse;
}
use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse in project identity-api-server by wso2.
the class ServerIdpManagementService method getOutboundConnectors.
/**
* Get outbound provisioning connectors of a specific Identity Provider.
*
* @param idpId Identity Provider resource ID.
* @return OutboundConnectorListResponse.
*/
public OutboundConnectorListResponse getOutboundConnectors(String idpId) {
try {
IdentityProvider idp = IdentityProviderServiceHolder.getIdentityProviderManager().getIdPByResourceId(idpId, ContextLoader.getTenantDomainFromContext(), true);
if (idp == null) {
throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_IDP_NOT_FOUND, idpId);
}
OutboundConnectorListResponse listResponse = null;
String defaultConnectorId = null;
ProvisioningConnectorConfig[] connectorConfigs = idp.getProvisioningConnectorConfigs();
if (connectorConfigs != null) {
listResponse = new OutboundConnectorListResponse();
List<OutboundConnectorListItem> connectorList = new ArrayList<>();
for (ProvisioningConnectorConfig config : connectorConfigs) {
connectorList.add(createOutboundConnectorListItem(idpId, config));
if (idp.getDefaultProvisioningConnectorConfig() != null) {
defaultConnectorId = base64URLEncode(idp.getDefaultProvisioningConnectorConfig().getName());
}
}
listResponse.setDefaultConnectorId(defaultConnectorId);
listResponse.setConnectors(connectorList);
}
return listResponse;
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_IDP_CONNECTORS, idpId);
}
}
Aggregations