use of org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getApplicationBasicInfo.
/**
* Get all basic application information for a matching filter with pagination based on the offset and limit.
*
* @param tenantDomain Tenant Domain.
* @param username User name.
* @param filter Application name filter.
* @param offset Starting index of the count.
* @param limit Counting value.
* @return An array of {@link ApplicationBasicInfo} instances within the limit.
* @throws IdentityApplicationManagementException Error in retrieving basic application information.
*/
@Override
public ApplicationBasicInfo[] getApplicationBasicInfo(String tenantDomain, String username, String filter, int offset, int limit) throws IdentityApplicationManagementException {
ApplicationBasicInfo[] applicationBasicInfoArray;
try {
startTenantFlow(tenantDomain, username);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
if (appDAO instanceof PaginatableFilterableApplicationDAO) {
// Invoking pre listeners.
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPreGetApplicationBasicInfo(tenantDomain, username, filter, offset, limit)) {
if (log.isDebugEnabled()) {
log.debug("Invoking pre listener: " + listener.getClass().getName());
}
return new ApplicationBasicInfo[0];
}
}
applicationBasicInfoArray = ((PaginatableFilterableApplicationDAO) appDAO).getApplicationBasicInfo(filter, offset, limit);
// Invoking post listeners.
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPostGetApplicationBasicInfo(tenantDomain, username, filter, offset, limit, applicationBasicInfoArray)) {
if (log.isDebugEnabled()) {
log.debug("Invoking post listener: " + listener.getClass().getName());
}
return new ApplicationBasicInfo[0];
}
}
} else {
throw new UnsupportedOperationException("Application filtering and pagination not supported in " + appDAO.getClass().getName() + " with tenant domain: " + tenantDomain);
}
} finally {
endTenantFlow();
}
return applicationBasicInfoArray;
}
use of org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getAllPaginatedApplicationBasicInfo.
/**
* Get All Application Basic Information with pagination
*
* @param tenantDomain Tenant Domain
* @param username User Name
* @param pageNumber Number of the page
* @return ApplicationBasicInfo[]
* @throws IdentityApplicationManagementException
*/
@Override
public ApplicationBasicInfo[] getAllPaginatedApplicationBasicInfo(String tenantDomain, String username, int pageNumber) throws IdentityApplicationManagementException {
ApplicationBasicInfo[] applicationBasicInfoArray;
try {
startTenantFlow(tenantDomain, username);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
if (appDAO instanceof PaginatableFilterableApplicationDAO) {
// invoking pre listeners
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPreGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber)) {
return new ApplicationBasicInfo[0];
}
}
applicationBasicInfoArray = ((PaginatableFilterableApplicationDAO) appDAO).getAllPaginatedApplicationBasicInfo(pageNumber);
// invoking post listeners
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && listener instanceof AbstractApplicationMgtListener && !((AbstractApplicationMgtListener) listener).doPostGetPaginatedApplicationBasicInfo(tenantDomain, username, pageNumber, applicationBasicInfoArray)) {
return new ApplicationBasicInfo[0];
}
}
} else {
throw new UnsupportedOperationException("Application pagination is not supported. Tenant domain: " + tenantDomain);
}
} finally {
endTenantFlow();
}
return applicationBasicInfoArray;
}
use of org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method createApplicationTemplateFromSP.
@Override
public void createApplicationTemplateFromSP(ServiceProvider serviceProvider, SpTemplate spTemplate, String tenantDomain) throws IdentityApplicationManagementException {
if (serviceProvider != null) {
try {
validateSPTemplateExists(spTemplate, tenantDomain);
ServiceProvider updatedSP = removeUnsupportedTemplateConfigs(serviceProvider);
applicationValidatorManager.validateSPConfigurations(updatedSP, tenantDomain, CarbonContext.getThreadLocalCarbonContext().getUsername());
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable()) {
listener.doPreCreateApplicationTemplate(serviceProvider, tenantDomain);
}
}
String serviceProviderTemplateXml = marshalSPTemplate(updatedSP, tenantDomain);
spTemplate.setContent(serviceProviderTemplateXml);
doAddApplicationTemplate(spTemplate, tenantDomain);
} catch (IdentityApplicationManagementValidationException e) {
log.error("Validation error when creating the application template:" + spTemplate.getName() + "from service provider: " + serviceProvider.getApplicationName() + " in:" + tenantDomain);
logValidationErrorMessages(e);
throw new IdentityApplicationManagementClientException(e.getValidationMsg());
} catch (IdentityApplicationManagementException e) {
String errorMsg = String.format("Error when creating the application template: %s from " + "service provider: %s in: ", spTemplate.getName(), serviceProvider.getApplicationName(), tenantDomain);
throw new IdentityApplicationManagementException(errorMsg, e);
}
} else {
createApplicationTemplate(spTemplate, tenantDomain);
}
}
use of org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method createApplicationWithTemplate.
@Override
public ServiceProvider createApplicationWithTemplate(ServiceProvider serviceProvider, String tenantDomain, String username, String templateName) throws IdentityApplicationManagementException {
// Call pre listeners.
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreCreateApplication(serviceProvider, tenantDomain, username)) {
throw buildServerException("Pre create application operation of listener: " + getName(listener) + " failed for application: " + serviceProvider.getApplicationName() + " of tenantDomain: " + tenantDomain);
}
}
doPreAddApplicationChecks(serviceProvider, tenantDomain, username);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
serviceProvider.setOwner(getUser(tenantDomain, username));
int appId = doAddApplication(serviceProvider, tenantDomain, username, appDAO::createApplication);
serviceProvider.setApplicationID(appId);
setDisplayNamesOfLocalAuthenticators(serviceProvider, tenantDomain);
SpTemplate spTemplate = this.getApplicationTemplate(templateName, tenantDomain);
if (spTemplate != null) {
updateSpFromTemplate(serviceProvider, tenantDomain, spTemplate);
appDAO.updateApplication(serviceProvider, tenantDomain);
}
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostCreateApplication(serviceProvider, tenantDomain, username)) {
log.error("Post create application operation of listener:" + getName(listener) + " failed for " + "application: " + serviceProvider.getApplicationName() + " of tenantDomain: " + tenantDomain);
break;
}
}
triggerAuditLogEvent(getInitiatorId(username, tenantDomain), getInitiatorId(username, tenantDomain), USER, CarbonConstants.LogEventConstants.EventCatalog.CREATE_APPLICATION.getEventId(), getAppId(serviceProvider), getApplicationName(serviceProvider), TARGET_APPLICATION, buildSPData(serviceProvider));
return serviceProvider;
}
use of org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method createApplicationTemplate.
@Override
public void createApplicationTemplate(SpTemplate spTemplate, String tenantDomain) throws IdentityApplicationManagementException {
try {
ServiceProvider serviceProvider = unmarshalSPTemplate(spTemplate.getContent());
validateSPTemplateExists(spTemplate, tenantDomain);
validateUnsupportedTemplateConfigs(serviceProvider);
applicationValidatorManager.validateSPConfigurations(serviceProvider, tenantDomain, CarbonContext.getThreadLocalCarbonContext().getUsername());
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable()) {
listener.doPreCreateApplicationTemplate(serviceProvider, tenantDomain);
}
}
doAddApplicationTemplate(spTemplate, tenantDomain);
} catch (IdentityApplicationManagementValidationException e) {
log.error("Validation error when creating the application template: " + spTemplate.getName() + " in:" + tenantDomain);
logValidationErrorMessages(e);
throw new IdentityApplicationManagementClientException(e.getValidationMsg());
} catch (IdentityApplicationManagementException e) {
String errorMsg = String.format("Error when creating the application template: %s in tenant: %s", spTemplate.getName(), tenantDomain);
throw new IdentityApplicationManagementException(errorMsg, e);
}
}
Aggregations