-
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.
Merge branch 'master' of bitbucket.org:unicon/shib-idp-ui into react
- Loading branch information
Showing
13 changed files
with
598 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,6 +400,7 @@ rdurable | |
build-no-tests | ||
|
||
beacon/spring/out | ||
/.classpath | ||
|
||
# Eclipse junk | ||
*.classpath | ||
|
17 changes: 17 additions & 0 deletions
17
...rc/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/ETagsConfiguration.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,17 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.configuration; | ||
|
||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.filter.ShallowEtagHeaderFilter; | ||
|
||
@Configuration | ||
public class ETagsConfiguration { | ||
@Bean | ||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
FilterRegistrationBean<ShallowEtagHeaderFilter> filterRegistrationBean = new FilterRegistrationBean<>(new ShallowEtagHeaderFilter()); | ||
filterRegistrationBean.addUrlPatterns("/api/entities/*", "/entities/*"); | ||
filterRegistrationBean.setName("etagFilter"); | ||
return filterRegistrationBean; | ||
} | ||
} |
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
104 changes: 104 additions & 0 deletions
104
...in/java/edu/internet2/tier/shibboleth/admin/ui/controller/CustomAttributesController.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,104 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.domain.CustomAttributeDefinition; | ||
import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor; | ||
import edu.internet2.tier.shibboleth.admin.ui.service.CustomAttributesService; | ||
|
||
@Controller | ||
@RequestMapping(value = "/api/custom") | ||
public class CustomAttributesController { | ||
@Autowired | ||
private CustomAttributesService caService; | ||
|
||
@PostMapping("/attribute") | ||
@Transactional | ||
public ResponseEntity<?> create(@RequestBody CustomAttributeDefinition definition) { | ||
// If already defined, we can't create a new one, nor will this call update the definition | ||
CustomAttributeDefinition cad = caService.find(definition.getName()); | ||
|
||
if (cad != null) { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setLocation(ServletUriComponentsBuilder.fromCurrentServletMapping().path("/api/custom/attribute").build().toUri()); | ||
|
||
return ResponseEntity.status(HttpStatus.CONFLICT).headers(headers) | ||
.body(new ErrorResponse(String.valueOf(HttpStatus.CONFLICT.value()), | ||
String.format("The custom attribute definition with name: [%s] already exists.", definition.getName()))); | ||
} | ||
|
||
CustomAttributeDefinition result = caService.createOrUpdateDefinition(definition); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(result); | ||
} | ||
|
||
@PutMapping("/attribute") | ||
@Transactional | ||
public ResponseEntity<?> update(@RequestBody CustomAttributeDefinition definition) { | ||
CustomAttributeDefinition cad = caService.find(definition.getName()); | ||
if (cad == null) { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setLocation(ServletUriComponentsBuilder.fromCurrentServletMapping().path("/api/custom/attribute").build().toUri()); | ||
|
||
return ResponseEntity.status(HttpStatus.NOT_FOUND).headers(headers) | ||
.body(new ErrorResponse(String.valueOf(HttpStatus.NOT_FOUND.value()), | ||
String.format("The custom attribute definition with name: [%s] does not already exist.", definition.getName()))); | ||
} | ||
|
||
CustomAttributeDefinition result = caService.createOrUpdateDefinition(definition); | ||
return ResponseEntity.ok(result); | ||
} | ||
|
||
@GetMapping("/attributes") | ||
@Transactional(readOnly = true) | ||
public ResponseEntity<?> getAll() { | ||
return ResponseEntity.ok(caService.getAllDefinitions()); | ||
} | ||
|
||
@GetMapping("/attribute/{name}") | ||
@Transactional(readOnly = true) | ||
public ResponseEntity<?> getOne(@PathVariable String name) { | ||
CustomAttributeDefinition cad = caService.find(name); | ||
if (cad == null) { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setLocation( | ||
ServletUriComponentsBuilder.fromCurrentServletMapping().path("/api/custom/attribute/" + name).build().toUri()); | ||
|
||
return ResponseEntity.status(HttpStatus.NOT_FOUND).headers(headers) | ||
.body(new ErrorResponse(String.valueOf(HttpStatus.NOT_FOUND.value()), | ||
String.format("The custom attribute definition with name: [%s] does not already exist.", name))); | ||
} | ||
return ResponseEntity.ok(cad); | ||
} | ||
|
||
@DeleteMapping("/attribute/{name}") | ||
@Transactional | ||
public ResponseEntity<?> delete(@PathVariable String name) { | ||
CustomAttributeDefinition cad = caService.find(name); | ||
if (cad == null) { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setLocation( | ||
ServletUriComponentsBuilder.fromCurrentServletMapping().path("/api/custom/attribute/" + name).build().toUri()); | ||
|
||
return ResponseEntity.status(HttpStatus.NOT_FOUND).headers(headers) | ||
.body(new ErrorResponse(String.valueOf(HttpStatus.NOT_FOUND.value()), | ||
String.format("The custom attribute definition with name: [%s] does not already exist.", name))); | ||
} | ||
caService.deleteDefinition(cad); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
72 changes: 49 additions & 23 deletions
72
...d/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntitiesController.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
44 changes: 44 additions & 0 deletions
44
...rc/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/CustomAttributeDefinition.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,44 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.domain; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.persistence.CollectionTable; | ||
import javax.persistence.Column; | ||
import javax.persistence.ElementCollection; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
|
||
import org.hibernate.envers.Audited; | ||
|
||
import lombok.Data; | ||
|
||
@Entity(name = "custom_attribute_definition") | ||
@Audited | ||
@Data | ||
public class CustomAttributeDefinition { | ||
@Id | ||
@Column(nullable = false) | ||
String name; | ||
|
||
@Column(name = "help_text", nullable = true) | ||
String helpText; | ||
|
||
@Column(name = "attribute_type", nullable = false) | ||
CustomAttributeType attributeType; | ||
|
||
@Column(name = "default_value", nullable = true) | ||
String defaultValue; | ||
|
||
@ElementCollection | ||
@CollectionTable(name = "custom_attr_list_defs", joinColumns = @JoinColumn(name = "name")) | ||
@Column(name = "value", nullable = false) | ||
Set<String> customAttrListDefinitions = new HashSet<>(); | ||
|
||
// @TODO: logic to ensure defaultValue matches an item from the list of values when SELECTION_LIST is the type ?? | ||
} | ||
|
||
enum CustomAttributeType { | ||
BOOLEAN, INTEGER, LONG, DOUBLE, DURATION, SELECTION_LIST, SPRING_BEAN_ID | ||
} |
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
20 changes: 20 additions & 0 deletions
20
...ain/java/edu/internet2/tier/shibboleth/admin/ui/repository/CustomAttributeRepository.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,20 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.domain.CustomAttributeDefinition; | ||
|
||
/** | ||
* Repository to manage {@link CustomAttributeDefinition} instances. | ||
*/ | ||
public interface CustomAttributeRepository extends JpaRepository<CustomAttributeDefinition, String> { | ||
|
||
List<CustomAttributeDefinition> findAll(); | ||
|
||
CustomAttributeDefinition findByName(String name); | ||
|
||
@SuppressWarnings("unchecked") | ||
CustomAttributeDefinition save(CustomAttributeDefinition attribute); | ||
} |
17 changes: 17 additions & 0 deletions
17
...src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/CustomAttributesService.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,17 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.service; | ||
|
||
import java.util.List; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.domain.CustomAttributeDefinition; | ||
|
||
public interface CustomAttributesService { | ||
|
||
CustomAttributeDefinition createOrUpdateDefinition(CustomAttributeDefinition definition); | ||
|
||
void deleteDefinition(CustomAttributeDefinition definition); | ||
|
||
CustomAttributeDefinition find(String name); | ||
|
||
List<CustomAttributeDefinition> getAllDefinitions(); | ||
|
||
} |
Oops, something went wrong.