Skip to content

Commit 2ef15c4

Browse files
committed
Validation and minor fixes
1 parent ee1eb06 commit 2ef15c4

File tree

7 files changed

+82
-30
lines changed

7 files changed

+82
-30
lines changed

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java

+14-20
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,19 @@ public UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator(
310310
public LocalAuthenticatorConfig addSystemDefinedLocalAuthenticator(LocalAuthenticatorConfig authenticatorConfig, String tenantDomain)
311311
throws AuthenticatorMgtException {
312312

313-
if (isExistingAuthenticatorNameDB(authenticatorConfig.getName(), tenantDomain)) {
314-
throw buildClientException(AuthenticatorMgtError.ERROR_AUTHENTICATOR_ALREADY_EXIST,
315-
authenticatorConfig.getName());
316-
}
317-
return dao.addSystemLocalAuthenticator(
318-
authenticatorConfig, IdentityTenantUtil.getTenantId(tenantDomain));
313+
if (isExistingAuthenticatorNameDB(authenticatorConfig.getName(), tenantDomain)) {
314+
throw buildClientException(AuthenticatorMgtError.ERROR_AUTHENTICATOR_ALREADY_EXIST,
315+
authenticatorConfig.getName());
316+
}
317+
for (LocalAuthenticatorConfig localAuthenticator: localAuthenticators){
318+
if(localAuthenticator.getName().equals(authenticatorConfig.getName())){
319+
authenticatorConfig.setEnabled(localAuthenticator.getEnabled());
320+
authenticatorConfig.setDisplayName(localAuthenticator.getDisplayName());
321+
break;
322+
}
323+
}
324+
return dao.addSystemLocalAuthenticator(
325+
authenticatorConfig, IdentityTenantUtil.getTenantId(tenantDomain));
319326
}
320327

321328
/**
@@ -328,6 +335,7 @@ public LocalAuthenticatorConfig updateAuthenticatorAmrValue(LocalAuthenticatorCo
328335

329336
LocalAuthenticatorConfig existingConfig = resolveExistingSystemLocalAuthenticator(authenticatorConfig.getName(),
330337
tenantDomain);
338+
authenticatorValidator.validateAmrValue(authenticatorConfig.getAmrValue());
331339
if (existingConfig == null) {
332340
for (LocalAuthenticatorConfig localAuthenticator : localAuthenticators) {
333341
if (localAuthenticator.getName().equals(authenticatorConfig.getName())) {
@@ -381,20 +389,6 @@ public UserDefinedLocalAuthenticatorConfig getUserDefinedLocalAuthenticator(Stri
381389
authenticatorName, IdentityTenantUtil.getTenantId(tenantDomain));
382390
}
383391

384-
// /**
385-
// * Retrieve a Local Application Authenticator configuration by name.
386-
// *
387-
// * @param authenticatorName Name of Local Application Authenticator configuration to be deleted.
388-
// * @param tenantDomain Tenant domain.
389-
// * @return Retrieved LocalAuthenticatorConfig.
390-
// * @throws AuthenticatorMgtException If an error occurs while retrieving the authenticator configuration.
391-
// */
392-
// public LocalAuthenticatorConfig getSystemLocalAuthenticator(String authenticatorName, String tenantDomain)
393-
// throws AuthenticatorMgtException {
394-
//
395-
// return dao.getSystemLocalAuthenticator(authenticatorName, IdentityTenantUtil.getTenantId(tenantDomain));
396-
// }
397-
398392
/**
399393
* Check whether any local or federated authenticator configuration exists with the given name.
400394
*

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

+10
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,14 @@ public void setAmrValue(String amrValue) {
289289

290290
this.amrValue = amrValue;
291291
}
292+
293+
/**
294+
* Get the enabled status of the Local authenticator config.
295+
*
296+
* @return enabled
297+
*/
298+
public boolean getEnabled() {
299+
300+
return enabled;
301+
}
292302
}

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/AuthenticatorMgtExceptionBuilder.java

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public enum AuthenticatorMgtError {
9494
"The provided authenticator name %s is not in the expected format %s."),
9595
ERROR_INVALID_URL("60016", "Invalid URL.",
9696
"The provided url %s is not in the expected format %s."),
97+
ERROR_INVALID_AMR_VALUE("60017", "Invalid AMR value.",
98+
"The provided AMR value %s is not in the expected format %s."),
9799

98100
// Server errors.
99101
ERROR_WHILE_ADDING_AUTHENTICATOR("65001", "Error while adding authenticator.",

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/UserDefinedLocalAuthenticatorValidator.java

+18
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class UserDefinedLocalAuthenticatorValidator {
3939
private static final String URL_REGEX = "^https?://.+";
4040
private final Pattern urlRegexPattern = Pattern.compile(URL_REGEX);
4141

42+
private static final String AMR_VALUE_REGEX = "^[a-zA-Z0-9_]{2,}$";
43+
private final Pattern amrRegexPattern = Pattern.compile(AMR_VALUE_REGEX);
44+
4245
/**
4346
* Validate the user defined local authenticator display name.
4447
*
@@ -83,4 +86,19 @@ public void validateUrl(String url) throws AuthenticatorMgtClientException {
8386
url, URL_REGEX);
8487
}
8588
}
89+
90+
/**
91+
* Validate the user defined local authenticator AMR value.
92+
*
93+
* @param amrValue The AMR value.
94+
* @throws AuthenticatorMgtClientException if the AMR value is not valid.
95+
*/
96+
public void validateAmrValue(String amrValue) throws AuthenticatorMgtClientException {
97+
98+
boolean isValidName = amrRegexPattern.matcher(amrValue).matches();
99+
if (!isValidName) {
100+
throw buildClientException(AuthenticatorMgtError.ERROR_INVALID_AMR_VALUE,
101+
amrValue, AMR_VALUE_REGEX);
102+
}
103+
}
86104
}

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/config/model/AuthenticatorConfig.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ public AuthenticatorConfig(String name, boolean enabled, String amrValue,
5656
this.enabled = enabled;
5757
this.amrValue = amrValue;
5858
this.parameterMap = parameterMap;
59-
}//Add a new constructor
59+
}
60+
61+
public AuthenticatorConfig(String name, boolean enabled, Map<String, String> parameterMap){
62+
this.name = name;
63+
this.enabled = enabled;
64+
this.parameterMap = parameterMap;
65+
}
6066

6167
/**
6268
* Deep clone of AuthenticatorConfig.

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
9797
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils;
9898
import org.wso2.carbon.identity.application.common.ApplicationAuthenticatorService;
99-
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
10099
import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig;
101100
import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig;
102101
import org.wso2.carbon.identity.application.common.model.Property;
@@ -919,9 +918,8 @@ public static SecretResolveManager getSecretConfigManager() {
919918
*/
920919
private void loadCodeForRequire() {
921920

922-
try {
923-
ClassLoader loader = FrameworkServiceComponent.class.getClassLoader();
924-
InputStream resourceStream = loader.getResourceAsStream("js/require.js");
921+
ClassLoader loader = FrameworkServiceComponent.class.getClassLoader();
922+
try (InputStream resourceStream = loader.getResourceAsStream("js/require.js")) {
925923
requireCode = IOUtils.toString(resourceStream);
926924
FrameworkServiceDataHolder.getInstance().setCodeForRequireFunction(requireCode);
927925
} catch (IOException e) {

pom.xml

+29-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<groupId>org.wso2.carbon.identity.framework</groupId>
2323
<artifactId>identity-framework</artifactId>
2424
<packaging>pom</packaging>
25-
<version>7.8.24-SNAPSHOT</version>
25+
<version>7.8.64-SNAPSHOT</version>
2626
<name>WSO2 Carbon - Platform Aggregator Pom</name>
2727
<url>http://wso2.org</url>
2828

@@ -77,6 +77,7 @@
7777
<module>components/certificate-mgt</module>
7878
<module>components/servlet-mgt</module>
7979
<module>components/system-config-mgt</module>
80+
<module>components/registration-framework</module>
8081
<module>features/extension-mgt</module>
8182
<module>components/consent-server-configs-mgt</module>
8283
<module>features/security-mgt</module>
@@ -116,6 +117,7 @@
116117
<module>features/certificate-mgt</module>
117118
<module>features/servlet-mgt</module>
118119
<module>features/system-config-mgt</module>
120+
<module>features/registration-framework</module>
119121
</modules>
120122

121123

@@ -755,6 +757,18 @@
755757
<artifactId>org.wso2.carbon.identity.ai.service.mgt.server.feature</artifactId>
756758
<version>${project.version}</version>
757759
</dependency>
760+
<dependency>
761+
<groupId>org.wso2.carbon.identity.framework</groupId>
762+
<artifactId>org.wso2.carbon.identity.user.registration.mgt.server.feature</artifactId>
763+
<type>zip</type>
764+
<version>${project.version}</version>
765+
</dependency>
766+
<dependency>
767+
<groupId>org.wso2.carbon.identity.framework</groupId>
768+
<artifactId>org.wso2.carbon.identity.user.registration.engine.server.feature</artifactId>
769+
<type>zip</type>
770+
<version>${project.version}</version>
771+
</dependency>
758772
<dependency>
759773
<groupId>com.google.api-client</groupId>
760774
<artifactId>google-api-client</artifactId>
@@ -1777,6 +1791,16 @@
17771791
<artifactId>org.wso2.carbon.identity.ai.service.mgt</artifactId>
17781792
<version>${project.version}</version>
17791793
</dependency>
1794+
<dependency>
1795+
<groupId>org.wso2.carbon.identity.framework</groupId>
1796+
<artifactId>org.wso2.carbon.identity.user.registration.mgt</artifactId>
1797+
<version>${project.version}</version>
1798+
</dependency>
1799+
<dependency>
1800+
<groupId>org.wso2.carbon.identity.framework</groupId>
1801+
<artifactId>org.wso2.carbon.identity.user.registration.engine</artifactId>
1802+
<version>${project.version}</version>
1803+
</dependency>
17801804
<dependency>
17811805
<groupId>org.wso2.carbon.identity.framework</groupId>
17821806
<artifactId>org.wso2.carbon.identity.servlet.mgt</artifactId>
@@ -1852,7 +1876,7 @@
18521876
<artifactId>jackson-dataformat-cbor</artifactId>
18531877
<version>${com.fasterxml.jackson.cbor.version}</version>
18541878
</dependency>
1855-
<!-- GraalVM related dependencies-->
1879+
<!-- GraalVM related dependencies-->
18561880
<dependency>
18571881
<groupId>org.wso2.orbit.graalvm.sdk</groupId>
18581882
<artifactId>graal-sdk</artifactId>
@@ -1886,7 +1910,7 @@
18861910
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18871911

18881912
<!-- Carbon kernel version -->
1889-
<carbon.kernel.version>4.10.34</carbon.kernel.version>
1913+
<carbon.kernel.version>4.10.36</carbon.kernel.version>
18901914
<carbon.kernel.feature.version>4.7.0</carbon.kernel.feature.version>
18911915
<carbon.kernel.package.import.version.range>[4.5.0, 5.0.0)</carbon.kernel.package.import.version.range>
18921916
<carbon.kernel.registry.imp.pkg.version>[1.0.1, 2.0.0)</carbon.kernel.registry.imp.pkg.version>
@@ -1912,7 +1936,7 @@
19121936
<carbon.identity.package.import.version.range>[5.14.0, 8.0.0)</carbon.identity.package.import.version.range>
19131937

19141938
<org.bouncycastle.imp.pkg.version.range>[0.0.0,2.0.0)</org.bouncycastle.imp.pkg.version.range>
1915-
<org.wso2.carbon.identity.organization.management.core.version>1.0.90
1939+
<org.wso2.carbon.identity.organization.management.core.version>1.1.24
19161940
</org.wso2.carbon.identity.organization.management.core.version>
19171941
<org.wso2.carbon.identity.organization.management.core.version.range>[1.0.0, 2.0.0)
19181942
</org.wso2.carbon.identity.organization.management.core.version.range>
@@ -2372,4 +2396,4 @@
23722396
</plugins>
23732397
</build>
23742398

2375-
</project>
2399+
</project>

0 commit comments

Comments
 (0)