-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit
- Loading branch information
Showing
15 changed files
with
1,133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...java/edu/internet2/tier/shibboleth/admin/ui/controller/DynamicRegistrationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.controller; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.DynamicRegistrationRepresentation; | ||
| import edu.internet2.tier.shibboleth.admin.ui.exception.ForbiddenException; | ||
| import edu.internet2.tier.shibboleth.admin.ui.exception.InvalidPatternMatchException; | ||
| import edu.internet2.tier.shibboleth.admin.ui.exception.ObjectIdExistsException; | ||
| import edu.internet2.tier.shibboleth.admin.ui.service.DynamicRegistrationService; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import io.swagger.v3.oas.annotations.tags.Tags; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api") | ||
| @Tags(value = {@Tag(name = "oidc")}) | ||
| public class DynamicRegistrationController { | ||
| @Autowired | ||
| DynamicRegistrationService dynamicRegistrationService; | ||
|
|
||
| @PostMapping("/DynamicRegistration") | ||
| @Transactional | ||
| public ResponseEntity<?> create(@RequestBody DynamicRegistrationRepresentation dynRegRepresentation) throws ForbiddenException, ObjectIdExistsException, InvalidPatternMatchException { | ||
| DynamicRegistrationRepresentation persisted = dynamicRegistrationService.createNew(dynRegRepresentation); | ||
| return ResponseEntity.created(getResourceUriFor(persisted.getResourceId())).body(persisted); | ||
| } | ||
|
|
||
| @GetMapping(value = "/DynamicRegistrations", produces = "application/json") | ||
| @Transactional(readOnly = true) | ||
| public ResponseEntity<?> getAll() throws ForbiddenException { | ||
| return ResponseEntity.ok(dynamicRegistrationService.getAllDynamicRegistrationsBasedOnUserAccess()); | ||
| } | ||
|
|
||
| private static URI getResourceUriFor(String resourceId) { | ||
| return ServletUriComponentsBuilder | ||
| .fromCurrentServletMapping().path("/api/DynamicRegistration") | ||
| .pathSegment(resourceId) | ||
| .build() | ||
| .toUri(); | ||
| } | ||
|
|
||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/ActivatableType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.domain; | ||
|
|
||
| public enum ActivatableType { | ||
| ENTITY_DESCRIPTOR, METADATA_RESOLVER, FILTER | ||
| ENTITY_DESCRIPTOR, METADATA_RESOLVER, FILTER, DYNAMIC_REGISTRATION | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ | |
|
|
||
| public interface IApprovable { | ||
| String getIdOfOwner(); | ||
|
|
||
| void removeLastApproval(); | ||
| } | ||
90 changes: 90 additions & 0 deletions
90
...internet2/tier/shibboleth/admin/ui/domain/frontend/DynamicRegistrationRepresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.domain.frontend; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.oidc.DynamicRegistrationInfo; | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.oidc.GrantType; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.time.format.DateTimeFormatter; | ||
|
|
||
| @NoArgsConstructor | ||
| @Getter | ||
| @Setter | ||
| public class DynamicRegistrationRepresentation { | ||
| private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS"); | ||
|
|
||
| private String applicationType; | ||
| private boolean approved; | ||
| private String contacts; | ||
| private LocalDateTime createdDate; | ||
| private boolean enabled; | ||
| private GrantType grantType; | ||
| private String idOfOwner; | ||
| private String jwks; | ||
| private String logoUri; | ||
| private LocalDateTime modifiedDate; | ||
| private String policyUri; | ||
| private String redirectUris; | ||
| private String resourceId; | ||
| private String responseTypes; | ||
| private String scope; | ||
| private String subjectType; | ||
| private String tokenEndpointAuthMethod; | ||
| private String tosUri; | ||
| private int version; | ||
|
|
||
| public DynamicRegistrationRepresentation(DynamicRegistrationInfo dri) { | ||
| applicationType = dri.getApplicationType(); | ||
| approved = dri.isApproved(); | ||
| contacts = dri.getContacts(); | ||
| createdDate = dri.getCreatedDate(); | ||
| enabled = dri.isEnabled(); | ||
| grantType = dri.getGrantType(); | ||
| idOfOwner = dri.getIdOfOwner(); | ||
| jwks = dri.getJwks(); | ||
| logoUri = dri.getLogoUri(); | ||
| modifiedDate = dri.getModifiedDate(); | ||
| policyUri = dri.getPolicyUri(); | ||
| redirectUris = dri.getRedirectUris(); | ||
| resourceId = dri.getResourceId(); | ||
| responseTypes = dri.getResponseTypes(); | ||
| scope = dri.getScope(); | ||
| subjectType = dri.getSubjectType(); | ||
| tokenEndpointAuthMethod = dri.getTokenEndpointAuthMethod(); | ||
| tosUri = dri.getTosUri(); | ||
| version = dri.hashCode(); | ||
| } | ||
|
|
||
| public DynamicRegistrationInfo buildDynamicRegistrationInfo() { | ||
| // Approved and enabled shouldn't be handled from here, and owner shouldn't come from the UI, so we ignore all those | ||
|
|
||
| DynamicRegistrationInfo dri = new DynamicRegistrationInfo(); | ||
| dri.setApplicationType(applicationType); | ||
| // dri.setApproved(approved); | ||
| dri.setContacts(contacts); | ||
| // dri.setEnabled(enabled); | ||
| dri.setGrantType(grantType); | ||
| // dri.setIdOfOwner(idOfOwner); | ||
| dri.setJwks(jwks); | ||
| dri.setLogoUri(logoUri); | ||
| dri.setPolicyUri(policyUri); | ||
| dri.setRedirectUris(redirectUris); | ||
| dri.setResourceId(resourceId); | ||
| dri.setResponseTypes(responseTypes); | ||
| dri.setScope(scope); | ||
| dri.setSubjectType(subjectType); | ||
| dri.setTokenEndpointAuthMethod(tokenEndpointAuthMethod); | ||
| dri.setTosUri(tosUri); | ||
| return dri; | ||
| } | ||
|
|
||
| public String getCreatedDate() { | ||
| return createdDate != null ? DATE_TIME_FORMATTER.format(createdDate) : null; | ||
| } | ||
|
|
||
| public String getModifiedDate() { | ||
| return modifiedDate != null ? DATE_TIME_FORMATTER.format(modifiedDate) : null; | ||
| } | ||
| } |
78 changes: 78 additions & 0 deletions
78
...main/java/edu/internet2/tier/shibboleth/admin/ui/domain/oidc/DynamicRegistrationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.domain.oidc; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.AbstractAuditable; | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.ActivatableType; | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.IActivatable; | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.IApprovable; | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.model.Ownable; | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.model.OwnableType; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import org.hibernate.envers.Audited; | ||
|
|
||
| import javax.persistence.ElementCollection; | ||
| import javax.persistence.Entity; | ||
| import javax.persistence.FetchType; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Data | ||
| @Audited | ||
| public class DynamicRegistrationInfo extends AbstractAuditable implements Ownable, IActivatable, IApprovable { | ||
| private String applicationType; | ||
| private boolean approved; | ||
| private String contacts; | ||
| private boolean enabled; | ||
| private GrantType grantType; | ||
| private String idOfOwner; | ||
| private String jwks; | ||
| private String logoUri; | ||
| private String policyUri; | ||
| private String redirectUris; | ||
| private String resourceId; | ||
| private String responseTypes; | ||
| private String scope; | ||
| private String subjectType; | ||
| private String tokenEndpointAuthMethod; | ||
| private String tosUri; | ||
|
|
||
| @ElementCollection(fetch = FetchType.EAGER) | ||
| @EqualsAndHashCode.Exclude | ||
| private List<String> approvedBy = new ArrayList<>(); | ||
|
|
||
| @Override | ||
| public ActivatableType getActivatableType() { | ||
| return ActivatableType.DYNAMIC_REGISTRATION; | ||
| } | ||
|
|
||
| @Override | ||
| public void setEnabled(Boolean enabled) { | ||
| this.enabled = enabled; | ||
| } | ||
|
|
||
| @Override | ||
| public String getObjectId() { | ||
| return getResourceId(); | ||
| } | ||
|
|
||
| public String getResourceId() { | ||
| if (resourceId == null) { | ||
| resourceId = UUID.randomUUID().toString(); | ||
| } | ||
| return resourceId; | ||
| } | ||
|
|
||
| @Override | ||
| public OwnableType getOwnableType() { | ||
| return OwnableType.DYNAMIC_REGISTRATION; | ||
| } | ||
|
|
||
| @Override | ||
| public void removeLastApproval() { | ||
| if (!approvedBy.isEmpty()) { | ||
| approvedBy.remove(approvedBy.size() - 1); | ||
| } | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/oidc/GrantType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.domain.oidc; | ||
|
|
||
| public enum GrantType { | ||
| authorization_code, implicit, refresh_token | ||
| } |
4 changes: 2 additions & 2 deletions
4
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/model/OwnableType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.security.model; | ||
|
|
||
| public enum OwnableType { | ||
| USER, ENTITY_DESCRIPTOR, METADATA_PROVIDER | ||
| } | ||
| USER, ENTITY_DESCRIPTOR, METADATA_PROVIDER, DYNAMIC_REGISTRATION | ||
| } |
3 changes: 2 additions & 1 deletion
3
...ava/edu/internet2/tier/shibboleth/admin/ui/security/permission/ShibUiPermissibleType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.security.permission; | ||
|
|
||
| public enum ShibUiPermissibleType { | ||
| entityDescriptorProjection // represents EntityDescriptorProjections | ||
| entityDescriptorProjection, // represents EntityDescriptorProjections | ||
| dynamicRegistrationInfo | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...rnet2/tier/shibboleth/admin/ui/security/repository/DynamicRegistrationInfoRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.security.repository; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.oidc.DynamicRegistrationInfo; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface DynamicRegistrationInfoRepository extends JpaRepository<DynamicRegistrationInfo, String> { | ||
| List<DynamicRegistrationInfo> findAllByIdOfOwner(String idOfOwner); | ||
|
|
||
| DynamicRegistrationInfo findByResourceId(String id); | ||
| } |
11 changes: 11 additions & 0 deletions
11
.../main/java/edu/internet2/tier/shibboleth/admin/ui/service/DynamicRegistrationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.DynamicRegistrationRepresentation; | ||
| import edu.internet2.tier.shibboleth.admin.ui.exception.ForbiddenException; | ||
| import edu.internet2.tier.shibboleth.admin.ui.exception.ObjectIdExistsException; | ||
|
|
||
| public interface DynamicRegistrationService { | ||
| Object getAllDynamicRegistrationsBasedOnUserAccess() throws ForbiddenException; | ||
|
|
||
| DynamicRegistrationRepresentation createNew(DynamicRegistrationRepresentation dynRegRepresentation) throws ObjectIdExistsException; | ||
| } |
Oops, something went wrong.