Skip to content

Commit

Permalink
Merge pull request #423 from VivekVinushanth/vv-fix-logconstants
Browse files Browse the repository at this point in the history
Update audit log v2 constants
  • Loading branch information
VivekVinushanth authored Mar 19, 2024
2 parents a02050b + b06b3e8 commit 7e7767d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import org.wso2.carbon.core.util.KeyStoreManager;
import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.central.log.mgt.utils.LogConstants;
import org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils;
import org.wso2.carbon.identity.core.model.SAMLSSOServiceProviderDO;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.sp.metadata.saml2.exception.InvalidMetadataException;
import org.wso2.carbon.identity.sp.metadata.saml2.util.Parser;
import org.wso2.carbon.identity.sso.saml.Error;
import org.wso2.carbon.identity.sso.saml.SAMLSSOConstants;
import org.wso2.carbon.identity.sso.saml.SSOServiceProviderConfigManager;
import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderDTO;
import org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderInfoDTO;
Expand All @@ -52,8 +53,6 @@
import java.util.Map;
import java.util.Optional;

import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.LogConstants.USER;
import static org.wso2.carbon.identity.application.mgt.ApplicationConstants.LogConstants.TARGET_APPLICATION;
import static org.wso2.carbon.identity.application.mgt.ApplicationMgtUtil.isEnableV2AuditLogs;
import static org.wso2.carbon.identity.central.log.mgt.utils.LoggerUtils.triggerAuditLogEvent;
import static org.wso2.carbon.identity.sso.saml.Error.CONFLICTING_SAML_ISSUER;
Expand Down Expand Up @@ -110,9 +109,9 @@ public boolean addRelyingPartyServiceProvider(SAMLSSOServiceProviderDTO serviceP
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(
initiatorId.get(), USER,
issuer, TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.CREATE_SAML_APPLICATION)
initiatorId.get(), LoggerUtils.Initiator.User.name(),
issuer, LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.CREATE_SAML_APPLICATION_ACTION)
.data(SAMLSSOUtil.buildSPData(serviceProviderDO));
triggerAuditLogEvent(auditLogBuilder, true);
} else {
Expand Down Expand Up @@ -179,9 +178,9 @@ public SAMLSSOServiceProviderDTO addSAMLServiceProvider(SAMLSSOServiceProviderDT
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(
initiatorId.get(), USER,
issuer, TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.CREATE_SAML_APPLICATION)
initiatorId.get(), LoggerUtils.Initiator.User.name(),
issuer, LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.CREATE_SAML_APPLICATION_ACTION)
.data(SAMLSSOUtil.buildSPData(serviceProviderDO));
triggerAuditLogEvent(auditLogBuilder, true);
} else {
Expand Down Expand Up @@ -257,8 +256,9 @@ public SAMLSSOServiceProviderDTO updateSAMLServiceProvider(SAMLSSOServiceProvide
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(
initiatorId.get(), USER, serviceProviderDO.getIssuer(), TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.UPDATE_SAML_APPLICATION)
initiatorId.get(), LoggerUtils.Initiator.User.name(), serviceProviderDO.getIssuer(),
LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.UPDATE_SAML_APPLICATION_ACTION)
.data(SAMLSSOUtil.buildSPData(serviceProviderDO));
triggerAuditLogEvent(auditLogBuilder, true);
} else {
Expand Down Expand Up @@ -385,9 +385,9 @@ public SAMLSSOServiceProviderDTO uploadRelyingPartyServiceProvider(String metada
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(
initiatorId.get(), USER,
samlssoServiceProviderDO.getIssuer(), TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.CREATE_SAML_APPLICATION)
initiatorId.get(), LoggerUtils.Initiator.User.name(),
samlssoServiceProviderDO.getIssuer(), LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.CREATE_SAML_APPLICATION_ACTION)
.data(SAMLSSOUtil.buildSPData(samlssoServiceProviderDO));
triggerAuditLogEvent(auditLogBuilder, true);
} else {
Expand Down Expand Up @@ -436,8 +436,9 @@ public SAMLSSOServiceProviderDTO updateRelyingPartyServiceProviderWithMetadata(S
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(
initiatorId.get(), USER, samlssoServiceProviderDO.getIssuer(), TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.UPDATE_SAML_APPLICATION)
initiatorId.get(), LoggerUtils.Initiator.User.name(), samlssoServiceProviderDO.getIssuer(),
LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.UPDATE_SAML_APPLICATION_ACTION)
.data(SAMLSSOUtil.buildSPData(samlssoServiceProviderDO));
triggerAuditLogEvent(auditLogBuilder, true);
} else {
Expand Down Expand Up @@ -735,8 +736,8 @@ public boolean removeServiceProvider(String issuer) throws IdentityException {
Optional<String> initiatorId = getInitiatorId();
if (initiatorId.isPresent()) {
AuditLog.AuditLogBuilder auditLogBuilder = new AuditLog.AuditLogBuilder(initiatorId.get(),
USER, issuer, TARGET_APPLICATION,
SAMLSSOConstants.LogConstants.DELETE_SAML_APPLICATION);
LoggerUtils.Initiator.User.name(), issuer, LoggerUtils.Target.Application.name(),
LogConstants.ApplicationManagement.DELETE_SAML_APPLICATION_ACTION);
triggerAuditLogEvent(auditLogBuilder, true);
} else {
log.error("Error getting the logged in userId");
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@
<properties>
<carbon.kernel.version>4.9.23</carbon.kernel.version>
<carbon.kernel.feature.version>4.9.0</carbon.kernel.feature.version>
<carbon.identity.framework.version>7.0.40</carbon.identity.framework.version>
<carbon.identity.framework.version>7.0.105</carbon.identity.framework.version>
<carbon.identity.framework.imp.pkg.version.range>[5.25.260, 8.0.0)
</carbon.identity.framework.imp.pkg.version.range>
<carbon.identity.organization.management.core.version>1.0.0</carbon.identity.organization.management.core.version>
Expand Down

0 comments on commit 7e7767d

Please sign in to comment.