Skip to content

Commit

Permalink
Merge branch 'master' into feature/repo-ng
Browse files Browse the repository at this point in the history
# Conflicts:
#	repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlAuditServiceImpl.java
  • Loading branch information
virgo47 committed Jun 23, 2020
2 parents 043a18d + d4ff5b6 commit 96b6084
Show file tree
Hide file tree
Showing 32 changed files with 426 additions and 394 deletions.
2 changes: 1 addition & 1 deletion config/sql/h2-4.2-all.sql
Expand Up @@ -1184,6 +1184,6 @@ ALTER TABLE m_user
ALTER TABLE m_value_policy
ADD CONSTRAINT fk_value_policy FOREIGN KEY (oid) REFERENCES m_object;

INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');

COMMIT;
Expand Up @@ -3,4 +3,6 @@
CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue);

UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';

COMMIT;
2 changes: 1 addition & 1 deletion config/sql/mysql-4.2-all-utf8mb4.sql
Expand Up @@ -1406,7 +1406,7 @@ ALTER TABLE m_user
ALTER TABLE m_value_policy
ADD CONSTRAINT fk_value_policy FOREIGN KEY (oid) REFERENCES m_object (oid);

INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');

# By: Ron Cordell - roncordell
# I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.
Expand Down
2 changes: 1 addition & 1 deletion config/sql/mysql-4.2-all.sql
Expand Up @@ -1406,7 +1406,7 @@ ALTER TABLE m_user
ALTER TABLE m_value_policy
ADD CONSTRAINT fk_value_policy FOREIGN KEY (oid) REFERENCES m_object (oid);

INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');

# By: Ron Cordell - roncordell
# I didn't see this anywhere, so I thought I'd post it here. This is the script from Quartz to create the tables in a MySQL database, modified to use INNODB instead of MYISAM.
Expand Down
Expand Up @@ -3,4 +3,6 @@
CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue);

UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';

COMMIT;
Expand Up @@ -3,4 +3,6 @@
CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue);

UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';

COMMIT;
Expand Up @@ -1208,7 +1208,7 @@ CREATE INDEX iOrgOrgTypeOid ON M_ORG_ORG_TYPE(ORG_OID) INITRANS 30;
CREATE INDEX iServiceTypeOid ON M_SERVICE_TYPE(SERVICE_OID) INITRANS 30;
CREATE INDEX iTaskDependentOid ON M_TASK_DEPENDENT(TASK_OID) INITRANS 30;

INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');

--
-- A hint submitted by a user: Oracle DB MUST be created as "shared" and the
Expand Down
Expand Up @@ -3,4 +3,6 @@
CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue) INITRANS 30;

UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';

COMMIT;
Expand Up @@ -1203,7 +1203,7 @@ CREATE INDEX iOrgOrgTypeOid ON M_ORG_ORG_TYPE(ORG_OID);
CREATE INDEX iServiceTypeOid ON M_SERVICE_TYPE(SERVICE_OID);
CREATE INDEX iTaskDependentOid ON M_TASK_DEPENDENT(TASK_OID);

INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');

-- Thanks to Patrick Lightbody for submitting this...
--
Expand Down
Expand Up @@ -3,4 +3,6 @@
CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue);

UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';

COMMIT;
Expand Up @@ -1183,7 +1183,7 @@ ALTER TABLE m_value_policy
ADD CONSTRAINT fk_value_policy FOREIGN KEY (oid) REFERENCES m_object;

BEGIN TRANSACTION
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.0');
INSERT INTO m_global_metadata VALUES ('databaseSchemaVersion', '4.2');
COMMIT;

--# thanks to George Papastamatopoulos for submitting this ... and Marko Lahma for
Expand Down
10 changes: 10 additions & 0 deletions config/sql/sqlserver-upgrade-4.0-4.2.sql
@@ -0,0 +1,10 @@
-- 2020-05-29 09:20

CREATE INDEX iOpExecTimestampValue
ON m_operation_execution (timestampValue);

BEGIN TRANSACTION
UPDATE m_global_metadata SET value = '4.2' WHERE name = 'databaseSchemaVersion';
COMMIT;

GO
6 changes: 0 additions & 6 deletions config/sql/sqlserver-upgrade-4.1-4.2.sql

This file was deleted.

Expand Up @@ -11,9 +11,9 @@
import static org.springframework.security.saml.util.StringUtils.stripStartingSlashes;

import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;

import com.evolveum.midpoint.model.common.SystemObjectCache;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;

Expand Down Expand Up @@ -226,23 +226,20 @@ public static AuthenticationSequenceType getSequenceByPath(HttpServletRequest ht

public static List<AuthenticationSequenceType> getSequencesForNodeGroups(Collection<ObjectReferenceType> nodeGroups,
AuthenticationsPolicyType authenticationPolicy) {
List<String> nodeGroupsOid = new ArrayList<>();
nodeGroups.forEach(nodeGroup -> {
if (nodeGroup != null && nodeGroup.getOid() != null && !nodeGroup.getOid().isEmpty()) {
nodeGroupsOid.add(nodeGroup.getOid());
}
});
Set<String> nodeGroupsOid = nodeGroups.stream()
.map(ObjectReferenceType::getOid)
.collect(Collectors.toSet());

List<AuthenticationSequenceType> sequences = new ArrayList<>();
authenticationPolicy.getSequence().forEach(sequence -> {
if (sequence != null) {
if (sequence.getNodeGroup().isEmpty()) {
sequences.add(sequence);
addSequenceToPoll(sequences, sequence, false);
} else {
for (ObjectReferenceType nodeGroup : sequence.getNodeGroup()) {
if (nodeGroup != null && nodeGroup.getOid() != null && !nodeGroup.getOid().isEmpty()
&& nodeGroupsOid.contains(nodeGroup.getOid())) {
sequences.add(sequence);
addSequenceToPoll(sequences, sequence, true);
return;
}
}
Expand All @@ -252,6 +249,41 @@ public static List<AuthenticationSequenceType> getSequencesForNodeGroups(Collect
return sequences;
}

private static void addSequenceToPoll(List<AuthenticationSequenceType> sequences, AuthenticationSequenceType addingSequence, boolean replace) {
if (sequences.isEmpty()) {
sequences.add(addingSequence);
return;
} else if (addingSequence == null) {
throw new IllegalArgumentException("Comparing sequence is null");
}
boolean isDefaultAddSeq = Boolean.TRUE.equals(addingSequence.getChannel().isDefault());
String suffixOfAddSeq = addingSequence.getChannel().getUrlSuffix();
String channelAddSeq = addingSequence.getChannel().getChannelId();
for (AuthenticationSequenceType actualSequence : sequences) {
boolean isDefaultActSeq = Boolean.TRUE.equals(actualSequence.getChannel().isDefault());
String suffixOfActSeq = actualSequence.getChannel().getUrlSuffix();
String channelActSeq = actualSequence.getChannel().getChannelId();
if (!channelAddSeq.equals(channelActSeq)) {
continue;
}
if (suffixOfAddSeq.toLowerCase().equals(suffixOfActSeq.toLowerCase())) {
if (replace) {
sequences.remove(sequences.indexOf(actualSequence));
sequences.add(addingSequence);
}
return;
}
if (isDefaultAddSeq && isDefaultActSeq) {
if (replace) {
sequences.remove(sequences.indexOf(actualSequence));
sequences.add(addingSequence);
}
return;
}
}
sequences.add(addingSequence);
}

public static String searchChannelByPath(String localePath) {
for (String prefix : LOCAL_PATH_AND_CHANNEL.keySet()) {
if (stripStartingSlashes(localePath).startsWith(prefix)) {
Expand Down
Expand Up @@ -9,6 +9,7 @@
import static org.testng.AssertJUnit.assertEquals;

import com.evolveum.midpoint.web.security.util.SecurityUtils;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceChannelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationSequenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthenticationsPolicyType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
Expand All @@ -29,18 +30,28 @@ private List<AuthenticationSequenceType> getSequences() {
AuthenticationSequenceType sequence = new AuthenticationSequenceType();
sequence.setName("sequence1");
sequence.getNodeGroup().add(getReference("1"));
sequence.setChannel(getChannel("gui1"));
sequences.add(sequence);
sequence = new AuthenticationSequenceType();
sequence.setName("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.setChannel(getChannel("gui3"));
sequences.add(sequence);
return sequences;
}

private AuthenticationSequenceChannelType getChannel(String key) {
AuthenticationSequenceChannelType channel = new AuthenticationSequenceChannelType();
channel.setUrlSuffix(key);
channel.setChannelId("channel#" + key);
return channel;
}

private ObjectReferenceType getReference(String oid) {
ObjectReferenceType ref = new ObjectReferenceType();
ref.setOid(oid);
Expand Down

0 comments on commit 96b6084

Please sign in to comment.