Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,38 @@ private ApplicationManagementServiceHolder() {

private static class ApplicationServiceHolder {

static final ApplicationManagementService SERVICE = (ApplicationManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(ApplicationManagementService.class, null);
private static final Log log = LogFactory.getLog(ApplicationServiceHolder.class);
static final ApplicationManagementService SERVICE = initializeService();

private static ApplicationManagementService initializeService() {

ApplicationManagementService service = (ApplicationManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(ApplicationManagementService.class, null);
if (service == null) {
log.warn("ApplicationManagementService is not available in OSGi context.");
} else {
log.debug("ApplicationManagementService successfully retrieved from OSGi context.");
}
return service;
}
}

private static class OAuthAdminServiceImplHolder {

static final OAuthAdminServiceImpl SERVICE = (OAuthAdminServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null);
private static final Log log = LogFactory.getLog(OAuthAdminServiceImplHolder.class);
static final OAuthAdminServiceImpl SERVICE = initializeService();

private static OAuthAdminServiceImpl initializeService() {

OAuthAdminServiceImpl service = (OAuthAdminServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null);
if (service == null) {
log.warn("OAuthAdminServiceImpl is not available in OSGi context.");
} else {
log.debug("OAuthAdminServiceImpl successfully retrieved from OSGi context.");
}
return service;
}
}

private static class STSAdminServiceInterfaceHolder {
Expand All @@ -68,71 +92,182 @@ private static class STSAdminServiceInterfaceHolder {
private static STSAdminServiceInterface initializeService() {

try {

return (STSAdminServiceInterface) PrivilegedCarbonContext
STSAdminServiceInterface service = (STSAdminServiceInterface) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(STSAdminServiceInterface.class, null);
if (service == null) {
log.warn("STSAdminServiceInterface is not available in OSGi context.");
} else {
log.debug("STSAdminServiceInterface successfully retrieved from OSGi context.");
}
return service;
} catch (NullPointerException e) {
// Catch NullPointerException if the context or the service isn't properly set.
log.debug("NullPointerException occurred while retrieving STSAdminServiceInterface. " +
"Context or service might not be available.");
"Context or service might not be available.", e);
return null;
}
}
}

private static class SAMLSSOConfigServiceImplHolder {

static final SAMLSSOConfigServiceImpl SERVICE = (SAMLSSOConfigServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(SAMLSSOConfigServiceImpl.class, null);
private static final Log log = LogFactory.getLog(SAMLSSOConfigServiceImplHolder.class);
static final SAMLSSOConfigServiceImpl SERVICE = initializeService();

private static SAMLSSOConfigServiceImpl initializeService() {

SAMLSSOConfigServiceImpl service = (SAMLSSOConfigServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(SAMLSSOConfigServiceImpl.class, null);
if (service == null) {
log.warn("SAMLSSOConfigServiceImpl is not available in OSGi context.");
} else {
log.debug("SAMLSSOConfigServiceImpl successfully retrieved from OSGi context.");
}
return service;
}
}

private static class LoginFlowAIManagerServiceHolder {

static final LoginFlowAIManager SERVICE =
(LoginFlowAIManager) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(LoginFlowAIManager.class, null);
private static final Log log = LogFactory.getLog(LoginFlowAIManagerServiceHolder.class);
static final LoginFlowAIManager SERVICE = initializeService();

private static LoginFlowAIManager initializeService() {

LoginFlowAIManager service = (LoginFlowAIManager) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(LoginFlowAIManager.class, null);
if (service == null) {
log.warn("LoginFlowAIManager is not available in OSGi context.");
} else {
log.debug("LoginFlowAIManager successfully retrieved from OSGi context.");
}
return service;
}
}

private static class OAuthServerConfigurationHolder {

static final OAuthServerConfiguration SERVICE = (OAuthServerConfiguration) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthServerConfiguration.class, null);
private static final Log log = LogFactory.getLog(OAuthServerConfigurationHolder.class);
static final OAuthServerConfiguration SERVICE = initializeService();

private static OAuthServerConfiguration initializeService() {

OAuthServerConfiguration service = (OAuthServerConfiguration) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthServerConfiguration.class, null);
if (service == null) {
log.warn("OAuthServerConfiguration is not available in OSGi context.");
} else {
log.debug("OAuthServerConfiguration successfully retrieved from OSGi context.");
}
return service;
}
}

private static class TemplateManagerHolder {

static final TemplateManager SERVICE = (TemplateManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(TemplateManager.class, null);
private static final Log log = LogFactory.getLog(TemplateManagerHolder.class);
static final TemplateManager SERVICE = initializeService();

private static TemplateManager initializeService() {

TemplateManager service = (TemplateManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(TemplateManager.class, null);
if (service == null) {
log.warn("TemplateManager is not available in OSGi context.");
} else {
log.debug("TemplateManager successfully retrieved from OSGi context.");
}
return service;
}
}

private static class CORSManagementServiceHolder {

static final CORSManagementService SERVICE = (CORSManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(CORSManagementService.class, null);
private static final Log log = LogFactory.getLog(CORSManagementServiceHolder.class);
static final CORSManagementService SERVICE = initializeService();

private static CORSManagementService initializeService() {

CORSManagementService service = (CORSManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(CORSManagementService.class, null);
if (service == null) {
log.warn("CORSManagementService is not available in OSGi context.");
} else {
log.debug("CORSManagementService successfully retrieved from OSGi context.");
}
return service;
}
}

private static class RealmServiceHolder {

static final RealmService SERVICE = (RealmService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(RealmService.class, null);
private static final Log log = LogFactory.getLog(RealmServiceHolder.class);
static final RealmService SERVICE = initializeService();

private static RealmService initializeService() {

RealmService service = (RealmService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(RealmService.class, null);
if (service == null) {
log.warn("RealmService is not available in OSGi context.");
} else {
log.debug("RealmService successfully retrieved from OSGi context.");
}
return service;
}
}

private static class APIResourceManagerHolder {

static final APIResourceManager SERVICE = (APIResourceManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(APIResourceManager.class, null);
private static final Log log = LogFactory.getLog(APIResourceManagerHolder.class);
static final APIResourceManager SERVICE = initializeService();

private static APIResourceManager initializeService() {

APIResourceManager service = (APIResourceManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(APIResourceManager.class, null);
if (service == null) {
log.warn("APIResourceManager is not available in OSGi context.");
} else {
log.debug("APIResourceManager successfully retrieved from OSGi context.");
}
return service;
}
}

private static class AuthorizedAPIManagementServiceHolder {

static final AuthorizedAPIManagementService SERVICE = (AuthorizedAPIManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(AuthorizedAPIManagementService.class, null);
private static final Log log = LogFactory.getLog(AuthorizedAPIManagementServiceHolder.class);
static final AuthorizedAPIManagementService SERVICE = initializeService();

private static AuthorizedAPIManagementService initializeService() {

AuthorizedAPIManagementService service = (AuthorizedAPIManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(AuthorizedAPIManagementService.class, null);
if (service == null) {
log.warn("AuthorizedAPIManagementService is not available in OSGi context.");
} else {
log.debug("AuthorizedAPIManagementService successfully retrieved from OSGi context.");
}
return service;
}
}

private static class OrgApplicationManagerHolder {

static final OrgApplicationManager SERVICE = (OrgApplicationManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OrgApplicationManager.class, null);
private static final Log log = LogFactory.getLog(OrgApplicationManagerHolder.class);
static final OrgApplicationManager SERVICE = initializeService();

private static OrgApplicationManager initializeService() {

OrgApplicationManager service = (OrgApplicationManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OrgApplicationManager.class, null);
if (service == null) {
log.warn("OrgApplicationManager is not available in OSGi context.");
} else {
log.debug("OrgApplicationManager successfully retrieved from OSGi context.");
}
return service;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.google.gson.Gson;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.server.application.management.v1.AdditionalSpProperty;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.Certificate;
Expand All @@ -44,13 +46,18 @@
*/
public class UpdateAdvancedConfigurations implements UpdateFunction<ServiceProvider, AdvancedApplicationConfiguration> {

private static final Log log = LogFactory.getLog(UpdateAdvancedConfigurations.class);
public static final String TYPE_JWKS = "JWKS";
public static final String TYPE_PEM = "PEM";

@Override
public void apply(ServiceProvider serviceProvider,
AdvancedApplicationConfiguration advancedConfigurations) {

if (log.isDebugEnabled()) {
log.debug("Updating advanced configurations for application: " +
serviceProvider.getApplicationName());
}
if (advancedConfigurations != null) {
handleAdditionalSpProperties(advancedConfigurations.getAdditionalSpProperties());
setIfNotNull(advancedConfigurations.getSaas(), serviceProvider::setSaasApp);
Expand Down Expand Up @@ -87,6 +94,10 @@ public void apply(ServiceProvider serviceProvider,
}
handleTrustedAppConfigurations(advancedConfigurations.getTrustedAppConfiguration(), serviceProvider);
updateCertificate(advancedConfigurations.getCertificate(), serviceProvider);
if (log.isDebugEnabled()) {
log.debug("Successfully updated advanced configurations for application: " +
serviceProvider.getApplicationName());
}
}
}

Expand Down Expand Up @@ -152,6 +163,9 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundConfig(ServicePr
private void updateCertificate(Certificate certificate, ServiceProvider serviceProvider) {

if (certificate != null) {
if (log.isDebugEnabled()) {
log.debug("Updating certificate configuration with type: " + certificate.getType());
}
if (TYPE_PEM.equals(certificate.getType())) {
setIfNotNull(certificate.getValue(), serviceProvider::setCertificateContent);
serviceProvider.setJwksUri(null);
Expand All @@ -166,6 +180,7 @@ private void handleAdditionalSpProperties(List<AdditionalSpProperty> spAdditiona

// `additionalSpProperties` not yet supported.
if (!CollectionUtils.isEmpty(spAdditionalProperties)) {
log.warn("Additional SP properties are not yet supported. Request will be rejected.");
throw buildBadRequestError(ADDITIONAL_SP_PROP_NOT_SUPPORTED.getCode(),
ADDITIONAL_SP_PROP_NOT_SUPPORTED.getDescription());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.wso2.carbon.identity.api.server.application.management.v1.core.functions.application;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.application.management.v1.core.functions.UpdateFunction;
import org.wso2.carbon.identity.application.common.model.RoleV2;
Expand All @@ -31,9 +33,15 @@
*/
public class UpdateAssociatedRoles implements UpdateFunction<ServiceProvider, AssociatedRolesConfig> {

private static final Log log = LogFactory.getLog(UpdateAssociatedRoles.class);

@Override
public void apply(ServiceProvider serviceProvider, AssociatedRolesConfig associatedRolesConfig) {

if (log.isDebugEnabled()) {
log.debug("Updating associated roles config for application: " +
serviceProvider.getApplicationName());
}
org.wso2.carbon.identity.application.common.model.AssociatedRolesConfig rolesConfig =
new org.wso2.carbon.identity.application.common.model.AssociatedRolesConfig();
if (associatedRolesConfig != null) {
Expand All @@ -47,5 +55,9 @@ public void apply(ServiceProvider serviceProvider, AssociatedRolesConfig associa
}
}
serviceProvider.setAssociatedRolesConfig(rolesConfig);
if (log.isDebugEnabled()) {
log.debug("Successfully updated associated roles config for application: " +
serviceProvider.getApplicationName());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package org.wso2.carbon.identity.api.server.application.management.v1.core.functions.application;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.identity.api.server.application.management.v1.ClaimConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.ClaimMappings;
Expand Down Expand Up @@ -44,9 +47,15 @@
*/
public class UpdateClaimConfiguration implements UpdateFunction<ServiceProvider, ClaimConfiguration> {

private static final Log log = LogFactory.getLog(UpdateClaimConfiguration.class);

@Override
public void apply(ServiceProvider application, ClaimConfiguration claimApiModel) {

if (log.isDebugEnabled()) {
log.debug("Updating claim configuration for application: " +
application.getApplicationName());
}
if (claimApiModel != null) {
ClaimConfig applicationClaimConfiguration = getClaimConfig(application);

Expand All @@ -58,6 +67,10 @@ public void apply(ServiceProvider application, ClaimConfiguration claimApiModel)
updateRoleClaimConfigs(claimApiModel.getRole(), application);
// Subject claim.
updateSubjectClaimConfigs(claimApiModel.getSubject(), application);
if (log.isDebugEnabled()) {
log.debug("Successfully updated claim configuration for application: " +
application.getApplicationName());
}
}
}

Expand Down Expand Up @@ -135,6 +148,8 @@ private void updateSubjectClaimConfigs(SubjectConfig subjectApiModel, ServicePro

if (Boolean.TRUE.equals(subjectApiModel.getMappedLocalSubjectMandatory()) &&
Boolean.FALSE.equals(subjectApiModel.getUseMappedLocalSubject())) {
log.warn("Invalid subject claim configuration: mapped local subject mandatory is true but " +
"use mapped local subject is false");
throw buildBadRequestError(ERROR_ASSERT_LOCAL_SUBJECT_IDENTIFIER_DISABLED.getCode(),
ERROR_ASSERT_LOCAL_SUBJECT_IDENTIFIER_DISABLED.getDescription());
}
Expand Down
Loading