use of org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig 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.application.common.model.ProvisioningConnectorConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method updateOutboundConnectorConfig.
private void updateOutboundConnectorConfig(IdentityProvider idp, OutboundProvisioningRequest outboundProvisioningRequest) {
if (outboundProvisioningRequest != null) {
List<OutboundConnector> outboundConnectors = outboundProvisioningRequest.getConnectors();
String defaultConnectorId = outboundProvisioningRequest.getDefaultConnectorId();
ProvisioningConnectorConfig defaultConnectorConfig = null;
List<ProvisioningConnectorConfig> connectorConfigs = new ArrayList<>();
for (OutboundConnector connector : outboundConnectors) {
ProvisioningConnectorConfig connectorConfig = new ProvisioningConnectorConfig();
connectorConfig.setName(base64URLDecode(connector.getConnectorId()));
connectorConfig.setEnabled(connector.getIsEnabled());
List<org.wso2.carbon.identity.api.server.idp.v1.model.Property> connectorProperties = connector.getProperties();
if (connectorProperties != null) {
if (!areAllDistinct(connectorProperties)) {
throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage.ERROR_CODE_INVALID_INPUT, " Duplicate properties are found in " + "the request.");
}
List<Property> properties = connectorProperties.stream().map(propertyToInternal).collect(Collectors.toList());
connectorConfig.setProvisioningProperties(properties.toArray(new Property[0]));
}
connectorConfigs.add(connectorConfig);
if (StringUtils.equals(defaultConnectorId, connector.getConnectorId())) {
defaultConnectorConfig = connectorConfig;
}
}
if (StringUtils.isNotBlank(defaultConnectorId) && defaultConnectorConfig == null) {
throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage.ERROR_CODE_INVALID_DEFAULT_OUTBOUND_CONNECTOR, null);
}
idp.setProvisioningConnectorConfigs(connectorConfigs.toArray(new ProvisioningConnectorConfig[0]));
idp.setDefaultProvisioningConnectorConfig(defaultConnectorConfig);
}
}
use of org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method createProvisioningConnectorConfig.
/**
* Create internal provisioning connector config from external outbound connector PUT request.
*
* @param outboundConnectorId Outbound provisioning connector resource ID.
* @param connector Outbound provisioning connector PUT request.
* @return Internal Provisioning connector config.
*/
private ProvisioningConnectorConfig createProvisioningConnectorConfig(String outboundConnectorId, OutboundConnectorPUTRequest connector) {
ProvisioningConnectorConfig connectorConfig = new ProvisioningConnectorConfig();
String connectorName = base64URLDecode(outboundConnectorId);
connectorConfig.setName(connectorName);
connectorConfig.setEnabled(connector.getIsEnabled());
connectorConfig.setBlocking(connector.getBlockingEnabled());
connectorConfig.setRulesEnabled(connector.getRulesEnabled());
if (connector.getProperties() == null) {
throw handleException(Response.Status.BAD_REQUEST, Constants.ErrorMessage.ERROR_CODE_OUTBOUND_PROVISIONING_CONFIG_NOT_FOUND, connectorName);
}
List<Property> properties = connector.getProperties().stream().map(propertyToInternal).collect(Collectors.toList());
connectorConfig.setProvisioningProperties(properties.toArray(new Property[0]));
return connectorConfig;
}
use of org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig 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);
}
}
use of org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method getMetaOutboundConnectors.
/**
* Get meta information about Identity Provider's outbound provisioning connectors.
*
* @return List of meta outbound provisioning connectors.
*/
public List<MetaOutboundConnectorListItem> getMetaOutboundConnectors() {
List<MetaOutboundConnectorListItem> metaOutboundConnectors = new ArrayList<>();
try {
ProvisioningConnectorConfig[] connectorConfigs = IdentityProviderServiceHolder.getIdentityProviderManager().getAllProvisioningConnectors();
if (ArrayUtils.isNotEmpty(connectorConfigs)) {
for (ProvisioningConnectorConfig connectorConfig : connectorConfigs) {
MetaOutboundConnectorListItem metaOutboundConnector = createMetaOutboundConnectorListItem(connectorConfig);
metaOutboundConnectors.add(metaOutboundConnector);
}
}
return metaOutboundConnectors;
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_META_CONNECTORS, null);
}
}
Aggregations