Skip to content

Commit

Permalink
[SHIBUI-701]
Browse files Browse the repository at this point in the history
Added support for resolver initialization. Each resolver now contains a
doInitialization boolean that controls whether the resolver's init
method should be run and if it should be added to the chaining resolver.
Currently, this only affects the filesystem metadata resolver's init method.
However, it affects all resolvers with respect to the chaining resolver.
Also added supporting tooltip and label and an update to the filesystem
resolver's json schema.

By default, doInitialization is true for all resolvers but the filesystem
resolver.
  • Loading branch information
Bill Smith committed Nov 9, 2018
1 parent ae4f553 commit cc6721d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public ResponseEntity<?> create(@RequestBody MetadataResolver newResolver) throw

//TODO: currently, the update call might explode, but the save works.. in which case, the UI never gets
// n valid response. This operation is not atomic. Should we return an error here?
org.opensaml.saml.metadata.resolver.MetadataResolver openSamlRepresentation = metadataResolverConverterService.convertToOpenSamlRepresentation(persistedResolver);
OpenSamlChainingMetadataResolverUtil.updateChainingMetadataResolver((OpenSamlChainingMetadataResolver) chainingMetadataResolver, openSamlRepresentation);
if (persistedResolver.getDoInitialization()) {
org.opensaml.saml.metadata.resolver.MetadataResolver openSamlRepresentation = metadataResolverConverterService.convertToOpenSamlRepresentation(persistedResolver);
OpenSamlChainingMetadataResolverUtil.updateChainingMetadataResolver((OpenSamlChainingMetadataResolver) chainingMetadataResolver, openSamlRepresentation);
}

return ResponseEntity.created(getResourceUriFor(persistedResolver)).body(persistedResolver);
}
Expand All @@ -148,8 +150,10 @@ public ResponseEntity<?> update(@PathVariable String resourceId, @RequestBody Me

MetadataResolver persistedResolver = resolverRepository.save(updatedResolver);

org.opensaml.saml.metadata.resolver.MetadataResolver openSamlRepresentation = metadataResolverConverterService.convertToOpenSamlRepresentation(persistedResolver);
OpenSamlChainingMetadataResolverUtil.updateChainingMetadataResolver((OpenSamlChainingMetadataResolver) chainingMetadataResolver, openSamlRepresentation);
if (persistedResolver.getDoInitialization()) {
org.opensaml.saml.metadata.resolver.MetadataResolver openSamlRepresentation = metadataResolverConverterService.convertToOpenSamlRepresentation(persistedResolver);
OpenSamlChainingMetadataResolverUtil.updateChainingMetadataResolver((OpenSamlChainingMetadataResolver) chainingMetadataResolver, openSamlRepresentation);
}

return ResponseEntity.ok(persistedResolver);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class FilesystemMetadataResolver extends MetadataResolver {
public FilesystemMetadataResolver() {
type = "FilesystemMetadataResolver";
this.setDoInitialization(false);
}

private String metadataFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class MetadataResolver extends AbstractAuditable {

private Boolean satisfyAnyPredicates = false;

private Boolean doInitialization = true;

@OneToMany(cascade = CascadeType.ALL)
@OrderColumn
private List<MetadataFilter> metadataFilters = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ public DateTime getLastRefresh() {

@Override
protected void initMetadataResolver() throws ComponentInitializationException {
//TODO determine whether we should actually be doing anything here
/*super.initMetadataResolver();
if (this.sourceResolver.getDoInitialization()) {
super.initMetadataResolver();

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"type": "boolean",
"default": false
},
"doInitialization": {
"title": "label.do-resolver-initialization",
"description": "tooltip.do-resolver-initialization",
"type": "boolean",
"default": false
},
"reloadableMetadataResolverAttributes": {
"type": "object",
"properties": {
Expand Down
4 changes: 4 additions & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ label.attribute-eduPersonUniqueId=eduPersonUniqueId
label.attribute-employeeNumber=employeeNumber
label.force-authn=Force AuthN

label.do-resolver-initialization=Initialize

message.must-be-unique=Must be unique.
message.name-must-be-unique=Name must be unique.
message.uri-valid-format=URI must be valid format.
Expand Down Expand Up @@ -458,3 +460,5 @@ tooltip.expiration-warning-threshold=For each attempted metadata refresh (whethe
tooltip.filter-name=Filter Name
tooltip.enable-filter=Enable Filter?
tooltip.enable-service=Enable Service?

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.
4 changes: 4 additions & 0 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ label.attribute-eduPersonUniqueId=eduPersonUniqueId
label.attribute-employeeNumber=employeeNumber
label.force-authn=Force AuthN

label.do-resolver-initialization=Initialize

message.must-be-unique=Must be unique.
message.name-must-be-unique=Name must be unique.
message.uri-valid-format=URI must be valid format.
Expand Down Expand Up @@ -459,3 +461,5 @@ tooltip.expiration-warning-threshold=For each attempted metadata refresh (whethe
tooltip.filter-name=Filter Name
tooltip.enable-filter=Enable Filter?
tooltip.enable-service=Enable Service?

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.

0 comments on commit cc6721d

Please sign in to comment.