Skip to content

Commit

Permalink
Merged in SHIBUI-905 (pull request #212)
Browse files Browse the repository at this point in the history
SHIBUI-905

Approved-by: Ryan Mathis <rmathis@unicon.net>
  • Loading branch information
dima767 authored and Jonathan Johnson committed Oct 22, 2018
2 parents 35d0508 + 4f259de commit 18aa330
Show file tree
Hide file tree
Showing 204 changed files with 5,423 additions and 5,031 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package edu.internet2.tier.shibboleth.admin.ui.controller

import com.fasterxml.jackson.databind.ObjectMapper
import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomAttributesConfiguration
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.MetadataSourcesJsonSchemaResourceLocation
import org.springframework.beans.factory.BeanInitializationException
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.core.io.ResourceLoader
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

import javax.annotation.PostConstruct

import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR

/**
* Controller implementing REST resource responsible for exposing structure definition for metadata sources user
* interface in terms of JSON schema.
*
* @author Dmitriy Kopylenko
* @author Bill Smith (wsmith@unicon.net)
*/
@RestController('/api/ui/MetadataSources')
class MetadataSourcesUiDefinitionController {

@Autowired
MetadataSourcesJsonSchemaResourceLocation jsonSchemaLocation

@Autowired
ObjectMapper jacksonObjectMapper

@Autowired
CustomAttributesConfiguration customAttributesConfiguration

@GetMapping
ResponseEntity<?> getUiDefinitionJsonSchema() {
try {
def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaLocation.url, Map)
parsedJson['properties']['attributeRelease']['widget']['data'] =
customAttributesConfiguration.getAttributes().collect {
[key: it['name'], label: it['displayName']]
}
return ResponseEntity.ok(parsedJson)
}
catch (Exception e) {
return ResponseEntity.status(INTERNAL_SERVER_ERROR)
.body([jsonParseError : e.getMessage(),
sourceUiSchemaDefinitionFile: this.jsonSchemaLocation.url])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package edu.internet2.tier.shibboleth.admin.ui.configuration;

import com.fasterxml.jackson.databind.ObjectMapper;
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.MetadataSourcesJsonSchemaResourceLocation;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;

/**
* @author Dmitriy Kopylenko
*/
@Configuration
@ConfigurationProperties("shibui")
public class JsonSchemaValidationComponentsConfiguration {

//Configured via @ConfigurationProperties (using setter method) 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";

//This setter is used by Boot's @ConfiguratonProperties binding machinery
public void setMetadataSourcesUiSchemaLocation(String metadataSourcesUiSchemaLocation) {
this.metadataSourcesUiSchemaLocation = metadataSourcesUiSchemaLocation;
}

@Bean
public MetadataSourcesJsonSchemaResourceLocation metadataSourcesJsonSchemaResourceLocation(ResourceLoader resourceLoader, ObjectMapper jacksonMapper) {
return new MetadataSourcesJsonSchemaResourceLocation(metadataSourcesUiSchemaLocation, resourceLoader, jacksonMapper);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package edu.internet2.tier.shibboleth.admin.ui.jsonschema;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.core.io.ResourceLoader;

import javax.annotation.PostConstruct;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;

/**
* Encapsulates metadata sources JSON schema location.
*
* @author Dmitriy Kopylenko
*/
public class MetadataSourcesJsonSchemaResourceLocation {

private final String metadataSourcesUiSchemaLocation;

private URL jsonSchemaUrl;

private final ResourceLoader resourceLoader;

private final ObjectMapper jacksonMapper;

private boolean detectMalformedJsonDuringInit = true;

public MetadataSourcesJsonSchemaResourceLocation(String metadataSourcesUiSchemaLocation, ResourceLoader resourceLoader, ObjectMapper jacksonMapper) {
this.metadataSourcesUiSchemaLocation = metadataSourcesUiSchemaLocation;
this.resourceLoader = resourceLoader;
this.jacksonMapper = jacksonMapper;
}

//This constructor is used in tests
public MetadataSourcesJsonSchemaResourceLocation(String metadataSourcesUiSchemaLocation,
ResourceLoader resourceLoader,
ObjectMapper jacksonMapper,
boolean detectMalformedJsonDuringInit) {
this.metadataSourcesUiSchemaLocation = metadataSourcesUiSchemaLocation;
this.resourceLoader = resourceLoader;
this.jacksonMapper = jacksonMapper;
this.detectMalformedJsonDuringInit = detectMalformedJsonDuringInit;
}

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();
if(this.detectMalformedJsonDuringInit) {
//Detect malformed JSON schema early, during application start up and fail fast with useful exception message
this.jacksonMapper.readValue(this.jsonSchemaUrl, Map.class);
}
}
catch (Exception ex) {
StringBuilder msg =
new StringBuilder(String.format("An error is detected during JSON parsing => [%s]", ex.getMessage()));
msg.append(String.format("Offending resource => [%s]", this.metadataSourcesUiSchemaLocation));

throw new BeanInitializationException(msg.toString(), ex);
}
}
}
2 changes: 2 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ shibui.logout-url=/dashboard

#shibui.default-password=

shibui.metadata-sources-ui-schema-location=classpath:metadata-sources-ui-schema.json

#Actuator endpoints (info)
# Un-comment to get full git details exposed like author, abbreviated SHA-1, commit message
#management.info.git.mode=full
Expand Down
53 changes: 21 additions & 32 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,21 @@ value.regex=Regex
value.script=Script
value.entity-id=Entity ID

value.support=Support
value.technical=Technical
value.administrative=Administrative
value.other=Other

value.signing=Signing
value.encryption=Encryption
value.both=Both

value.file-backed-http-metadata-provider=FileBackedHttpMetadataProvider
value.entity-attributes-filter=EntityAttributes Filter
value.spdescriptor=SPSSODescriptor
value.attr-auth-descriptor=AttributeAuthorityDescriptor

brand.header.title=Source Management (default)
brand.header.title=Source Management
brand.logo-link-label=Shibboleth
brand.logo-link-description=Link to Shibboleth Website
brand.logo-alt=Shibboleth Logo - Click to be directed to www.shibboleth.net
Expand All @@ -80,10 +89,6 @@ brand.footer.links-label-4=Mailing List
brand.footer.links-desc-4=Shibboleth.net open-source community mailing list
brand.footer.copyright=Copyright \u00A9 Internet2

brand.unicon=Unicon
brand.unicon-logo=Unicon Logo
brand.i2=Internet 2
brand.i2-logo=Internet 2 Logo
brand.in-partnership-with=In partnership with
brand.and=and

Expand All @@ -101,17 +106,13 @@ label.enable-this-service=Enable this service?
label.organization-name=Organization Name
label.organization-display-name=Organization Display Name
label.organization-url=Organization URL
label.contact-information=Contact Information:
label.name=Name
label.type=Type
label.email-address=Email Address
label.assertion-consumer-service-endpoints=Assertion Consumer Service Endpoints
label.my-changes=My Changes
label.their-changes=Their Changes
label.new-endpoint=New Endpoint
label.default=(default)
label.assertion-consumer-services-location=Assertion Consumer Service Location
label.assertion-consumer-service-location-binding=Assertion Consumer Service Location Binding
label.select-binding=Select Binding Type
label.mark-as-default=Mark as Default
label.attribute-name=Attribute Name
Expand All @@ -121,7 +122,6 @@ label.clear-all-attributes=Clear All Attributes
label.protocol-support-enumeration=Protocol Support Enumeration
label.select-protocol=Select Protocol
label.nameid-format=NameID Format
label.enable-this-service-opon-saving=Enable this service upon saving?
label.name-and-entity-id=Name and Entity ID
label.organization-information=Organization Information
label.contact-information=Contact Information
Expand All @@ -146,8 +146,10 @@ label.x509-certificates=X509 Certificates
label.certificate-name-display-only=Certificate Name (Display Only)
label.certificate=Certificate
label.assertion-consumer-services=Assertion Consumer Services
label.assertion-consumer-service-locations=Assertion Consumer Service Location
label.assertion-consumer-service-location-binding=Assertion Consumer Service Binding
label.assertion-consumer-service-location=Assertion Consumer Service Location
label.assertion-consumer-service-endpoint=Assertion Consumer Service Endpoints
label.default=(default)
label.assertion-consumer-service-location-binding=Assertion Consumer Service Location Binding
label.relying-party-overrides=Relying Party Overrides
label.sign-the-assertion=Sign the Assertion?
label.turn-off-encryption-of-response=Turn off Encryption of Response?
Expand All @@ -165,19 +167,13 @@ label.privacy-statement-url=Privacy Statement URL
label.contact-name=Contact Name
label.select-contact-type=Select Contact Type
label.contact-email-address=Contact Email Address
label.sign-the-assertion=Sign the Assertion
label.dont-sign-the-response=Don\u0027t Sign the Response
label.turn-off-encryption-of-response=Turn Off Encryption of Response
label.use-sha1-signing-algorithm=Use SHA1 Signing Algorithm
label.nameid-format-to-send=NameID Format to Send
label.authentication-methods-to-use=Authentication Methods to Use
label.auth-method-indexed=Authentication Method
label.ignore-any-sp-requested-authentication-method=Ignore any SP-Requested Authentication Method
label.omit-not-before-condition=Omit Not Before Condition
label.responder-id=ResponderID
label.preview-provider=Preview XML
label.search-entity-id=Search Entity Id
label.new-filter=Edit EntityAttributesFilter
label.edit-filter=Edit EntityAttributesFilter
label.min-4-chars=Minimum 4 characters.
label.new-filter=New Filter - EntityAttributes
label.service-provider=Metadata Source Name:
Expand All @@ -187,16 +183,14 @@ label.service-provider-status=Metadata Source Status:
label.current-metadata-sources=Current Metadata Sources
label.current-metadata-providers=Current Metadata Providers
label.add-a-new-metadata-provider=Add a new metadata provider
label.name-and-entityid=Name and EntityId
label.org-info=Organization Information
label.service-resolver-name-dashboard-display-only=Service Resolver Name (Dashboard Display Only)
label.service-resolver-entity-id=Service Resolver Entity ID
label.add-a-new-metadata-source=Add a new metadata source - Finish Summary
label.name-and-entityid=Name and Entity ID.
label.finish-summary-validation=Finished!
label.select-entity-id-to-copy=Select the Entity ID to copy
label.metadata-source-name-dashboard-display-only=Metadata Source Name (Dashboard Display Only)
label.service-resolver-entity-id=New Entity ID
label.new-entity-id=New Entity ID
label.sections-to-copy=Sections to Copy?
label.add-a-new-metadata-resolver=Add a new metadata source
label.how-are-you-adding-the-metadata-information=How are you adding the metadata information?
Expand All @@ -210,13 +204,12 @@ label.entity-ids-added=Entity Ids Added
label.ui-mdui-info=User Interface / MDUI Information
label.sp-sso-descriptor-info=SP SSO Descriptor Information
label.security-info=Security Information
label.assertion-consumer-services=Assertion Consumer Service
label.sp-org-info=SP/Organization Information
label.finished=Finished!
label.signing=Signing
label.encryption=Encryption
label.both=Both
label.sp-sso-descriptor-info=Organization Information
label.org-info=Organization Information
label.security-descriptor-info=Security Descriptor Information
label.entity-id=Entity ID
label.service-provider-name=Service Provider Name
Expand All @@ -243,17 +236,14 @@ label.name-id-format= Name ID Format
label.authentication-methods=Authentication Methods
label.authentication-method=Authentication Method
label.x509-certificate-available=x509 Certificate Available
label.authentication-requests-signed=Authentication Requests Signed
label.want-assertions-signed=Want Assertions Signed
label.x509-certificates=x509 Certificates
label.protocol-support-enum=Protocol Support Enumeration
label.binding=Binding
label.location-url=Location URL
label.make-default=Make Default
label.metadata-provider-name-dashboard-display-only=Metadata Provider Name (Dashboard Display Only)
label.default-authentication-methods=Default Authentication Method(s)
label.new-of-type=New { type }

label.filter-name=Filter Name (Dashboard Display Only)
label.metadata-filter-name=Metadata Filter Name (Dashboard Display Only)
label.filter-enable=Enable this Filter?
label.search-criteria=Search Criteria
Expand Down Expand Up @@ -301,6 +291,7 @@ label.metadata-provider-name=Metadata Provider Name
label.select-metadata-type=Select a metadata provider type
label.metadata-provider-status=Metadata Provider Status
label.enable-provider-upon-saving=Enable Metadata Provider upon saving?
label.certificate-type=Type

label.enable-filter=Enable Filter?
label.required-valid-until=Required Valid Until Filter
Expand All @@ -326,7 +317,6 @@ label.descriptor-info=SP SSO Descriptor Information
label.key-info=Security Information
label.assertion=Assertion Consumer Service
label.relying-party=Relying Party Overrides
label.org-info=Organization Information

label.attribute-eduPersonPrincipalName=eduPersonPrincipalName (EPPN)
label.attribute-uid=uid
Expand Down Expand Up @@ -375,6 +365,8 @@ message.entity-id-min-unique=You must add at least one entity id target and they
message.required-for-scripts=Required for Scripts
message.required-for-regex=Required for Regex

tooltip.entity-id=Entity ID
tooltip.service-provider-name=Service Provider Name (Dashboard Display Only)
tooltip.force-authn=Disallows use (or reuse) of authentication results and login flows that don\u0027t provide a real-time proof of user presence in the login process
tooltip.service-provider-name-dashboard-display-only=Service Provider Name (Dashboard Display Only)
tooltip.service-provider-entity-id=Service Provider Entity ID
Expand Down Expand Up @@ -404,9 +396,6 @@ tooltip.mdui-privacy-statement-url=The IdP Privacy Statement URL is a link to th
tooltip.mdui-logo-url=The IdP Logo URL in metadata points to an image file on a remote server. A discovery service, for example, may rely on a visual cue (i.e., a logo) instead of or in addition to the IdP Display Name.
tooltip.mdui-logo-width=The logo should have a minimum width of 100 pixels
tooltip.mdui-logo-height=The logo should have a minimum height of 75 pixels and a maximum height of 150 pixels (or the application will scale it proportionally)
tooltip.organization-name=Organization Name
tooltip.organization-display-name=Organization Display Name
tooltip.organization-url=Organization Url
tooltip.contact-name=Contact Name
tooltip.contact-type=Contact Type
tooltip.contact-email=Contact Email
Expand Down
Loading

0 comments on commit 18aa330

Please sign in to comment.