Search in sources :

Example 1 with OutboundConnectorListItem

use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem in project identity-api-server by wso2.

the class ServerIdpManagementService method createOutboundConnectorListItem.

private OutboundConnectorListItem createOutboundConnectorListItem(String idPId, ProvisioningConnectorConfig config) {
    String connectorId = base64URLEncode(config.getName());
    OutboundConnectorListItem listItem = new OutboundConnectorListItem();
    listItem.setConnectorId(connectorId);
    listItem.setName(config.getName());
    listItem.setIsEnabled(config.isEnabled());
    listItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT + "/%s/provisioning/outbound-connectors/%s", idPId, connectorId)).toString());
    return listItem;
}
Also used : OutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem) MetaOutboundConnectorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnectorListItem)

Example 2 with OutboundConnectorListItem

use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem 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 OutboundConnectorListItem

use of org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnectorListItem 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

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