tenant.setAdminPassword(UUIDGenerator.getUUID());
tenant.setEmail(adminEmail);
tenant.setAdminFirstName(adminFirstName);
tenant.setAdminLastName(adminLastName);
tenant.setDomain(domainName);
TenantPersistor tenantPersistor = IdentityRPServiceComponent.getTenantPersistor();
MultiTenantRealmConfigBuilder builder =
IdentityRPServiceComponent.getRealmService()
.
getMultiTenantRealmConfigBuilder();
TenantMgtConfiguration tenantMgtConfiguration =
IdentityRPServiceComponent.getRealmService().getTenantMgtConfiguration();
RealmConfiguration bootStrapRealmConfig =
IdentityRPServiceComponent.getRealmService()
.getBootstrapRealmConfiguration();
RealmConfiguration realmConfigToPersist =
builder.getRealmConfigForTenantToPersist(bootStrapRealmConfig,
tenantMgtConfiguration,
tenant,
-1);
realmConfigToPersist.
getUserStoreProperties().
put(UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP, GOOGLE_APPS_IDP_NAME);
tenant.setRealmConfig(realmConfigToPersist);
tenantId = tenantPersistor.persistTenant(tenant);
IdentityRPServiceComponent.getRealmService().getTenantManager().activateTenant(tenantId);
return tenantId;
}