use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class CacheBackedApplicationDAO method updateApplication.
public void updateApplication(ServiceProvider serviceProvider, String tenantDomain) throws IdentityApplicationManagementException {
ServiceProvider storedApp = getApplication(serviceProvider.getApplicationID());
clearAllAppCache(storedApp, tenantDomain);
appDAO.updateApplication(serviceProvider, tenantDomain);
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class CacheBackedApplicationDAO method getApplicationFromCache.
private ServiceProvider getApplicationFromCache(int appId, String tenantDomain) {
ServiceProvider serviceProvider = null;
ServiceProviderIDCacheKey cacheKey = new ServiceProviderIDCacheKey(appId);
ServiceProviderIDCacheEntry entry = appCacheByID.getValueFromCache(cacheKey, tenantDomain);
if (entry != null) {
serviceProvider = entry.getServiceProvider();
}
if (serviceProvider == null) {
if (log.isDebugEnabled()) {
log.debug("Cache missing for the application with id " + appId);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Cache present for the application with id " + appId);
}
}
return serviceProvider;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class FileBasedApplicationDAO method getAllRequestedClaimsByServiceProvider.
@Override
public List<String> getAllRequestedClaimsByServiceProvider(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
ServiceProvider serviceProvider = ApplicationManagementServiceComponent.getFileBasedSPs().get(serviceProviderName);
List<String> requestedClaimList = new ArrayList<String>();
if (serviceProvider == null || serviceProvider.getClaimConfig() == null) {
return requestedClaimList;
}
ClaimMapping[] claimMappings = serviceProvider.getClaimConfig().getClaimMappings();
if (claimMappings != null && claimMappings.length > 0) {
for (ClaimMapping mapping : claimMappings) {
if (mapping.isRequested()) {
if (mapping.getRemoteClaim() != null && mapping.getRemoteClaim().getClaimUri() != null) {
requestedClaimList.add(mapping.getRemoteClaim().getClaimUri());
} else if (mapping.getLocalClaim() != null && mapping.getLocalClaim().getClaimUri() != null) {
requestedClaimList.add(mapping.getLocalClaim().getClaimUri());
}
}
}
}
return requestedClaimList;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getServiceProviderNameByClientId.
/**
* @param clientId
* @param clientType
* @param tenantDomain
* @return
* @throws IdentityApplicationManagementException
*/
@Override
public String getServiceProviderNameByClientId(String clientId, String clientType, String tenantDomain) throws IdentityApplicationManagementException {
String name = null;
// invoking the listeners
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreGetServiceProviderNameByClientId(clientId, clientType, tenantDomain)) {
return null;
}
}
if (StringUtils.isNotEmpty(clientId)) {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
name = appDAO.getServiceProviderNameByClientId(clientId, clientType, tenantDomain);
if (name == null) {
name = new FileBasedApplicationDAO().getServiceProviderNameByClientId(clientId, clientType, tenantDomain);
}
}
if (name == null) {
ServiceProvider defaultSP = ApplicationManagementServiceComponent.getFileBasedSPs().get(IdentityApplicationConstants.DEFAULT_SP_CONFIG);
name = defaultSP.getApplicationName();
}
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostGetServiceProviderNameByClientId(name, clientId, clientType, tenantDomain)) {
return null;
}
}
return name;
}
use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method marshalSP.
/**
* Convert service provider object of service provider to xml formatted string
*
* @param serviceProvider service provider to be marshaled
* @param tenantDomain tenant domain
* @return xml formatted string of the service provider
* @throws IdentityApplicationManagementException Identity Application Management Exception
*/
private String marshalSP(ServiceProvider serviceProvider, String tenantDomain) throws IdentityApplicationManagementException {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ServiceProvider.class);
Marshaller marshaller = jaxbContext.createMarshaller();
DocumentBuilderFactory docBuilderFactory = IdentityUtil.getSecuredDocumentBuilderFactory();
Document document = docBuilderFactory.newDocumentBuilder().newDocument();
marshaller.marshal(serviceProvider, document);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "AuthenticationScript inboundConfiguration");
StringWriter stringBuilder = new StringWriter();
StreamResult result = new StreamResult(stringBuilder);
transformer.transform(new DOMSource(document), result);
return stringBuilder.getBuffer().toString();
} catch (JAXBException | ParserConfigurationException | TransformerException e) {
throw new IdentityApplicationManagementException(String.format("Error in exporting Service Provider %s@%s", serviceProvider.getApplicationName(), tenantDomain), e);
}
}
Aggregations