From c378bdb586a4ed6fa1617e0c7d4ad8351feaee12 Mon Sep 17 00:00:00 2001 From: thisarawelmilla Date: Sat, 14 Sep 2024 11:23:58 +0530 Subject: [PATCH] Add new authenticator property. --- .../UpdateAuthenticationSequence.java | 3 + .../v1/model/Authenticator.java | 56 ++++++++++++++++++- .../ServerAuthenticatorManagementService.java | 9 +++ .../src/main/resources/authenticators.yaml | 5 ++ .../configs/v1/model/Authenticator.java | 56 ++++++++++++++++++- .../core/ServerConfigManagementService.java | 1 + .../src/main/resources/configs.yaml | 5 ++ .../idp/v1/model/FederatedAuthenticator.java | 56 ++++++++++++++++++- .../model/FederatedAuthenticatorListItem.java | 56 ++++++++++++++++++- .../v1/model/MetaFederatedAuthenticator.java | 56 ++++++++++++++++++- .../MetaFederatedAuthenticatorListItem.java | 56 ++++++++++++++++++- .../v1/core/ServerIdpManagementService.java | 7 +++ .../src/main/resources/idp.yaml | 20 +++++++ 13 files changed, 380 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAuthenticationSequence.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAuthenticationSequence.java index 7b62ac766d..3cd63bd765 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAuthenticationSequence.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAuthenticationSequence.java @@ -31,6 +31,7 @@ import org.wso2.carbon.identity.application.common.model.ServiceProvider; import org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig; import org.wso2.carbon.identity.application.mgt.ApplicationConstants; +import org.wso2.carbon.identity.base.IdentityConstants; import java.util.ArrayList; import java.util.Collections; @@ -160,11 +161,13 @@ private AuthenticationStep buildAuthenticationStep(AuthenticationStepModel stepM LocalAuthenticatorConfig localAuthOption = new LocalAuthenticatorConfig(); localAuthOption.setEnabled(true); localAuthOption.setName(option.getAuthenticator()); + localAuthOption.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); localAuthOptions.add(localAuthOption); } else { FederatedAuthenticatorConfig federatedAuthConfig = new FederatedAuthenticatorConfig(); federatedAuthConfig.setEnabled(true); federatedAuthConfig.setName(option.getAuthenticator()); + federatedAuthConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); IdentityProvider federatedIdp = new IdentityProvider(); federatedIdp.setIdentityProviderName(option.getIdp()); diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/gen/java/org/wso2/carbon/identity/api/server/authenticators/v1/model/Authenticator.java b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/gen/java/org/wso2/carbon/identity/api/server/authenticators/v1/model/Authenticator.java index a79c8f2621..76fd698e31 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/gen/java/org/wso2/carbon/identity/api/server/authenticators/v1/model/Authenticator.java +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/gen/java/org/wso2/carbon/identity/api/server/authenticators/v1/model/Authenticator.java @@ -37,6 +37,40 @@ public class Authenticator { private String displayName; private Boolean isEnabled; +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; + @XmlType(name="TypeEnum") @XmlEnum(String.class) public enum TypeEnum { @@ -148,6 +182,24 @@ public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; } + /** + **/ + public Authenticator definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public Authenticator type(TypeEnum type) { @@ -262,6 +314,7 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.name, authenticator.name) && Objects.equals(this.displayName, authenticator.displayName) && Objects.equals(this.isEnabled, authenticator.isEnabled) && + Objects.equals(this.definedBy, authenticator.definedBy) && Objects.equals(this.type, authenticator.type) && Objects.equals(this.image, authenticator.image) && Objects.equals(this.description, authenticator.description) && @@ -271,7 +324,7 @@ public boolean equals(java.lang.Object o) { @Override public int hashCode() { - return Objects.hash(id, name, displayName, isEnabled, type, image, description, tags, self); + return Objects.hash(id, name, displayName, isEnabled, definedBy, type, image, description, tags, self); } @Override @@ -284,6 +337,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" image: ").append(toIndentedString(image)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java index a67a7bf481..af69c203fe 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/java/org/wso2/carbon/identity/api/server/authenticators/v1/core/ServerAuthenticatorManagementService.java @@ -41,6 +41,7 @@ import org.wso2.carbon.identity.application.common.model.IdentityProvider; import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig; import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig; +import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.base.IdentityException; import org.wso2.carbon.identity.core.model.ExpressionNode; import org.wso2.carbon.identity.core.model.FilterTreeBuilder; @@ -421,6 +422,13 @@ private void addIdp(IdentityProvider identityProvider, List authe authenticator.setType(Authenticator.TypeEnum.FEDERATED); authenticator.setImage(identityProvider.getImageUrl()); authenticator.setDescription(identityProvider.getIdentityProviderDescription()); + if (identityProvider.getFederatedAuthenticatorConfigs().length == 1) { + IdentityConstants.DefinedByType definedByType = + identityProvider.getFederatedAuthenticatorConfigs()[0].getDefinedByType(); + authenticator.definedBy(Authenticator.DefinedByEnum.valueOf(definedByType.toString())); + } else { + authenticator.definedBy(Authenticator.DefinedByEnum.SYSTEM); + } if (CollectionUtils.isNotEmpty(configTagsListDistinct)) { authenticator.setTags(configTagsListDistinct); } @@ -512,6 +520,7 @@ private Authenticator addLocalAuthenticator(LocalAuthenticatorConfig config) { authenticator.setDisplayName(config.getDisplayName()); authenticator.setIsEnabled(config.isEnabled()); authenticator.setType(Authenticator.TypeEnum.LOCAL); + authenticator.definedBy(Authenticator.DefinedByEnum.valueOf(config.getDefinedByType().toString())); String[] tags = config.getTags(); if (ArrayUtils.isNotEmpty(tags)) { authenticator.setTags(Arrays.asList(tags)); diff --git a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/resources/authenticators.yaml b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/resources/authenticators.yaml index fc489ae816..c91bc6ab54 100644 --- a/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/resources/authenticators.yaml +++ b/components/org.wso2.carbon.identity.api.server.authenticators/org.wso2.carbon.identity.api.server.authenticators.v1/src/main/resources/authenticators.yaml @@ -202,6 +202,11 @@ components: isEnabled: type: boolean example: true + definedBy: + type: string + enum: + - SYSTEM + - USER type: type: string enum: diff --git a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/Authenticator.java b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/Authenticator.java index ab982bc225..744e6dbe18 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/Authenticator.java +++ b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/gen/java/org/wso2/carbon/identity/api/server/configs/v1/model/Authenticator.java @@ -38,6 +38,40 @@ public class Authenticator { private String displayName; private Boolean isEnabled = true; +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; + @XmlType(name="TypeEnum") @XmlEnum(String.class) public enum TypeEnum { @@ -152,6 +186,24 @@ public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; } + /** + **/ + public Authenticator definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public Authenticator type(TypeEnum type) { @@ -238,6 +290,7 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.name, authenticator.name) && Objects.equals(this.displayName, authenticator.displayName) && Objects.equals(this.isEnabled, authenticator.isEnabled) && + Objects.equals(this.definedBy, authenticator.definedBy) && Objects.equals(this.type, authenticator.type) && Objects.equals(this.tags, authenticator.tags) && Objects.equals(this.properties, authenticator.properties); @@ -245,7 +298,7 @@ public boolean equals(java.lang.Object o) { @Override public int hashCode() { - return Objects.hash(id, name, displayName, isEnabled, type, tags, properties); + return Objects.hash(id, name, displayName, isEnabled, definedBy, type, tags, properties); } @Override @@ -258,6 +311,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java index 142d5bfe13..c3e555320d 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/java/org/wso2/carbon/identity/api/server/configs/v1/core/ServerConfigManagementService.java @@ -770,6 +770,7 @@ private Authenticator buildAuthenticatorResponse(LocalAuthenticatorConfig config authenticator.setId(base64URLEncode(config.getName())); authenticator.setName(config.getName()); authenticator.setDisplayName(config.getDisplayName()); + authenticator.setDefinedBy(Authenticator.DefinedByEnum.valueOf(config.getDefinedByType().toString())); authenticator.setIsEnabled(config.isEnabled()); if (config instanceof RequestPathAuthenticatorConfig) { authenticator.setType(Authenticator.TypeEnum.REQUEST_PATH); diff --git a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml index a7226d6ec9..62a6e34f70 100644 --- a/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml +++ b/components/org.wso2.carbon.identity.api.server.configs/org.wso2.carbon.identity.api.server.configs.v1/src/main/resources/configs.yaml @@ -1217,6 +1217,11 @@ components: isEnabled: type: boolean default: true + definedBy: + type: string + enum: + - SYSTEM + - USER type: type: string enum: diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java index 84373ee10c..5996d10619 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticator.java @@ -36,6 +36,40 @@ public class FederatedAuthenticator { private String authenticatorId; private String name; private Boolean isEnabled = false; + +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; private Boolean isDefault = false; private List tags = null; @@ -98,6 +132,24 @@ public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; } + /** + **/ + public FederatedAuthenticator definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public FederatedAuthenticator isDefault(Boolean isDefault) { @@ -183,6 +235,7 @@ public boolean equals(java.lang.Object o) { return Objects.equals(this.authenticatorId, federatedAuthenticator.authenticatorId) && Objects.equals(this.name, federatedAuthenticator.name) && Objects.equals(this.isEnabled, federatedAuthenticator.isEnabled) && + Objects.equals(this.definedBy, federatedAuthenticator.definedBy) && Objects.equals(this.isDefault, federatedAuthenticator.isDefault) && Objects.equals(this.tags, federatedAuthenticator.tags) && Objects.equals(this.properties, federatedAuthenticator.properties); @@ -190,7 +243,7 @@ public boolean equals(java.lang.Object o) { @Override public int hashCode() { - return Objects.hash(authenticatorId, name, isEnabled, isDefault, tags, properties); + return Objects.hash(authenticatorId, name, isEnabled, definedBy, isDefault, tags, properties); } @Override @@ -202,6 +255,7 @@ public String toString() { sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" isDefault: ").append(toIndentedString(isDefault)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorListItem.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorListItem.java index 1c479915aa..ea7d4d2a13 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorListItem.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/FederatedAuthenticatorListItem.java @@ -35,6 +35,40 @@ public class FederatedAuthenticatorListItem { private String authenticatorId; private String name; private Boolean isEnabled = false; + +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; private List tags = null; private String self; @@ -93,6 +127,24 @@ public void setIsEnabled(Boolean isEnabled) { this.isEnabled = isEnabled; } + /** + **/ + public FederatedAuthenticatorListItem definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public FederatedAuthenticatorListItem tags(List tags) { @@ -152,13 +204,14 @@ public boolean equals(java.lang.Object o) { return Objects.equals(this.authenticatorId, federatedAuthenticatorListItem.authenticatorId) && Objects.equals(this.name, federatedAuthenticatorListItem.name) && Objects.equals(this.isEnabled, federatedAuthenticatorListItem.isEnabled) && + Objects.equals(this.definedBy, federatedAuthenticatorListItem.definedBy) && Objects.equals(this.tags, federatedAuthenticatorListItem.tags) && Objects.equals(this.self, federatedAuthenticatorListItem.self); } @Override public int hashCode() { - return Objects.hash(authenticatorId, name, isEnabled, tags, self); + return Objects.hash(authenticatorId, name, isEnabled, definedBy, tags, self); } @Override @@ -170,6 +223,7 @@ public String toString() { sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" self: ").append(toIndentedString(self)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticator.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticator.java index d85f7cc9af..46483c4c83 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticator.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticator.java @@ -36,6 +36,40 @@ public class MetaFederatedAuthenticator { private String authenticatorId; private String name; private String displayName; + +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; private List tags = null; private List properties = null; @@ -95,6 +129,24 @@ public void setDisplayName(String displayName) { this.displayName = displayName; } + /** + **/ + public MetaFederatedAuthenticator definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public MetaFederatedAuthenticator tags(List tags) { @@ -162,13 +214,14 @@ public boolean equals(java.lang.Object o) { return Objects.equals(this.authenticatorId, metaFederatedAuthenticator.authenticatorId) && Objects.equals(this.name, metaFederatedAuthenticator.name) && Objects.equals(this.displayName, metaFederatedAuthenticator.displayName) && + Objects.equals(this.definedBy, metaFederatedAuthenticator.definedBy) && Objects.equals(this.tags, metaFederatedAuthenticator.tags) && Objects.equals(this.properties, metaFederatedAuthenticator.properties); } @Override public int hashCode() { - return Objects.hash(authenticatorId, name, displayName, tags, properties); + return Objects.hash(authenticatorId, name, displayName, definedBy, tags, properties); } @Override @@ -180,6 +233,7 @@ public String toString() { sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticatorListItem.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticatorListItem.java index b7ef4c326a..7def0a4289 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticatorListItem.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/gen/java/org/wso2/carbon/identity/api/server/idp/v1/model/MetaFederatedAuthenticatorListItem.java @@ -34,6 +34,40 @@ public class MetaFederatedAuthenticatorListItem { private String authenticatorId; private String name; + +@XmlType(name="DefinedByEnum") +@XmlEnum(String.class) +public enum DefinedByEnum { + + @XmlEnumValue("SYSTEM") SYSTEM(String.valueOf("SYSTEM")), @XmlEnumValue("USER") USER(String.valueOf("USER")); + + + private String value; + + DefinedByEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DefinedByEnum fromValue(String value) { + for (DefinedByEnum b : DefinedByEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private DefinedByEnum definedBy; private List tags = null; private String self; @@ -74,6 +108,24 @@ public void setName(String name) { this.name = name; } + /** + **/ + public MetaFederatedAuthenticatorListItem definedBy(DefinedByEnum definedBy) { + + this.definedBy = definedBy; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("definedBy") + @Valid + public DefinedByEnum getDefinedBy() { + return definedBy; + } + public void setDefinedBy(DefinedByEnum definedBy) { + this.definedBy = definedBy; + } + /** **/ public MetaFederatedAuthenticatorListItem tags(List tags) { @@ -132,13 +184,14 @@ public boolean equals(java.lang.Object o) { MetaFederatedAuthenticatorListItem metaFederatedAuthenticatorListItem = (MetaFederatedAuthenticatorListItem) o; return Objects.equals(this.authenticatorId, metaFederatedAuthenticatorListItem.authenticatorId) && Objects.equals(this.name, metaFederatedAuthenticatorListItem.name) && + Objects.equals(this.definedBy, metaFederatedAuthenticatorListItem.definedBy) && Objects.equals(this.tags, metaFederatedAuthenticatorListItem.tags) && Objects.equals(this.self, metaFederatedAuthenticatorListItem.self); } @Override public int hashCode() { - return Objects.hash(authenticatorId, name, tags, self); + return Objects.hash(authenticatorId, name, definedBy, tags, self); } @Override @@ -149,6 +202,7 @@ public String toString() { sb.append(" authenticatorId: ").append(toIndentedString(authenticatorId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" definedBy: ").append(toIndentedString(definedBy)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" self: ").append(toIndentedString(self)).append("\n"); sb.append("}"); diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java index da4f38f5c9..5ec893dfa6 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/java/org/wso2/carbon/identity/api/server/idp/v1/core/ServerIdpManagementService.java @@ -94,6 +94,7 @@ import org.wso2.carbon.identity.application.common.model.RoleMapping; import org.wso2.carbon.identity.application.common.model.SubProperty; import org.wso2.carbon.identity.application.common.util.IdentityApplicationConstants; +import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.claim.metadata.mgt.exception.ClaimMetadataException; import org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim; import org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean; @@ -1771,6 +1772,7 @@ private void updateFederatedAuthenticatorConfig(IdentityProvider idp, FederatedA authConfig.setName(base64URLDecode(authenticator.getAuthenticatorId())); authConfig.setDisplayName(getDisplayNameOfAuthenticator(authConfig.getName())); authConfig.setEnabled(authenticator.getIsEnabled()); + authConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); List authProperties = authenticator.getProperties(); if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authConfig.getName())) { @@ -2456,6 +2458,8 @@ private FederatedAuthenticatorListResponse createFederatedAuthenticatorResponse( fedAuthListItem.setAuthenticatorId(base64URLEncode(fedAuthConfig.getName())); fedAuthListItem.setName(fedAuthConfig.getName()); fedAuthListItem.setIsEnabled(fedAuthConfig.isEnabled()); + fedAuthListItem.setDefinedBy(FederatedAuthenticatorListItem.DefinedByEnum.valueOf( + fedAuthConfig.getDefinedByType().toString())); FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName( fedAuthConfig.getName()); @@ -2838,6 +2842,7 @@ private FederatedAuthenticatorConfig createFederatedAuthenticatorConfig(String f authConfig.setName(authenticatorName); authConfig.setDisplayName(getDisplayNameOfAuthenticator(authenticatorName)); authConfig.setEnabled(authenticator.getIsEnabled()); + authConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM); List authProperties = authenticator.getProperties(); if (IdentityApplicationConstants.Authenticator.SAML2SSO.FED_AUTH_NAME.equals(authenticatorName)) { validateSamlMetadata(authProperties); @@ -3030,6 +3035,8 @@ private FederatedAuthenticator createFederatedAuthenticator(String authenticator federatedAuthenticator.setName(config.getName()); federatedAuthenticator.setIsEnabled(config.isEnabled()); federatedAuthenticator.setIsDefault(isDefaultAuthenticator); + federatedAuthenticator.setDefinedBy(FederatedAuthenticator.DefinedByEnum.valueOf( + config.getDefinedByType().toString())); FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName( config.getName()); diff --git a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml index 8fee505e59..f96e152c3a 100644 --- a/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml +++ b/components/org.wso2.carbon.identity.api.server.idp/org.wso2.carbon.identity.api.server.idp.v1/src/main/resources/idp.yaml @@ -2783,6 +2783,11 @@ components: name: type: string example: SAML2Authenticator + definedBy: + type: string + enum: + - SYSTEM + - USER tags: type: array items: @@ -2804,6 +2809,11 @@ components: displayName: type: string example: 'SAML2 Web SSO Configuration' + definedBy: + type: string + enum: + - SYSTEM + - USER tags: type: array items: @@ -2849,6 +2859,11 @@ components: type: boolean default: false example: true + definedBy: + type: string + enum: + - SYSTEM + - USER isDefault: type: boolean default: false @@ -2908,6 +2923,11 @@ components: type: boolean default: false example: true + definedBy: + type: string + enum: + - SYSTEM + - USER tags: type: array items: