Skip to content

Commit 6384aaf

Browse files
authored
[ENG-10291] Update the institution model to support in-progress SSO (#106)
* Add `SsoAvailability` enum and update `institution` model * Fix JavaDoc and style
1 parent 067c545 commit 6384aaf

2 files changed

Lines changed: 72 additions & 4 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.cos.cas.osf.authentication.support;
2+
3+
/**
4+
* This is {@link SsoAvailability}.
5+
*
6+
* @author Longze Chen
7+
* @since 26.1.0
8+
*/
9+
public enum SsoAvailability {
10+
11+
/**
12+
* The institution is active, has a delegation protocol, and its SSO setup has been verified.
13+
* */
14+
PUBLIC("Public"),
15+
/**
16+
* The institution is either: 1) inactive and has a delegation protocol,
17+
* or 2) active, has a delegation protocol but its SSO setup is in-progress.
18+
*/
19+
HIDDEN("Hidden"),
20+
/**
21+
* The institution does not have a delegation protocol (i.e. not eligible for SSO).
22+
*/
23+
UNAVAILABLE("Unavailable");
24+
25+
private final String id;
26+
27+
SsoAvailability(final String id) {
28+
this.id = id;
29+
}
30+
31+
public static SsoAvailability getType(final String id) throws IllegalArgumentException {
32+
if (id == null) {
33+
return null;
34+
}
35+
for (final SsoAvailability type : SsoAvailability.values()) {
36+
if (id.equals(type.getId())) {
37+
return type;
38+
}
39+
}
40+
throw new IllegalArgumentException("No matching type for id " + id);
41+
}
42+
43+
public final String getId() {
44+
return id;
45+
}
46+
}

src/main/java/io/cos/cas/osf/model/OsfInstitution.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.cos.cas.osf.model;
22

33
import io.cos.cas.osf.authentication.support.DelegationProtocol;
4+
import io.cos.cas.osf.authentication.support.SsoAvailability;
45

56
import lombok.Getter;
67
import lombok.NoArgsConstructor;
@@ -14,7 +15,8 @@
1415
import java.util.Date;
1516

1617
/**
17-
* This is {@link OsfInstitution}.
18+
* This is {@link OsfInstitution}. It maps to a subset of columns in the OSF DB table {@code osf_instittuion}.
19+
* This subset is required to support institution SSO for CAS and OSF.
1820
*
1921
* @author Longze Chen
2022
* @since 21.0.0
@@ -40,27 +42,47 @@ public class OsfInstitution extends AbstractOsfModel {
4042
@Column(name = "logout_url")
4143
private String logoutUrl;
4244

45+
/**
46+
* Maps to column {@code delegation_protocol} of table {@code osf_instittuion} in OSF database.
47+
*/
4348
@Column(name = "delegation_protocol")
4449
private String delegationProtocol;
4550

51+
/**
52+
* Maps to column {@code sso_availability} of table {@code osf_instittuion} in OSF database.
53+
*/
54+
@Column(name = "sso_availability")
55+
private String ssoAvailability;
56+
4657
@Column(name = "is_deleted")
4758
private Boolean deleted;
4859

49-
@Column(name = "sso_in_progress")
50-
private Boolean ssoInProgress;
51-
5260
@Temporal(TemporalType.TIMESTAMP)
5361
@Column(name = "deactivated")
5462
private Date dateDeactivated;
5563

5664
@Column(name = "support_email", nullable = false)
5765
private String supportEmail;
5866

67+
/**
68+
* @return the institution's delegation protocol.
69+
*/
5970
public DelegationProtocol getDelegationProtocol() {
6071
try {
6172
return DelegationProtocol.getType(delegationProtocol);
6273
} catch (final IllegalArgumentException e) {
6374
return null;
6475
}
6576
}
77+
78+
/**
79+
* @return the institution's SSO Availability.
80+
*/
81+
public SsoAvailability getSsoAvailability() {
82+
try {
83+
return SsoAvailability.getType(ssoAvailability);
84+
} catch (final IllegalArgumentException e) {
85+
return null;
86+
}
87+
}
6688
}

0 commit comments

Comments
 (0)