Skip to content

Commit

Permalink
SHIBUI-704 resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 12, 2018
2 parents 339c516 + 4e6c571 commit 25643dd
Show file tree
Hide file tree
Showing 13 changed files with 557 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.filesystemMetadataProviderSchema
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.localDynamicMetadataProviderSchema
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.localDynamicMetadataProviderSchema
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.dynamicHttpMetadataProviderSchema
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType
Expand Down Expand Up @@ -41,9 +41,9 @@ class MetadataResolverUiDefinitionController {
case SchemaType.FILESYSTEM_METADATA_RESOLVER:
jsonSchemaLocation = filesystemMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break
/* case SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER:
case SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER:
jsonSchemaLocation = localDynamicMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break*/
break
/* case SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER:
jsonSchemaLocation = dynamicHttpMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER;
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;

/**
Expand All @@ -38,10 +38,10 @@ public class JsonSchemaComponentsConfiguration {
@Setter
private String filesystemMetadataResolverUiSchemaLocation = "classpath:file-system-metadata-provider.schema.json";

/* TODO: Will be added as part of SHIBUI-703
//Configured via @ConfigurationProperties (using setter method) with 'shibui.local-dynamic-metadata-provider-ui-schema-location' property and
// default value set here if that property is not explicitly set in application.properties
@Setter
private String localDynamicMetadataResolverUiSchemaLocation = "classpath:local-dynamic-metadata-provider.schema.json";
*/

/* TODO: Will be added as part of SHIBUI-704
@Setter
Expand All @@ -68,20 +68,19 @@ public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(Res
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build());
/*.register(DYNAMIC_HTTP_METADATA_RESOLVER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(dynamicHttpMetadataResolverUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build())
.register(LOCAL_DYNAMIC_METADATA_RESOLVER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(localDynamicMetadataResolverUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build());*/

.build());
/*.register(DYNAMIC_HTTP_METADATA_RESOLVER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(dynamicHttpMetadataResolverUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build())*/
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ public OpenSamlLocalDynamicMetadataResolver(ParserPool parserPool,

@Override
protected void initMetadataResolver() throws ComponentInitializationException {
super.initMetadataResolver();
if (sourceResolver.getDoInitialization()) {
super.initMetadataResolver();

delegate.addIndexedDescriptorsFromBackingStore(this.getBackingStore(),
this.sourceResolver.getResourceId(),
indexWriter);
delegate.addIndexedDescriptorsFromBackingStore(this.getBackingStore(),
this.sourceResolver.getResourceId(),
indexWriter);
}
}

public void refresh() throws ComponentInitializationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER;
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;

/**
Expand Down Expand Up @@ -52,11 +52,18 @@ public static JsonSchemaResourceLocation filesystemMetadataProviderSchema(JsonSc
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for filesystem metadata resolver is not registered."));
}

/* public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
/**
* Searches local dynamic metadata resolver JSON schema resource location object in the given location registry.
*
* @param resourceLocationRegistry
* @return local dynamic metadata resolver JSON schema resource location object
* @throws IllegalStateException if schema is not found in the given registry
*/
public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
return resourceLocationRegistry
.lookup(LOCAL_DYNAMIC_METADATA_RESOLVER)
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for local dynamic metadata resolver is not registered."));
}*/
}

/* public static JsonSchemaResourceLocation dynamicHttpMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
return resourceLocationRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public enum SchemaType {

// resolver types
FILE_BACKED_HTTP_METADATA_RESOLVER("FileBackedHttpMetadataResolver"),
FILESYSTEM_METADATA_RESOLVER("FilesystemMetadataResolver");
// LOCAL_DYNAMIC_METADATA_RESOLVER,
FILESYSTEM_METADATA_RESOLVER("FilesystemMetadataResolver"),
LOCAL_DYNAMIC_METADATA_RESOLVER("LocalDynamicMetadataResolver");
// DYNAMIC_HTTP_METADATA_RESOLVER;

String jsonType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ private OpenSamlLocalDynamicMetadataResolver convertToOpenSamlRepresentation(Loc
IndexWriter indexWriter = indexWriterService.getIndexWriter(resolver.getResourceId());

XMLObjectLoadSaveManager manager = null;
try {
manager = new FilesystemLoadSaveManager(placeholderResolverService()
.resolveValueFromPossibleTokenPlaceholder(resolver.getSourceDirectory()));
} catch (ConstraintViolationException e) {
// the base directory string instance was null or empty
//TODO: What should we do here? Currently, this causes a test to fail.
if (resolver.getDoInitialization()) {
try {
manager = new FilesystemLoadSaveManager(placeholderResolverService()
.resolveValueFromPossibleTokenPlaceholder(resolver.getSourceDirectory()));
} catch (ConstraintViolationException e) {
// the base directory string instance was null or empty
//TODO: What should we do here? Currently, this causes a test to fail.
throw new RuntimeException("An exception occurred while attempting to instantiate a FilesystemLoadSaveManger for the path: " + resolver.getSourceDirectory(), e);
}
}

OpenSamlLocalDynamicMetadataResolver openSamlResolver = new OpenSamlLocalDynamicMetadataResolver(openSamlObjects.getParserPool(), indexWriter, resolver, manager);
Expand Down
8 changes: 7 additions & 1 deletion backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ value.dynamic-http-metadata-provider=DynamicHttpMetadataProvider
value.entity-attributes-filter=EntityAttributes Filter
value.spdescriptor=SPSSODescriptor
value.attr-auth-descriptor=AttributeAuthorityDescriptor

value.dynamic-http-metadata-provider=DynamicHttpMetadataProvider
value.local-dynamic-metadata-provider=LocalDynamicMetadataProvider

brand.header.title=Source Management
brand.logo-link-label=Shibboleth
Expand Down Expand Up @@ -348,6 +348,8 @@ label.cleanup-task-interval=Cleanup Task Interval
label.persistent-cache-manager-directory=Persistent Cache Manager Directory
label.initialize-from-persistent-cache-in-background=Initialize from Persistent Cache in Background?
label.background-init-from-cache-delay=Background Initialization from Cache Delay
label.source-directory=Source Directory
label.remove-idle-entity-data=Remove Idle Entity Data?
label.do-resolver-initialization=Initialize
label.file-doesnt-exist=The file specified in the resolver does not exist on the file system. Therefore, the resolver cannot be initialized.

Expand Down Expand Up @@ -481,4 +483,8 @@ tooltip.cleanup-task-interval=The interval at which the internal cleanup task sh
tooltip.persistent-cache-manager-directory=The optional manager for the persistent cache store for resolved metadata. On metadata provider initialization, data present in the persistent cache will be loaded to memory, effectively restoring the state of the provider as closely as possible to that which existed before the previous shutdown. Each individual cache entry will only be loaded if 1) the entry is still valid as determined by the internal provider logic, and 2) the entry passes the (optional) predicate supplied via initializationFromCachePredicateRef.
tooltip.initialize-from-persistent-cache-in-background=Flag indicating whether should initialize from the persistent cache in the background. Initializing from the cache in the background will improve IdP startup times.
tooltip.background-init-from-cache-delay=The delay after which to schedule the background initialization from the persistent cache when initializeFromPersistentCacheInBackground=true.

tooltip.source-directory=Convenience mechanism for wiring a FilesystemLoadSaveManager, loading from the specified source directory in the local filesystem. This attribute will be ignored if sourceManagerRef is also specified. Either this attribute or sourceManagerRef is required.
tooltip.remove-idle-entity-data=Flag indicating whether idle metadata should be removed.

tooltip.do-resolver-initialization=Initialize this resolver? In the case of Filesystem resolvers, this will cause the system to read the file and index the resolver.
188 changes: 188 additions & 0 deletions backend/src/main/resources/local-dynamic-metadata-provider.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{
"type": "object",
"required": [
"name",
"@type",
"xmlId",
"sourceDirectory"
],
"properties": {
"name": {
"title": "label.metadata-provider-name",
"description": "tooltip.metadata-provider-name",
"type": "string",
"widget": {
"id": "string",
"help": "message.must-be-unique"
}
},
"@type": {
"title": "label.metadata-provider-type",
"description": "tooltip.metadata-provider-type",
"placeholder": "label.select-metadata-type",
"type": "string",
"readOnly": true,
"widget": {
"id": "select",
"disabled": true
},
"oneOf": [
{
"enum": [
"FileSystemMetadataResolver"
],
"description": "value.file-system-metadata-provider"
}
]
},
"xmlId": {
"title": "label.xml-id",
"description": "tooltip.xml-id",
"type": "string",
"default": "",
"minLength": 1
},
"sourceDirectory": {
"title": "label.source-directory",
"description": "tooltip.source-directory",
"type": "string",
"default": "",
"minLength": 1
},
"enabled": {
"title": "label.enable-provider-upon-saving",
"description": "tooltip.enable-provider-upon-saving",
"type": "boolean",
"default": false
},
"dynamicMetadataResolverAttributes": {
"type": "object",
"properties": {
"refreshDelayFactor": {
"title": "label.refresh-delay-factor",
"description": "tooltip.refresh-delay-factor",
"type": "number",
"widget": {
"id": "number",
"step": 0.01
},
"placeholder": "label.real-number",
"minimum": 0,
"maximum": 0.99,
"default": null
},
"minCacheDuration": {
"title": "label.min-cache-duration",
"description": "tooltip.min-cache-duration",
"type": "string",
"placeholder": "label.duration",
"widget": {
"id": "datalist",
"data": [
"PT0S",
"PT30S",
"PT1M",
"PT10M",
"PT30M",
"PT1H",
"PT4H",
"PT12H",
"PT24H"
]
},
"default": null,
"pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
},
"maxCacheDuration": {
"title": "label.max-cache-duration",
"description": "tooltip.max-cache-duration",
"type": "string",
"placeholder": "label.duration",
"widget": {
"id": "datalist",
"data": [
"PT0S",
"PT30S",
"PT1M",
"PT10M",
"PT30M",
"PT1H",
"PT4H",
"PT12H",
"PT24H"
]
},
"default": null,
"pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
},
"maxIdleEntityData": {
"title": "label.max-idle-entity-data",
"description": "tooltip.max-idle-entity-data",
"type": "string",
"placeholder": "label.duration",
"widget": {
"id": "datalist",
"data": [
"PT0S",
"PT30S",
"PT1M",
"PT10M",
"PT30M",
"PT1H",
"PT4H",
"PT12H",
"PT24H"
]
},
"default": null,
"pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
},
"removeIdleEntityData": {
"title": "label.remove-idle-entity-data",
"description": "tooltip.remove-idle-entity-data",
"type": "boolean",
"widget": {
"id": "boolean-radio"
},
"oneOf": [
{
"enum": [
true
],
"description": "value.true"
},
{
"enum": [
false
],
"description": "value.false"
}
],
"default": true
},
"cleanupTaskInterval": {
"title": "label.cleanup-task-interval",
"description": "tooltip.cleanup-task-interval",
"type": "string",
"placeholder": "label.duration",
"widget": {
"id": "datalist",
"data": [
"PT0S",
"PT30S",
"PT1M",
"PT10M",
"PT30M",
"PT1H",
"PT4H",
"PT12H",
"PT24H"
]
},
"default": null,
"pattern": "^(R\\d*\\/)?P(?:\\d+(?:\\.\\d+)?Y)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?W)?(?:\\d+(?:\\.\\d+)?D)?(?:T(?:\\d+(?:\\.\\d+)?H)?(?:\\d+(?:\\.\\d+)?M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
}
}
}
}
}
Loading

0 comments on commit 25643dd

Please sign in to comment.