Skip to content

Commit 8df2dde

Browse files
committed
Fixes #654
1 parent 7d2713e commit 8df2dde

21 files changed

+255
-807
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ SabClientIntegrationTest.java
2626
sso.txt
2727
TODO.txt
2828
queries.md
29+
ssh_docker.sh
2930

dashboard-gui/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3513,9 +3513,9 @@ caniuse-api@^3.0.0:
35133513
lodash.uniq "^4.5.0"
35143514

35153515
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001219:
3516-
version "1.0.30001636"
3517-
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz"
3518-
integrity sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==
3516+
version "1.0.30001690"
3517+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz"
3518+
integrity sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==
35193519

35203520
capture-exit@^2.0.0:
35213521
version "2.0.0"

dashboard-server/src/main/java/dashboard/Application.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import dashboard.manage.Manage;
77
import dashboard.manage.UrlResourceManage;
88
import dashboard.pdp.*;
9-
import dashboard.sab.HttpClientTransport;
109
import dashboard.sab.Sab;
11-
import dashboard.sab.SabClient;
1210
import dashboard.sab.SabClientMock;
11+
import dashboard.sab.SabRest;
1312
import dashboard.service.Services;
1413
import dashboard.service.impl.*;
1514
import dashboard.stats.Stats;
@@ -40,9 +39,12 @@ public Services services(Manage manage, @Value("${guestidp.entityids}") String g
4039
}
4140

4241
@Bean
43-
public Sab sab(HttpClientTransport httpClientTransport,
44-
@Value("${dashboard.feature.sab}") boolean sabEnabled) {
45-
return sabEnabled ? new SabClient(httpClientTransport) : new SabClientMock();
42+
public Sab sab(Manage manage,
43+
@Value("${dashboard.feature.sab}") boolean sabEnabled,
44+
@Value("${sab-rest.username}") String sabRestUserName,
45+
@Value("${sab-rest.password}") String sabRestPassword,
46+
@Value("${sab-rest.endpoint}") String restEndPointURL) {
47+
return sabEnabled ? new SabRest(manage, sabRestUserName, sabRestPassword, restEndPointURL) : new SabClientMock();
4648
}
4749

4850
@Bean

dashboard-server/src/main/java/dashboard/sab/HttpClientTransport.java

Lines changed: 0 additions & 107 deletions
This file was deleted.

dashboard-server/src/main/java/dashboard/sab/Sab.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,21 @@
1717
package dashboard.sab;
1818

1919
import java.util.Collection;
20+
import java.util.List;
2021
import java.util.Optional;
2122

2223
/**
2324
* Interface for SAB, the SURFnet Authorisation Beheer interface
2425
*/
2526
public interface Sab {
2627

27-
/**
28-
* Get the Role/organisation info for the given userId
29-
*
30-
* @param userId the userId to query for
31-
* @return SabRoleHolder
32-
*/
33-
Optional<SabRoleHolder> getRoles(String userId);
34-
3528
/**
3629
* Get all persons within the given organisation that have the given role.
3730
*/
38-
Collection<SabPerson> getPersonsInRoleForOrganization(String organisationGuid, String role);
31+
List<SabPerson> getPersonsInRoleForOrganization(String organisationGuid, String role);
3932

4033
/**
4134
* Get all persons from the given organization that have the given role
42-
*
43-
* @return
4435
*/
45-
Collection<SabPerson> getSabEmailsForOrganization(String entityId, String role);
36+
List<SabPerson> getSabEmailsForOrganization(String entityId, String role);
4637
}

dashboard-server/src/main/java/dashboard/sab/SabClient.java

Lines changed: 0 additions & 125 deletions
This file was deleted.

dashboard-server/src/main/java/dashboard/sab/SabClientMock.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import com.google.common.collect.ImmutableList;
1919
import com.google.common.collect.ImmutableMap;
2020

21-
import java.util.*;
21+
import java.util.Arrays;
22+
import java.util.Collections;
23+
import java.util.List;
24+
import java.util.Map;
2225

2326
import static java.util.Arrays.asList;
24-
import static java.util.stream.Collectors.toList;
2527

2628
/**
2729
* Mock implementation of SAB client that uses a predefined mapping of userIds to SabRoleHolders
@@ -47,19 +49,14 @@ public class SabClientMock implements Sab {
4749
);
4850

4951
@Override
50-
public Optional<SabRoleHolder> getRoles(String userId) {
51-
return Optional.ofNullable(rolesMapping.get(userId));
52-
}
53-
54-
@Override
55-
public Collection<SabPerson> getPersonsInRoleForOrganization(String organisationGuid, String role) {
52+
public List<SabPerson> getPersonsInRoleForOrganization(String organisationGuid, String role) {
5653
return sabPersons.stream()
5754
.filter(person -> person.getRoles().stream().anyMatch(r -> r.roleName.equals(role)))
58-
.collect(toList());
55+
.toList();
5956
}
6057

6158
@Override
62-
public Collection<SabPerson> getSabEmailsForOrganization(String entityId, String role) {
63-
return sabPersons;
59+
public List<SabPerson> getSabEmailsForOrganization(String entityId, String role) {
60+
return this.getPersonsInRoleForOrganization(null, role);
6461
}
6562
}

0 commit comments

Comments
 (0)