Skip to content

Commit

Permalink
SHIBUI-2269
Browse files Browse the repository at this point in the history
Additional missing bits to get backend to a point to allow UI to integrate
  • Loading branch information
chasegawa committed Jun 28, 2022
1 parent 9f82c6a commit c5161d6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.dynamicHttpMetadataProviderSchema
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.externalMetadataProviderSchema
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.JsonSchemaResourceLocation.SchemaType
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR

/**
* Controller implementing REST resource responsible for exposing structure definition for metadata resolvers user
* interface in terms of JSON schema.
Expand Down Expand Up @@ -50,6 +50,9 @@ class MetadataResolverUiDefinitionController {
case SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER:
jsonSchemaLocation = dynamicHttpMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break
case SchemaType.EXTERNAL_METADATA_RESOLVER:
jsonSchemaLocation = externalMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry)
break
default:
throw new UnsupportedOperationException("Json schema for an unsupported metadata resolver (" + resolverType + ") was requested")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(Res
.detectMalformedJson(true)
.build())
.register(EXTERNAL_METADATA_RESOLVER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(externalMetadataResolverUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build())
.jsonSchemaLocation(externalMetadataResolverUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build())
.register(NAME_ID_FORMAT_FILTER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(nameIdFormatFilterUiSchemaLocation)
.resourceLoader(resourceLoader)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.internet2.tier.shibboleth.admin.ui.jsonschema;

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.EXTERNAL_METADATA_RESOLVER;
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;
Expand Down Expand Up @@ -66,6 +67,19 @@ public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(Json
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for local dynamic metadata resolver is not registered."));
}

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

/**
* Searches dynamic http metadata resolver JSON schema resource location object in the given location registry.
*
Expand All @@ -75,8 +89,8 @@ public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(Json
*/
public static JsonSchemaResourceLocation dynamicHttpMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
return resourceLocationRegistry
.lookup(DYNAMIC_HTTP_METADATA_RESOLVER)
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for dynamic http metadata resolver is not registered."));
.lookup(DYNAMIC_HTTP_METADATA_RESOLVER)
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for dynamic http metadata resolver is not registered."));
}

/**
Expand All @@ -91,4 +105,4 @@ public static JsonSchemaResourceLocation nameIdFormatFilterSchema(JsonSchemaReso
.lookup(NAME_ID_FORMAT_FILTER)
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for name id format filter is not registered."));
}
}
}

0 comments on commit c5161d6

Please sign in to comment.