use of org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig in project identity-api-server by wso2.
the class ServerIdpManagementService method updateJITConfig.
/**
* Update Just-In-Time Provisioning configuration.
*
* @param idpId Identity Provider resource ID.
* @param justInTimeProvisioningConfig JIT config.
* @return updated JIT config.
*/
public JustInTimeProvisioning updateJITConfig(String idpId, JustInTimeProvisioning justInTimeProvisioningConfig) {
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);
}
updateJIT(idP, justInTimeProvisioningConfig);
IdentityProvider updatedIdP = IdentityProviderServiceHolder.getIdentityProviderManager().updateIdPByResourceId(idpId, idP, ContextLoader.getTenantDomainFromContext());
return createJITResponse(updatedIdP);
} catch (IdentityProviderManagementException e) {
throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_UPDATING_IDP_JIT, idpId);
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig in project identity-api-server by wso2.
the class BuildProvisioningConfiguration method getOutboundProvisioningConfiguration.
private OutboundProvisioningConfiguration getOutboundProvisioningConfiguration(IdentityProvider identityProvider) {
ProvisioningConnectorConfig provisioningConfig = identityProvider.getDefaultProvisioningConnectorConfig();
JustInTimeProvisioningConfig justInTimeProvisioningConfig = identityProvider.getJustInTimeProvisioningConfig();
return new OutboundProvisioningConfiguration().idp(identityProvider.getIdentityProviderName()).blocking(provisioningConfig.isBlocking()).connector(provisioningConfig.getName()).rules(provisioningConfig.isRulesEnabled()).jit(justInTimeProvisioningConfig != null && justInTimeProvisioningConfig.isProvisioningEnabled());
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method getOutboundProvisioningConfiguration.
/**
* @param applicationId
* @param connection
* @return
* @throws SQLException
*/
private OutboundProvisioningConfig getOutboundProvisioningConfiguration(int applicationId, Connection connection, int tenantID) throws SQLException {
PreparedStatement outboundProConfigPrepStmt = null;
OutboundProvisioningConfig outBoundProvisioningConfig = new OutboundProvisioningConfig();
ResultSet resultSet = null;
List<IdentityProvider> idpProConnectors = new ArrayList<IdentityProvider>();
try {
outboundProConfigPrepStmt = connection.prepareStatement(LOAD_PRO_CONNECTORS_BY_APP_ID);
// IDP_NAME, CONNECTOR_NAM
outboundProConfigPrepStmt.setInt(1, applicationId);
outboundProConfigPrepStmt.setInt(2, tenantID);
resultSet = outboundProConfigPrepStmt.executeQuery();
while (resultSet.next()) {
ProvisioningConnectorConfig proConnector = null;
IdentityProvider fedIdp = null;
fedIdp = new IdentityProvider();
fedIdp.setIdentityProviderName(resultSet.getString(1));
proConnector = new ProvisioningConnectorConfig();
proConnector.setName(resultSet.getString(2));
if ("1".equals(resultSet.getString(3))) {
JustInTimeProvisioningConfig jitConfig = new JustInTimeProvisioningConfig();
jitConfig.setProvisioningEnabled(true);
fedIdp.setJustInTimeProvisioningConfig(jitConfig);
}
if ("1".equals(resultSet.getString(4))) {
proConnector.setBlocking(true);
} else {
proConnector.setBlocking(false);
}
if ("1".equals(resultSet.getString(5))) {
proConnector.setRulesEnabled(true);
} else {
proConnector.setRulesEnabled(false);
}
fedIdp.setDefaultProvisioningConnectorConfig(proConnector);
idpProConnectors.add(fedIdp);
}
outBoundProvisioningConfig.setProvisioningIdentityProviders(idpProConnectors.toArray(new IdentityProvider[idpProConnectors.size()]));
} finally {
IdentityApplicationManagementUtil.closeStatement(outboundProConfigPrepStmt);
}
return outBoundProvisioningConfig;
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig in project carbon-identity-framework by wso2.
the class ApplicationBean method update.
/**
* @param request
*/
public void update(HttpServletRequest request) {
// update basic info.
serviceProvider.setApplicationName(request.getParameter("spName"));
serviceProvider.setDescription(request.getParameter("sp-description"));
serviceProvider.setCertificateContent(request.getParameter("sp-certificate"));
String jwks = request.getParameter("jwksUri");
serviceProvider.setJwksUri(jwks);
if (Boolean.parseBoolean(request.getParameter("deletePublicCert"))) {
serviceProvider.setCertificateContent("");
}
String isSasApp = request.getParameter("isSaasApp");
serviceProvider.setSaasApp((isSasApp != null && "on".equals(isSasApp)) ? true : false);
String isDiscoverableApp = request.getParameter("isDiscoverableApp");
serviceProvider.setDiscoverable("on".equals(isDiscoverableApp));
String accessUrl = request.getParameter("accessURL");
serviceProvider.setAccessUrl(accessUrl);
String imageUrl = request.getParameter("imageURL");
serviceProvider.setImageUrl(imageUrl);
String logoutReturnUrl = request.getParameter(LOGOUT_RETURN_URL);
if (StringUtils.isNotBlank(logoutReturnUrl)) {
boolean logoutReturnUrlDefined = false;
if (serviceProvider.getSpProperties() != null) {
for (ServiceProviderProperty property : serviceProvider.getSpProperties()) {
if (property.getName() != null && LOGOUT_RETURN_URL.equals(property.getName())) {
property.setValue(logoutReturnUrl);
logoutReturnUrlDefined = true;
break;
}
}
}
if (!logoutReturnUrlDefined) {
ServiceProviderProperty property = new ServiceProviderProperty();
property.setName(LOGOUT_RETURN_URL);
property.setDisplayName("Logout Return URL");
property.setValue(logoutReturnUrl);
serviceProvider.addSpProperties(property);
}
}
if (serviceProvider.getLocalAndOutBoundAuthenticationConfig() == null) {
// create fresh one.
serviceProvider.setLocalAndOutBoundAuthenticationConfig(new LocalAndOutboundAuthenticationConfig());
}
// authentication type : default, local, federated or advanced.
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType(request.getParameter("auth_type"));
// update inbound provisioning data.
String provisioningUserStore = request.getParameter("scim-inbound-userstore");
InboundProvisioningConfig inBoundProConfig = new InboundProvisioningConfig();
inBoundProConfig.setProvisioningUserStore(provisioningUserStore);
inBoundProConfig.setDumbMode(Boolean.parseBoolean(request.getParameter(DUMB)));
serviceProvider.setInboundProvisioningConfig(inBoundProConfig);
// update outbound provisioning data.
String[] provisioningProviders = request.getParameterValues("provisioning_idp");
if (provisioningProviders != null && provisioningProviders.length > 0) {
List<IdentityProvider> provisioningIdps = new ArrayList<IdentityProvider>();
for (String proProvider : provisioningProviders) {
String connector = request.getParameter("provisioning_con_idp_" + proProvider);
String jitEnabled = request.getParameter("provisioning_jit_" + proProvider);
String blocking = request.getParameter("blocking_prov_" + proProvider);
String ruleEnabled = request.getParameter("rules_enabled_" + proProvider);
if (connector != null) {
IdentityProvider proIdp = new IdentityProvider();
proIdp.setIdentityProviderName(proProvider);
JustInTimeProvisioningConfig jitpro = new JustInTimeProvisioningConfig();
if ("on".equals(jitEnabled)) {
jitpro.setProvisioningEnabled(true);
}
proIdp.setJustInTimeProvisioningConfig(jitpro);
ProvisioningConnectorConfig proCon = new ProvisioningConnectorConfig();
if ("on".equals(ruleEnabled)) {
proCon.setRulesEnabled(true);
} else {
proCon.setRulesEnabled(false);
}
if ("on".equals(blocking)) {
proCon.setBlocking(true);
} else {
proCon.setBlocking(false);
}
proCon.setName(connector);
proIdp.setDefaultProvisioningConnectorConfig(proCon);
provisioningIdps.add(proIdp);
}
}
if (CollectionUtils.isNotEmpty(provisioningIdps)) {
OutboundProvisioningConfig outboundProConfig = new OutboundProvisioningConfig();
outboundProConfig.setProvisioningIdentityProviders(provisioningIdps.toArray(new IdentityProvider[provisioningIdps.size()]));
serviceProvider.setOutboundProvisioningConfig(outboundProConfig);
}
} else {
serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
}
// get all request-path authenticators.
String[] requestPathAuthenticators = request.getParameterValues("req_path_auth");
if (requestPathAuthenticators != null && requestPathAuthenticators.length > 0) {
List<RequestPathAuthenticatorConfig> reqAuthList = new ArrayList<RequestPathAuthenticatorConfig>();
for (String name : requestPathAuthenticators) {
if (name != null) {
RequestPathAuthenticatorConfig reqAuth = new RequestPathAuthenticatorConfig();
reqAuth.setName(name);
reqAuth.setDisplayName(request.getParameter("req_path_auth_" + name));
reqAuthList.add(reqAuth);
}
}
if (CollectionUtils.isNotEmpty(reqAuthList)) {
serviceProvider.setRequestPathAuthenticatorConfigs(reqAuthList.toArray(new RequestPathAuthenticatorConfig[reqAuthList.size()]));
} else {
serviceProvider.setRequestPathAuthenticatorConfigs(null);
}
} else {
serviceProvider.setRequestPathAuthenticatorConfigs(null);
}
List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<InboundAuthenticationRequestConfig>();
if (samlIssuer != null) {
InboundAuthenticationRequestConfig samlAuthenticationRequest = new InboundAuthenticationRequestConfig();
samlAuthenticationRequest.setInboundAuthKey(samlIssuer);
samlAuthenticationRequest.setInboundAuthType("samlsso");
if (attrConsumServiceIndex != null && !attrConsumServiceIndex.isEmpty()) {
Property property = new Property();
property.setName("attrConsumServiceIndex");
property.setValue(attrConsumServiceIndex);
Property[] properties = { property };
samlAuthenticationRequest.setProperties(properties);
}
authRequestList.add(samlAuthenticationRequest);
}
if (kerberosServiceName != null) {
InboundAuthenticationRequestConfig kerberosAuthenticationRequest = new InboundAuthenticationRequestConfig();
kerberosAuthenticationRequest.setInboundAuthKey(kerberosServiceName);
kerberosAuthenticationRequest.setInboundAuthType("kerberos");
authRequestList.add(kerberosAuthenticationRequest);
}
if (oauthAppName != null) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(oauthAppName);
opicAuthenticationRequest.setInboundAuthType("oauth2");
if (oauthConsumerSecret != null && !oauthConsumerSecret.isEmpty()) {
Property property = new Property();
property.setName("oauthConsumerSecret");
property.setValue(oauthConsumerSecret);
Property[] properties = { property };
opicAuthenticationRequest.setProperties(properties);
}
authRequestList.add(opicAuthenticationRequest);
}
if (CollectionUtils.isNotEmpty(wstrustEp)) {
wstrustEp.forEach(entry -> {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(entry);
opicAuthenticationRequest.setInboundAuthType("wstrust");
authRequestList.add(opicAuthenticationRequest);
});
}
String passiveSTSRealm = request.getParameter("passiveSTSRealm");
String passiveSTSWReply = request.getParameter("passiveSTSWReply");
if (StringUtils.isNotBlank(passiveSTSRealm)) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm);
opicAuthenticationRequest.setInboundAuthType("passivests");
if (passiveSTSWReply != null && !passiveSTSWReply.isEmpty()) {
Property property = new Property();
property.setName("passiveSTSWReply");
property.setValue(passiveSTSWReply);
Property[] properties = { property };
opicAuthenticationRequest.setProperties(properties);
}
authRequestList.add(opicAuthenticationRequest);
}
String openidRealm = request.getParameter("openidRealm");
if (StringUtils.isNotBlank(openidRealm)) {
InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
opicAuthenticationRequest.setInboundAuthKey(openidRealm);
opicAuthenticationRequest.setInboundAuthType("openid");
authRequestList.add(opicAuthenticationRequest);
}
if (!CollectionUtils.isEmpty(inboundAuthenticationRequestConfigs)) {
for (InboundAuthenticationRequestConfig customAuthConfig : inboundAuthenticationRequestConfigs) {
String type = customAuthConfig.getInboundAuthType();
Property[] properties = customAuthConfig.getProperties();
if (!ArrayUtils.isEmpty(properties)) {
for (Property prop : properties) {
String propVal = request.getParameter("custom_auth_prop_name_" + type + "_" + prop.getName());
prop.setValue(propVal);
}
}
authRequestList.add(customAuthConfig);
}
}
if (serviceProvider.getInboundAuthenticationConfig() == null) {
serviceProvider.setInboundAuthenticationConfig(new InboundAuthenticationConfig());
}
if (CollectionUtils.isNotEmpty(authRequestList)) {
serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
}
// update local and out-bound authentication.
if (AUTH_TYPE_DEFAULT.equalsIgnoreCase(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType())) {
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(null);
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(null);
} else if (AUTH_TYPE_LOCAL.equalsIgnoreCase(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType())) {
AuthenticationStep authStep = new AuthenticationStep();
LocalAuthenticatorConfig localAuthenticator = new LocalAuthenticatorConfig();
localAuthenticator.setName(request.getParameter("local_authenticator"));
if (localAuthenticator.getName() != null && localAuthenticatorConfigs != null) {
for (LocalAuthenticatorConfig config : localAuthenticatorConfigs) {
if (config.getName().equals(localAuthenticator.getName())) {
localAuthenticator.setDisplayName(config.getDisplayName());
break;
}
}
}
authStep.setLocalAuthenticatorConfigs(new LocalAuthenticatorConfig[] { localAuthenticator });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(null);
} else if (AUTH_TYPE_FEDERATED.equalsIgnoreCase(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType())) {
AuthenticationStep authStep = new AuthenticationStep();
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName(request.getParameter("fed_idp"));
authStep.setFederatedIdentityProviders(new IdentityProvider[] { idp });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationScriptConfig(null);
} else if (AUTH_TYPE_FLOW.equalsIgnoreCase(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType())) {
// already updated.
}
String alwaysSendAuthListOfIdPs = request.getParameter("always_send_auth_list_of_idps");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAlwaysSendBackAuthenticatedListOfIdPs(alwaysSendAuthListOfIdPs != null && "on".equals(alwaysSendAuthListOfIdPs) ? true : false);
String useTenantDomainInLocalSubjectIdentifier = request.getParameter("use_tenant_domain_in_local_subject_identifier");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setUseTenantDomainInLocalSubjectIdentifier(useTenantDomainInLocalSubjectIdentifier != null && "on".equals(useTenantDomainInLocalSubjectIdentifier) ? true : false);
String useUserstoreDomainInLocalSubjectIdentifier = request.getParameter("use_userstore_domain_in_local_subject_identifier");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setUseUserstoreDomainInLocalSubjectIdentifier(useUserstoreDomainInLocalSubjectIdentifier != null && "on".equals(useUserstoreDomainInLocalSubjectIdentifier) ? true : false);
String useUserstoreDomainInRoles = request.getParameter("use_userstore_domain_in_roles");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setUseUserstoreDomainInRoles(useUserstoreDomainInRoles != null && "on".equals(useUserstoreDomainInRoles) ? true : false);
boolean skipConsent = Boolean.parseBoolean(request.getParameter(IdentityConstants.SKIP_CONSENT));
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSkipConsent(skipConsent);
boolean skipLogoutConsent = Boolean.parseBoolean(request.getParameter(IdentityConstants.SKIP_LOGOUT_CONSENT));
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSkipLogoutConsent(skipLogoutConsent);
String enableAuthorization = request.getParameter("enable_authorization");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setEnableAuthorization(enableAuthorization != null && "on".equals(enableAuthorization));
String subjectClaimUri = request.getParameter("subject_claim_uri");
serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri((subjectClaimUri != null && !subjectClaimUri.isEmpty()) ? subjectClaimUri : null);
// update application permissions.
PermissionsAndRoleConfig permAndRoleConfig = new PermissionsAndRoleConfig();
String[] permissions = request.getParameterValues("app_permission");
List<ApplicationPermission> appPermList = new ArrayList<ApplicationPermission>();
if (permissions != null && permissions.length > 0) {
for (String permission : permissions) {
if (permission != null && !permission.trim().isEmpty()) {
ApplicationPermission appPermission = new ApplicationPermission();
appPermission.setValue(permission);
appPermList.add(appPermission);
}
}
}
if (CollectionUtils.isNotEmpty(appPermList)) {
permAndRoleConfig.setPermissions(appPermList.toArray(new ApplicationPermission[appPermList.size()]));
}
// update role mapping.
int roleMappingCount = Integer.parseInt(request.getParameter("number_of_rolemappings"));
List<RoleMapping> roleMappingList = new ArrayList<RoleMapping>();
for (int i = 0; i < roleMappingCount; i++) {
RoleMapping mapping = new RoleMapping();
LocalRole localRole = new LocalRole();
localRole.setLocalRoleName(request.getParameter("idpRole_" + i));
mapping.setLocalRole(localRole);
mapping.setRemoteRole(request.getParameter("spRole_" + i));
if (mapping.getLocalRole() != null && mapping.getRemoteRole() != null) {
roleMappingList.add(mapping);
}
}
permAndRoleConfig.setRoleMappings(roleMappingList.toArray(new RoleMapping[roleMappingList.size()]));
serviceProvider.setPermissionAndRoleConfig(permAndRoleConfig);
if (serviceProvider.getClaimConfig() == null) {
serviceProvider.setClaimConfig(new ClaimConfig());
}
if (request.getParameter("claim_dialect") != null && "custom".equals(request.getParameter("claim_dialect"))) {
serviceProvider.getClaimConfig().setLocalClaimDialect(false);
} else {
serviceProvider.getClaimConfig().setLocalClaimDialect(true);
}
// update claim configuration.
int claimCount = Integer.parseInt(request.getParameter("number_of_claim_mappings"));
List<ClaimMapping> claimMappingList = new ArrayList<ClaimMapping>();
for (int i = 0; i < claimCount; i++) {
ClaimMapping mapping = new ClaimMapping();
Claim localClaim = new Claim();
localClaim.setClaimUri(request.getParameter("idpClaim_" + i));
Claim spClaim = new Claim();
spClaim.setClaimUri(request.getParameter("spClaim_" + i));
String requested = request.getParameter("spClaim_req_" + i);
if (requested != null && "on".equals(requested)) {
mapping.setRequested(true);
} else {
mapping.setRequested(false);
}
String mandatory = request.getParameter("spClaim_mand_" + i);
if (mandatory != null && "on".equals(mandatory)) {
mapping.setMandatory(true);
} else {
mapping.setMandatory(false);
}
mapping.setLocalClaim(localClaim);
mapping.setRemoteClaim(spClaim);
if (isLocalClaimsSelected() || mapping.getRemoteClaim().getClaimUri() == null || mapping.getRemoteClaim().getClaimUri().isEmpty()) {
mapping.getRemoteClaim().setClaimUri(mapping.getLocalClaim().getClaimUri());
}
if (mapping.getLocalClaim().getClaimUri() != null && mapping.getRemoteClaim().getClaimUri() != null) {
claimMappingList.add(mapping);
}
}
String spClaimDialectParam = request.getParameter(ApplicationMgtUIConstants.Params.SP_CLAIM_DIALECT);
String[] spClaimDialects = null;
if (StringUtils.isNotBlank(spClaimDialectParam)) {
spClaimDialects = spClaimDialectParam.split(",");
}
serviceProvider.getClaimConfig().setSpClaimDialects(spClaimDialects);
serviceProvider.getClaimConfig().setClaimMappings(claimMappingList.toArray(new ClaimMapping[claimMappingList.size()]));
serviceProvider.getClaimConfig().setRoleClaimURI(request.getParameter("roleClaim"));
String alwaysSendMappedLocalSubjectId = request.getParameter("always_send_local_subject_id");
serviceProvider.getClaimConfig().setAlwaysSendMappedLocalSubjectId(alwaysSendMappedLocalSubjectId != null && "on".equals(alwaysSendMappedLocalSubjectId) ? true : false);
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.JustInTimeProvisioningConfig in project carbon-identity-framework by wso2.
the class IdPManagementDAO method getIdPByAuthenticatorPropertyValue.
/**
* @param dbConnection
* @param property Property which has a unique value like EntityID to specifically identify a IdentityProvider
* Unless it will return first matched IdentityProvider
* @param value
* @param tenantId
* @param tenantDomain
* @return
* @throws IdentityProviderManagementException
*/
public IdentityProvider getIdPByAuthenticatorPropertyValue(Connection dbConnection, String property, String value, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
PreparedStatement prepStmt = null;
ResultSet rs = null;
IdentityProvider federatedIdp = null;
boolean dbConnectionInitialized = true;
if (dbConnection == null) {
dbConnection = IdentityDatabaseUtil.getDBConnection(false);
} else {
dbConnectionInitialized = false;
}
try {
// SP_IDP_ID, SP_IDP_NAME, SP_IDP_PRIMARY, SP_IDP_HOME_REALM_ID,SP_IDP_CERTIFICATE,
// SP_IDP_TOKEN_EP_ALIAS,
// SP_IDP_INBOUND_PROVISIONING_ENABLED,SP_IDP_INBOUND_PROVISIONING_USER_STORE_ID,
// SP_IDP_USER_CLAIM_URI,
// SP_IDP_ROLE_CLAIM_URI,SP_IDP_DEFAULT_AUTHENTICATOR_NAME,SP_IDP_DEFAULT_PRO_CONNECTOR_NAME
String sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_BY_AUTHENTICATOR_PROPERTY;
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setString(1, property);
prepStmt.setString(2, value);
prepStmt.setInt(3, tenantId);
rs = prepStmt.executeQuery();
int idpId = -1;
String idPName = "";
if (rs.next()) {
federatedIdp = new IdentityProvider();
idpId = rs.getInt("ID");
idPName = rs.getString("NAME");
federatedIdp.setIdentityProviderName(idPName);
if ((IdPManagementConstants.IS_TRUE_VALUE).equals(rs.getString("IS_PRIMARY"))) {
federatedIdp.setPrimary(true);
} else {
federatedIdp.setPrimary(false);
}
federatedIdp.setHomeRealmId(rs.getString("HOME_REALM_ID"));
federatedIdp.setCertificate(getBlobValue(rs.getBinaryStream("CERTIFICATE")));
federatedIdp.setAlias(rs.getString("ALIAS"));
JustInTimeProvisioningConfig jitProConfig = new JustInTimeProvisioningConfig();
if (IdPManagementConstants.IS_TRUE_VALUE.equals(rs.getString("INBOUND_PROV_ENABLED"))) {
jitProConfig.setProvisioningEnabled(true);
} else {
jitProConfig.setProvisioningEnabled(false);
}
jitProConfig.setProvisioningUserStore(rs.getString("INBOUND_PROV_USER_STORE_ID"));
federatedIdp.setJustInTimeProvisioningConfig(jitProConfig);
String userClaimUri = rs.getString("USER_CLAIM_URI");
String roleClaimUri = rs.getString("ROLE_CLAIM_URI");
String defaultAuthenticatorName = rs.getString("DEFAULT_AUTHENTICATOR_NAME");
String defaultProvisioningConnectorConfigName = rs.getString("DEFAULT_PRO_CONNECTOR_NAME");
federatedIdp.setIdentityProviderDescription(rs.getString("DESCRIPTION"));
// IS_FEDERATION_HUB_IDP
if (IdPManagementConstants.IS_TRUE_VALUE.equals(rs.getString("IS_FEDERATION_HUB"))) {
federatedIdp.setFederationHub(true);
} else {
federatedIdp.setFederationHub(false);
}
if (federatedIdp.getClaimConfig() == null) {
federatedIdp.setClaimConfig(new ClaimConfig());
}
// IS_LOCAL_CLAIM_DIALECT
if (IdPManagementConstants.IS_TRUE_VALUE.equals(rs.getString("IS_LOCAL_CLAIM_DIALECT"))) {
federatedIdp.getClaimConfig().setLocalClaimDialect(true);
} else {
federatedIdp.getClaimConfig().setLocalClaimDialect(false);
}
federatedIdp.setProvisioningRole(rs.getString("PROVISIONING_ROLE"));
if (IdPManagementConstants.IS_TRUE_VALUE.equals(rs.getString("IS_ENABLED"))) {
federatedIdp.setEnable(true);
} else {
federatedIdp.setEnable(false);
}
federatedIdp.setDisplayName(rs.getString("DISPLAY_NAME"));
if (defaultAuthenticatorName != null) {
FederatedAuthenticatorConfig defaultAuthenticator = new FederatedAuthenticatorConfig();
defaultAuthenticator.setName(defaultAuthenticatorName);
federatedIdp.setDefaultAuthenticatorConfig(defaultAuthenticator);
}
if (defaultProvisioningConnectorConfigName != null) {
ProvisioningConnectorConfig defaultProConnector = new ProvisioningConnectorConfig();
defaultProConnector.setName(defaultProvisioningConnectorConfigName);
federatedIdp.setDefaultProvisioningConnectorConfig(defaultProConnector);
}
// get federated authenticators.
federatedIdp.setFederatedAuthenticatorConfigs(getFederatedAuthenticatorConfigs(dbConnection, idPName, federatedIdp, tenantId));
if (federatedIdp.getClaimConfig().isLocalClaimDialect()) {
federatedIdp.setClaimConfig(getLocalIdPDefaultClaimValues(dbConnection, idPName, userClaimUri, roleClaimUri, idpId, tenantId));
} else {
// get claim configuration.
federatedIdp.setClaimConfig(getIdPClaimConfiguration(dbConnection, idPName, userClaimUri, roleClaimUri, idpId, tenantId));
}
// get provisioning connectors.
federatedIdp.setProvisioningConnectorConfigs(getProvisioningConnectorConfigs(dbConnection, idPName, idpId, tenantId));
// get permission and role configuration.
federatedIdp.setPermissionAndRoleConfig(getPermissionsAndRoleConfiguration(dbConnection, idPName, idpId, tenantId));
List<IdentityProviderProperty> propertyList = filterIdenityProperties(federatedIdp, getIdentityPropertiesByIdpId(dbConnection, Integer.parseInt(rs.getString("ID"))));
if (IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME.equals(idPName)) {
propertyList = resolveConnectorProperties(propertyList, tenantDomain);
}
federatedIdp.setIdpProperties(propertyList.toArray(new IdentityProviderProperty[0]));
}
return federatedIdp;
} catch (SQLException e) {
throw new IdentityProviderManagementException("Error occurred while retrieving Identity Provider " + "information for Authenticator Property : " + property + " and value : " + value, e);
} catch (ConnectorException e) {
throw new IdentityProviderManagementException("Error occurred while retrieving the identity connector " + "configurations.", e);
} finally {
if (dbConnectionInitialized) {
IdentityDatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt);
} else {
IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
}
}
}
Aggregations