-
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.
Intermediate work commit - feature incomplete
- Loading branch information
Showing
10 changed files
with
136 additions
and
30 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
26 changes: 12 additions & 14 deletions
26
backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/beacon/ShibuiDetail.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,21 +1,19 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.beacon; | ||
|
|
||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Data | ||
| @Builder | ||
| public class ShibuiDetail { | ||
|
|
||
|
|
||
| // "shibui": { | ||
| // "authMechanisms": [ | ||
| // "pac4j-saml" | ||
| // ], | ||
| // "numberOfMetadataSources": 25, | ||
| // "numberOfMetadataProviders": 3, | ||
| // "numberOfFilters": 0, | ||
| // "dailyLogins": 12, | ||
| // "numberOfGroups": 15, | ||
| // "numberOfRoles": 5, | ||
| // "installationID": "4813c762-4a90-40a2-9c01-81bf67647da4" | ||
| // } | ||
| private List<String> authMechanisms; | ||
| private int numberOfMetadataSources; | ||
| private int numberOfMetadataProviders; | ||
| private int numberOfFilters; | ||
| private int dailyLogins; | ||
| private int numberOfGroups; | ||
| private int numberOfRoles; | ||
| private String installationID; | ||
| } |
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
25 changes: 25 additions & 0 deletions
25
...end/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/BeaconController.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,25 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.controller; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import edu.internet2.tier.shibboleth.admin.ui.service.IBeaconDataService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @Profile({"dev", "very-dangerous"}) | ||
| @RestController | ||
| @RequestMapping(value = "/api/beacon") | ||
| public class BeaconController { | ||
|
|
||
| @Autowired | ||
| private IBeaconDataService service; | ||
|
|
||
|
|
||
| @GetMapping(value = "/detail") | ||
| public ResponseEntity<?> getDetail() throws JsonProcessingException { | ||
| return ResponseEntity.ok(service.getBeaconData()); | ||
| } | ||
| } |
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
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
6 changes: 5 additions & 1 deletion
6
...end/src/main/java/edu/internet2/tier/shibboleth/admin/ui/repository/FilterRepository.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,8 +1,12 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.repository; | ||
|
|
||
| import edu.internet2.tier.shibboleth.admin.ui.domain.filters.MetadataFilter; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.CrudRepository; | ||
|
|
||
| public interface FilterRepository extends CrudRepository<MetadataFilter, Long> { | ||
| MetadataFilter findByResourceId(String resourceId); | ||
| } | ||
|
|
||
| @Query("SELECT COUNT(f) FROM MetadataFilter f WHERE f.filterEnabled = true") | ||
| int getActiveFilterCount(); | ||
| } |
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
59 changes: 52 additions & 7 deletions
59
...d/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/BeaconDataServiceImpl.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,33 +1,78 @@ | ||
| package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import edu.internet2.tier.shibboleth.admin.ui.beacon.BeaconDetail; | ||
| import edu.internet2.tier.shibboleth.admin.ui.beacon.ShibuiDetail; | ||
| import edu.internet2.tier.shibboleth.admin.ui.domain.BeaconConfiguration; | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.BeaconConfigurationRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.FilterRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.repository.GroupsRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.repository.RoleRepository; | ||
| import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService; | ||
| import lombok.SneakyThrows; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.springframework.boot.actuate.info.InfoEndpoint; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Map; | ||
|
|
||
| public class BeaconDataServiceImpl implements IBeaconDataService { | ||
| private ObjectMapper mapper; | ||
| private String productName; | ||
| private String tierVersion; | ||
| private String version; | ||
|
|
||
| public BeaconDataServiceImpl(String productName, InfoEndpoint info) { | ||
| private EntityDescriptorRepository entityDescriptorRepository; | ||
| private MetadataResolverRepository metadataResolverRepository; | ||
| private FilterRepository filterRepository; | ||
| private GroupsRepository groupsRepository; | ||
| private RoleRepository roleRepository; | ||
| private BeaconConfigurationRepository beaconConfigurationRepository; | ||
| private UserService userService; | ||
|
|
||
| public BeaconDataServiceImpl(String productName, InfoEndpoint info, String tierVersion, EntityDescriptorRepository entityDescriptorRepository, | ||
| MetadataResolverRepository metadataResolverRepository, FilterRepository filterRepository, GroupsRepository groupsRepository, | ||
| RoleRepository roleRepository, BeaconConfigurationRepository beaconConfigurationRepository, UserService userService) { | ||
| mapper = new ObjectMapper(); | ||
| mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // skip any null values | ||
|
|
||
| this.productName = productName; | ||
| version = info.info().get("build") == null ? "unknown" : ((Map)info.info().get("build")).get("version").toString(); | ||
| this.version = info.info().get("build") == null ? "unknown" : ((Map)info.info().get("build")).get("version").toString(); | ||
| this.tierVersion = StringUtils.isBlank(tierVersion) ? "NA" : tierVersion; | ||
|
|
||
| this.entityDescriptorRepository = entityDescriptorRepository; | ||
| this.metadataResolverRepository = metadataResolverRepository; | ||
| this.filterRepository = filterRepository; | ||
| this.groupsRepository = groupsRepository; | ||
| this.roleRepository = roleRepository; | ||
| this.beaconConfigurationRepository = beaconConfigurationRepository; | ||
| this.userService = userService; | ||
| } | ||
|
|
||
| @Override | ||
| @SneakyThrows | ||
| public String getBeaconData() throws JsonProcessingException { | ||
| BeaconDetail detail = new BeaconDetail(); | ||
| detail.setTbProduct(productName); | ||
| detail.setTbProductVersion(version); | ||
| public String getBeaconData() { | ||
| BeaconDetail detail = new BeaconDetail().setTbProduct(productName).setTbProductVersion(version).setTbTIERRelease(tierVersion).setShibui(getShibuiDetailData()); | ||
|
|
||
| return mapper.writeValueAsString(detail); | ||
| } | ||
|
|
||
| private ShibuiDetail getShibuiDetailData() { | ||
| BeaconConfiguration configuration = beaconConfigurationRepository.getReferenceById(1); | ||
|
|
||
| ShibuiDetail detail = ShibuiDetail.builder() | ||
| .installationID(configuration.getInstallationId()) | ||
| .authMechanisms(Arrays.asList(BeaconConfiguration.getAuthMechanisms().split(","))) | ||
| .numberOfMetadataSources(entityDescriptorRepository.getActiveEntityCount()) | ||
| .numberOfMetadataProviders(metadataResolverRepository.getActiveMetadataProviderCount()) | ||
| .numberOfFilters(filterRepository.getActiveFilterCount()) | ||
| .dailyLogins(userService.getDailyLoginCount()) | ||
| .numberOfGroups((int) groupsRepository.count()) | ||
| .numberOfRoles((int) roleRepository.count()) | ||
| .build(); | ||
| return detail; | ||
| } | ||
| } |
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,16 @@ | ||
| { | ||
| "git": { | ||
| "branch": "feature/shibui-2571", | ||
| "commit": { | ||
| "id": "b547925", | ||
| "time": "2023-05-23T20:32:38Z" | ||
| } | ||
| }, | ||
| "build": { | ||
| "artifact": "shibui", | ||
| "name": "backend", | ||
| "time": "2023-05-24T17:15:28.585Z", | ||
| "version": "1.18.0-SNAPSHOT", | ||
| "group": "edu.internet2.tier.shibboleth.admin.ui" | ||
| } | ||
| } |