Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pre Update Password action management related files #6281

Merged
merged 19 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
afa989b
Add Pre Update Password action management related files
ashanthamara Jan 13, 2025
12871d2
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 21, 2025
aa6d6cf
Rename feature module name
ashanthamara Jan 21, 2025
69c42f3
Add Unit test for ActionConverter
ashanthamara Jan 22, 2025
f98540a
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 23, 2025
36f70f4
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 24, 2025
861e28b
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 24, 2025
3cfd441
Add unit test for PreUpdatePasswordActionDTOModelResolver and refacto…
ashanthamara Jan 25, 2025
07baa92
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 25, 2025
31de195
Minor changes
ashanthamara Jan 25, 2025
e0969aa
Address sonarcube suggestions
ashanthamara Jan 25, 2025
604c0ad
Address comments
ashanthamara Jan 25, 2025
e1d2c83
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 25, 2025
7efdf6a
Fix component version
ashanthamara Jan 25, 2025
415638b
Error message fix
ashanthamara Jan 25, 2025
9426492
Fix package exposing issues
ashanthamara Jan 25, 2025
4154fdf
Minor fix
ashanthamara Jan 25, 2025
08e0c5b
Merge remote-tracking branch 'upstream/master' into pre-update-password
ashanthamara Jan 25, 2025
2e2c319
Update component version
ashanthamara Jan 25, 2025
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 @@ -526,7 +526,7 @@ private ActionRule populateRule(Map<String, String> propertiesFromDB, Integer te
private void addProperties(ActionDTO actionDTO, Integer tenantId) throws ActionMgtException {

Map<String, Object> propertiesMap = actionDTO.getProperties();
if (propertiesMap == null) {
if (propertiesMap == null || propertiesMap.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public Action activateAction(String actionType, String actionId, String tenantDo
ActionDTO activatedActionDTO = DAO_FACADE.activateAction(resolvedActionType, actionId,
IdentityTenantUtil.getTenantId(tenantDomain));
auditLogger.printAuditLog(ActionManagementAuditLogger.Operation.ACTIVATE, actionType, actionId);
return buildAction(resolvedActionType, activatedActionDTO);
return buildBasicAction(activatedActionDTO);
}

/**
Expand All @@ -227,7 +227,7 @@ public Action deactivateAction(String actionType, String actionId, String tenant
ActionDTO deactivatedActionDTO = DAO_FACADE.deactivateAction(resolvedActionType, actionId,
IdentityTenantUtil.getTenantId(tenantDomain));
auditLogger.printAuditLog(ActionManagementAuditLogger.Operation.DEACTIVATE, actionType, actionId);
return buildAction(resolvedActionType, deactivatedActionDTO);
return buildBasicAction(deactivatedActionDTO);
}

/**
Expand Down Expand Up @@ -418,6 +418,21 @@ private ActionDTO buildActionDTO(String actionType, String actionId, Action acti
.build();
}

private Action buildBasicAction(ActionDTO actionDTO) {

if (actionDTO == null) {
return null;
}

return new Action.ActionResponseBuilder()
.id(actionDTO.getId())
.type(actionDTO.getType())
.name(actionDTO.getName())
.description(actionDTO.getDescription())
.status(actionDTO.getStatus())
.build();
}

private Action buildAction(String actionType, ActionDTO actionDTO) {

if (actionDTO == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>user-mgt</artifactId>
<version>7.7.109-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.identity.user.pre.update.password.action</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Pre Update Password Action Management</name>
<description>The Pre Update Password Action Management backend component</description>
ashanthamara marked this conversation as resolved.
Show resolved Hide resolved
<url>http://wso2.org</url>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.action.management</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.testutil</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Private-Package>
org.wso2.carbon.identity.user.pre.update.password.action.constant,
org.wso2.carbon.identity.user.pre.update.password.action.internal
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.user.pre.update.password.action.constant,
!org.wso2.carbon.identity.user.pre.update.password.action.internal,
org.wso2.carbon.identity.user.pre.update.password.action.*;
version="${carbon.identity.package.export.version}"
</Export-Package>
<Import-Package>
org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}",
org.apache.commons.logging; version="${import.package.version.commons.logging}",
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}",
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}",
org.wso2.carbon.identity.action.management.exception; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.action.management.model; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.action.management.service; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.service; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.exception; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.certificate.management.model; version="${carbon.identity.package.import.version.range}"
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>../../../spotbugs-exclude.xml</excludeFilterFile>
<effort>Max</effort>
<threshold>High</threshold>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.user.pre.update.password.action.constant;

/**
* This class holds the constants used in Pre Update Password extension.
*/
public class PreUpdatePasswordActionConstants {

public static final String PASSWORD_SHARING_FORMAT = "passwordSharingFormat";
public static final String CERTIFICATE = "certificate";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.user.pre.update.password.action.internal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.wso2.carbon.identity.action.management.service.ActionConverter;
import org.wso2.carbon.identity.action.management.service.ActionDTOModelResolver;
import org.wso2.carbon.identity.certificate.management.service.CertificateManagementService;
import org.wso2.carbon.identity.user.pre.update.password.action.management.PreUpdatePasswordActionConverter;
import org.wso2.carbon.identity.user.pre.update.password.action.management.PreUpdatePasswordActionDTOModelResolver;

/**
* Service component for the Pre Update Password Action.
*/
@Component(
name = "pre.update.password.action.service.component",
immediate = true
)
public class PreUpdatePasswordActionServiceComponent {

private static final Log LOG = LogFactory.getLog(PreUpdatePasswordActionServiceComponent.class);

@Activate
protected void activate(ComponentContext context) {

try {
BundleContext bundleCtx = context.getBundleContext();
bundleCtx.registerService(ActionConverter.class, new PreUpdatePasswordActionConverter(), null);
LOG.debug("Pre Update Password Action Converter is enabled");

bundleCtx.registerService(ActionDTOModelResolver.class, new PreUpdatePasswordActionDTOModelResolver(),
null);
LOG.debug("Pre Update Password Action DTO Model Resolver is enabled");

LOG.debug("Pre Update Password Action bundle is activated");
} catch (Throwable e) {
LOG.error("Error while initializing Pre Update Password Action service component.", e);
}
}

@Deactivate
protected void deactivate(ComponentContext context) {

try {
BundleContext bundleCtx = context.getBundleContext();
bundleCtx.ungetService(bundleCtx.getServiceReference(PreUpdatePasswordActionConverter.class));
bundleCtx.ungetService(bundleCtx.getServiceReference(PreUpdatePasswordActionDTOModelResolver.class));
LOG.debug("Action management bundle is deactivated");
ashanthamara marked this conversation as resolved.
Show resolved Hide resolved
} catch (Throwable e) {
LOG.error("Error while deactivating Pre Update Password Action service component.", e);
}
}

@Reference(
name = "org.wso2.carbon.identity.certificate.management",
service = CertificateManagementService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetCertificateManagementService"
)
private void setCertificateManagementService(CertificateManagementService certificateManagementService) {

PreUpdatePasswordActionServiceComponentHolder.getInstance()
.setCertificateManagementService(certificateManagementService);
LOG.debug("CertificateManagementService set in PreUpdatePasswordActionServiceComponentHolder bundle.");
ashanthamara marked this conversation as resolved.
Show resolved Hide resolved
}

private void unsetCertificateManagementService(CertificateManagementService certificateManagementService) {

PreUpdatePasswordActionServiceComponentHolder.getInstance().setCertificateManagementService(null);
LOG.debug("CertificateManagementService unset in PreUpdatePasswordActionServiceComponentHolder bundle.");
}
}
Loading
Loading