Skip to content

Commit

Permalink
schema cleanup: AuthenticationSequenceType.name attribute usage is re…
Browse files Browse the repository at this point in the history
…moved
  • Loading branch information
Kateryna Honchar committed May 23, 2023
1 parent e24d500 commit 8a888a0
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private String getSequenceName() {
}

private String getSequenceIdentifier(AuthenticationSequenceType seq) {
return StringUtils.isNotEmpty(seq.getIdentifier()) ? seq.getIdentifier() : seq.getName();
return seq.getIdentifier();
}

protected abstract void initCustomLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ private String getPasswordResetUrl(SecurityPolicyType securityPolicy) {

AuthenticationsPolicyType authenticationPolicy = securityPolicy.getAuthentication();
AuthenticationSequenceType sequence = SecurityUtils.getSequenceByIdentifier(resetSequenceIdOrName, authenticationPolicy);
if (sequence == null) {
// this lookup by name will be (probably) eventually removed
sequence = SecurityUtils.getSequenceByName(resetSequenceIdOrName, authenticationPolicy);
}
if (sequence == null) {
LOGGER.warn("Password reset authentication sequence '{}' does not exist", resetSequenceIdOrName);
return "";
Expand Down Expand Up @@ -164,11 +160,8 @@ private String getRegistrationUrl(SecurityPolicyType securityPolicy) {
return "";
}

AuthenticationSequenceType sequence = SecurityUtils.getSequenceByIdentifier(selfRegistrationPolicy.getAdditionalAuthenticationSequence(), securityPolicy.getAuthentication());
if (sequence == null) {
sequence = SecurityUtils.getSequenceByName(selfRegistrationPolicy.getAdditionalAuthenticationSequence(),
securityPolicy.getAuthentication());
}
AuthenticationSequenceType sequence = SecurityUtils.getSequenceByIdentifier(
selfRegistrationPolicy.getAdditionalAuthenticationSequence(), securityPolicy.getAuthentication());
if (sequence == null || sequence.getChannel() == null || sequence.getChannel().getUrlSuffix() == null) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,33 +135,6 @@ public static CsrfToken getCsrfToken() {
return (CsrfToken) httpReq.getAttribute("_csrf");
}

/**
* name attribute is deprecated, getSequenceByIdentifier should be used instead
* @param name
* @param authenticationPolicy
* @return
*/
@Deprecated
public static AuthenticationSequenceType getSequenceByName(String name, AuthenticationsPolicyType authenticationPolicy) {
if (authenticationPolicy == null || authenticationPolicy.getSequence() == null
|| authenticationPolicy.getSequence().isEmpty()) {
return null;
}

Validate.notBlank(name, "Name for searching of sequence is blank");
for (AuthenticationSequenceType sequence : authenticationPolicy.getSequence()) {
if (sequence != null) {
if (name.equals(sequence.getName()) || name.equals(sequence.getIdentifier())) {
if (sequence.getModule() == null || sequence.getModule().isEmpty()) {
return null;
}
return sequence;
}
}
}
return null;
}

public static AuthenticationSequenceType getSequenceByIdentifier(String identifier, AuthenticationsPolicyType authenticationPolicy) {
if (authenticationPolicy == null || CollectionUtils.isEmpty(authenticationPolicy.getSequence())) {
return null;
Expand Down Expand Up @@ -192,6 +165,6 @@ private static String getPathForLogout(@NotNull String prefix) {
}

public static boolean sequenceExists(AuthenticationsPolicyType policy, String identifier) {
return getSequenceByIdentifier(identifier, policy) != null || getSequenceByName(identifier, policy) != null;
return getSequenceByIdentifier(identifier, policy) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static AuthenticationsPolicyType createDefaultAuthenticationPolicy(

public static AuthenticationSequenceType createDefaultSequence() {
return new AuthenticationSequenceType()
.name(DEFAULT_SEQUENCE_IDENTIFIER)
.identifier(DEFAULT_SEQUENCE_IDENTIFIER)
.displayName(DEFAULT_SEQUENCE_DISPLAY_IDENTIFIER)
.beginChannel()
._default(true)
Expand Down Expand Up @@ -156,7 +156,7 @@ public static AuthenticationSequenceType findSequenceByIdentifier(@NotNull Secur
.getAuthentication()
.getSequence()
.stream()
.filter(s -> identifier.equals(s.getIdentifier()) || identifier.equals(s.getName()))
.filter(s -> identifier.equals(s.getIdentifier()))
.findFirst()
.orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public String getSequenceIdentifier() {
if (sequence == null) {
return null;
}
return StringUtils.isNotEmpty(sequence.getIdentifier()) ? sequence.getIdentifier() : sequence.getName();
return sequence.getIdentifier();
}

public void setSequence(AuthenticationSequenceType sequence) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private static AuthenticationSequenceType searchSequenceComparingChannelId(Strin
sequencesWithSameChannel.add(sequence);
if (Boolean.TRUE.equals(sequence.getChannel().isDefault())) {
if (sequence.getModule() == null || sequence.getModule().isEmpty()) {
LOGGER.error("Found sequence " + sequence.getName() + "not contains configuration for module");
LOGGER.error("Found sequence " + sequence.getIdentifier() + "not contains configuration for module");
return null;
}
return sequence;
Expand Down Expand Up @@ -270,7 +270,7 @@ private static AuthenticationSequenceType searchSequenceComparingUrlSuffix(Strin
for (AuthenticationSequenceType sequence : sequences) {
if (sequence != null && sequence.getChannel() != null && urlSuffix.equals(sequence.getChannel().getUrlSuffix())) {
if (sequence.getModule() == null || sequence.getModule().isEmpty()) {
LOGGER.error("Found sequence " + sequence.getName() + "not contains configuration for module");
LOGGER.error("Found sequence " + sequence.getIdentifier() + "not contains configuration for module");
return null;
}
return sequence;
Expand Down Expand Up @@ -607,7 +607,7 @@ public static boolean isAllowUpdatingAuthBehavior(boolean isUpdatingDuringUnsucc
}

public static String getAuthSequenceIdentifier(@NotNull AuthenticationSequenceType seq) {
return StringUtils.isNotEmpty(seq.getIdentifier()) ? seq.getIdentifier() : seq.getName();
return seq.getIdentifier();
}

public static boolean isUrlForAuthProcessing(HttpServletRequest httpRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ public class TestAuthSequenceUtil extends AbstractHigherUnitTest {
private List<AuthenticationSequenceType> getSequences() {
List<AuthenticationSequenceType> sequences = new ArrayList<>();
AuthenticationSequenceType sequence = new AuthenticationSequenceType();
sequence.setName("sequence1");
sequence.setIdentifier("sequence1");
sequence.getNodeGroup().add(getReference("1"));
sequence.setChannel(getChannel("gui1"));
sequences.add(sequence);
sequence = new AuthenticationSequenceType();
sequence.setName("sequence2");
sequence.setIdentifier("sequence2");
sequence.getNodeGroup().add(getReference("1"));
sequence.getNodeGroup().add(getReference("2"));
sequence.setChannel(getChannel("gui2"));
sequences.add(sequence);
sequence = new AuthenticationSequenceType();
sequence.setName("sequence3");
sequence.setIdentifier("sequence3");
sequence.setChannel(getChannel("gui3"));
sequences.add(sequence);
return sequences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ private String createPrefixLinkByAuthSequence(String channel, String nameOfSeque
AuthenticationSequenceType sequenceByName = null;
AuthenticationSequenceType defaultSequence = null;
for (AuthenticationSequenceType sequenceType : sequences) {
String sequenceIdentifier = StringUtils.isNotEmpty(sequenceType.getIdentifier()) ? sequenceType.getIdentifier() : sequenceType.getName();
String sequenceIdentifier = sequenceType.getIdentifier();
if (StringUtils.equals(sequenceIdentifier, nameOfSequence)) {
sequenceByName = sequenceType;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ private void mergeSequence(AuthenticationSequenceType sequence, AuthenticationSe
}

private boolean sequencesIdentifiersMatch(AuthenticationSequenceType sequence1, AuthenticationSequenceType sequence2) {
String identifier1 = StringUtils.isNotEmpty(sequence1.getIdentifier()) ? sequence1.getIdentifier() : sequence1.getName();
String identifier2 = StringUtils.isNotEmpty(sequence2.getIdentifier()) ? sequence2.getIdentifier() : sequence2.getName();
String identifier1 = sequence1.getIdentifier();
String identifier2 = sequence2.getIdentifier();
return identifier1 != null && StringUtils.equals(identifier1, identifier2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</httpBasic>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -37,7 +37,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</httpBasic>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -37,7 +37,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</httpBasic>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -37,7 +37,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -40,7 +40,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</httpSecQ>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -52,7 +52,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -40,7 +40,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -43,7 +43,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -42,7 +42,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -43,7 +43,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</oidc>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -42,7 +42,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</httpBasic>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -37,7 +37,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</httpSecQ>
</modules>
<sequence>
<name>admin-gui-default</name>
<identifier>admin-gui-default</identifier>
<description>
Default GUI authentication sequence.
</description>
Expand All @@ -44,7 +44,7 @@
</module>
</sequence>
<sequence>
<name>rest</name>
<identifier>rest</identifier>
<description>
Authentication sequence for REST service.
We want just OIDC auth here, HTTP basic as fallback.
Expand Down

0 comments on commit 8a888a0

Please sign in to comment.