Search in sources :

Example 1 with OutboundConnectorListResponse

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);
    }
}
Also used : IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 2 with OutboundConnectorListResponse

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;
}
Also used : OutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem) MetaOutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnectorListItem) ArrayList(java.util.ArrayList) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) OutboundConnectorListResponse(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse)

Example 3 with 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);
    }
}
Also used : OutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem) MetaOutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnectorListItem) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig) OutboundConnectorListResponse(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse)

Aggregations

ArrayList (java.util.ArrayList)2 MetaOutboundConnectorListItem (org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnectorListItem)2 OutboundConnectorListItem (org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem)2 OutboundConnectorListResponse (org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListResponse)2 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)2 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)2 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)2