Search in sources :

Example 56 with ProvisioningConnectorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.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;
}
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 57 with ProvisioningConnectorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.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);
    }
}
Also used : ArrayList(java.util.ArrayList) OutboundConnector(org.wso2.carbon.identity.api.server.idp.v1.model.OutboundConnector) MetaOutboundConnector(org.wso2.carbon.identity.api.server.idp.v1.model.MetaOutboundConnector) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.Property) SubProperty(org.wso2.carbon.identity.application.common.model.SubProperty) MetaProperty(org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)

Example 58 with ProvisioningConnectorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.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;
}
Also used : IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.Property) SubProperty(org.wso2.carbon.identity.application.common.model.SubProperty) MetaProperty(org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty) ProvisioningConnectorConfig(org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)

Example 59 with ProvisioningConnectorConfig

use of org.wso2.carbon.identity.application.common.model.xsd.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);
    }
}
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)

Example 60 with ProvisioningConnectorConfig

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

Aggregations

ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)39 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)19 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)19 Property (org.wso2.carbon.identity.application.common.model.Property)19 ArrayList (java.util.ArrayList)17 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)14 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)10 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)10 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.idp.xsd.ProvisioningConnectorConfig)10 PreparedStatement (java.sql.PreparedStatement)9 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)9 Test (org.testng.annotations.Test)8 Claim (org.wso2.carbon.identity.application.common.model.Claim)7 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)7 LocalRole (org.wso2.carbon.identity.application.common.model.LocalRole)7 PermissionsAndRoleConfig (org.wso2.carbon.identity.application.common.model.PermissionsAndRoleConfig)7 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)7 ResultSet (java.sql.ResultSet)6 HashMap (java.util.HashMap)6 JustInTimeProvisioningConfig (org.wso2.carbon.identity.application.common.model.JustInTimeProvisioningConfig)6