-
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.
- Loading branch information
Showing
5 changed files
with
102 additions
and
18 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
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
18 changes: 18 additions & 0 deletions
18
...2/tier/shibboleth/admin/ui/configuration/JsonSchemaValidationComponentsConfiguration.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,18 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.configuration; | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.MetadataSourcesJsonSchemaResourceLocation; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.ResourceLoader; | ||
|
||
/** | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@Configuration | ||
public class JsonSchemaValidationComponentsConfiguration { | ||
|
||
@Bean | ||
public MetadataSourcesJsonSchemaResourceLocation metadataSourcesJsonSchemaResourceLocation(ResourceLoader resourceLoader) { | ||
return new MetadataSourcesJsonSchemaResourceLocation(resourceLoader); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...du/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaValidationFailedException.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.jsonschema; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Indicates JSON schema validation failure. Encapsulates a list of error messages produced by JSON schema validator | ||
* component. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
public class JsonSchemaValidationFailedException extends RuntimeException { | ||
|
||
private final List<String> errors; | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ernet2/tier/shibboleth/admin/ui/jsonschema/MetadataSourcesJsonSchemaResourceLocation.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,58 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.jsonschema; | ||
|
||
import org.springframework.beans.factory.BeanCreationException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.core.io.ResourceLoader; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
/** | ||
* Encapsulates metadata sources JSON schema location. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@ConfigurationProperties("shibui") | ||
public class MetadataSourcesJsonSchemaResourceLocation { | ||
|
||
//Configured via @ConfigurationProperties with 'shibui.metadata-sources-ui-schema-location' property and default | ||
//value set here if that property is not explicitly set in application.properties | ||
private String metadataSourcesUiSchemaLocation = "classpath:metadata-sources-ui-schema.json"; | ||
|
||
private URL jsonSchemaUrl; | ||
|
||
ResourceLoader resourceLoader; | ||
|
||
public MetadataSourcesJsonSchemaResourceLocation(ResourceLoader resourceLoader) { | ||
this.resourceLoader = resourceLoader; | ||
} | ||
|
||
public URL getUrl() { | ||
return this.jsonSchemaUrl; | ||
} | ||
|
||
public URI getUri() { | ||
try { | ||
return this.jsonSchemaUrl.toURI(); | ||
} | ||
catch (URISyntaxException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
|
||
@PostConstruct | ||
public void init() { | ||
try { | ||
this.jsonSchemaUrl = this.resourceLoader.getResource(this.metadataSourcesUiSchemaLocation).getURL(); | ||
} | ||
catch (IOException ex) { | ||
throw new BeanCreationException(ex.getMessage(), ex); | ||
} | ||
} | ||
} |