Skip to content

Commit

Permalink
resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Nov 19, 2019
2 parents 12a3dbd + e33ed1c commit 8a4c244
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 125 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,8 @@ pac4j-module/out/
r

#Local integration test run shell script wrapper
rinteg
rinteg

#Local run with durable H2 shell script wrapper
**/application-h2durable.properties
rdurable
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects;
import net.shibboleth.ext.spring.resource.ResourceHelper;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
import net.shibboleth.utilities.java.support.resource.Resource;
import org.apache.lucene.index.IndexWriter;
Expand All @@ -21,13 +22,10 @@
import org.opensaml.saml.metadata.resolver.MetadataResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;

import javax.validation.ConstraintViolationException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;

import static edu.internet2.tier.shibboleth.admin.util.TokenPlaceholderResolvers.placeholderResolverService;

Expand All @@ -46,8 +44,8 @@ private OpenSamlFunctionDrivenDynamicHTTPMetadataResolver convertToOpenSamlRepre
IndexWriter indexWriter = indexWriterService.getIndexWriter(resolver.getResourceId());

OpenSamlFunctionDrivenDynamicHTTPMetadataResolver openSamlResolver = new OpenSamlFunctionDrivenDynamicHTTPMetadataResolver(openSamlObjects.getParserPool(),
indexWriter,
resolver);
indexWriter,
resolver);
openSamlResolver.initialize();
return openSamlResolver;
}
Expand All @@ -68,31 +66,25 @@ private OpenSamlFilesystemMetadataResolver convertToOpenSamlRepresentation(Files
}

OpenSamlFilesystemMetadataResolver openSamlResolver = new OpenSamlFilesystemMetadataResolver(openSamlObjects.getParserPool(),
indexWriter,
resolver,
metadataFile);
indexWriter,
resolver,
metadataFile);
openSamlResolver.initialize();
return openSamlResolver;
}

private OpenSamlLocalDynamicMetadataResolver convertToOpenSamlRepresentation(LocalDynamicMetadataResolver resolver) throws IOException, ComponentInitializationException {
IndexWriter indexWriter = indexWriterService.getIndexWriter(resolver.getResourceId());

XMLObjectLoadSaveManager manager = null;
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);
}
try {
IndexWriter indexWriter = indexWriterService.getIndexWriter(resolver.getResourceId());
XMLObjectLoadSaveManager manager = new FilesystemLoadSaveManager(new AlwaysExistingVirtualMetadataDirectory(placeholderResolverService()
.resolveValueFromPossibleTokenPlaceholder(resolver.getSourceDirectory())));
OpenSamlLocalDynamicMetadataResolver openSamlResolver = new OpenSamlLocalDynamicMetadataResolver(openSamlObjects.getParserPool(), indexWriter, resolver, manager);
openSamlResolver.initialize();
return openSamlResolver;
} catch (ConstraintViolationException e) {
// the base directory string instance was null or empty
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);
openSamlResolver.initialize();
return openSamlResolver;
}

private OpenSamlResourceBackedMetadataResolver convertToOpenSamlRepresentation(ResourceBackedMetadataResolver resolver) throws IOException, ComponentInitializationException {
Expand All @@ -112,9 +104,9 @@ private OpenSamlResourceBackedMetadataResolver convertToOpenSamlRepresentation(R
}

OpenSamlResourceBackedMetadataResolver openSamlResolver = new OpenSamlResourceBackedMetadataResolver(openSamlObjects.getParserPool(),
indexWriter,
resolver,
resource);
indexWriter,
resolver,
resource);
openSamlResolver.initialize();
return openSamlResolver;
}
Expand All @@ -136,4 +128,27 @@ public MetadataResolver convertToOpenSamlRepresentation(edu.internet2.tier.shibb
throw new RuntimeException("Unsupported metadata resolver type!");
}
}

/**
* Use this class when creating FilesystemLoadSaveManager for OpenSamlLocalDynamicMetadataResolver
* as we guard the system from any file-related exceptions during init of open saml object representation.
* File with the same name might exist and we don't force the
* system to create a directory in this case. Shibboleth Idp would take care of these directory-creating aspects
* instead.
*/
private static class AlwaysExistingVirtualMetadataDirectory extends File {
public AlwaysExistingVirtualMetadataDirectory(String pathname) {
super(pathname);
}

@Override
public boolean exists() {
return true;
}

@Override
public boolean isDirectory() {
return true;
}
}
}
3 changes: 2 additions & 1 deletion backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ action.back-to-top=Back to Top
action.restore=Restore
action.view-only-changes=View Only Changes
action.user-role=User Role
action.toggle-view=Toggle view

value.enabled=Enabled
value.disabled=Disabled
Expand Down Expand Up @@ -560,7 +561,7 @@ tooltip.enable-provider-upon-saving=If checkbox is clicked, the metadata provide

tooltip.max-validity-interval=Defines the window within which the metadata is valid.
tooltip.require-signed-root=If true, this fails to load metadata with no signature on the root XML element.
tooltip.certificate-file=A path (on the local file system) to a certificate file whose key used to verify the signature. Conflicts with trustEngineRef and both of the child elements.
tooltip.certificate-file=A path (on the local file system) to a certificate file whose key is used to verify the signature. Conflicts with trustEngineRef and both of the child elements.
tooltip.retained-roles=Note that property replacement cannot be used on this element.
tooltip.remove-roleless-entity-descriptors=Controls whether to keep entity descriptors that contain no roles. Note: If this attribute is set to false, the resulting output may not be schema-valid since an <md:EntityDescriptor> element must include at least one role descriptor.
tooltip.remove-empty-entities-descriptors=Controls whether to keep entities descriptors that contain no entity descriptors. Note: If this attribute is set to false, the resulting output may not be schema-valid since an <md:EntitiesDescriptor> element must include at least one child element, either an <md:EntityDescriptor> element or an <md:EntitiesDescriptor> element.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package edu.internet2.tier.shibboleth.admin.ui.service

import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.DynamicMetadataResolverAttributes
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.LocalDynamicMetadataResolver
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import spock.lang.Specification

@SpringBootTest
class MetadataResolverConverterServiceImplTests extends Specification {

@Autowired
MetadataResolverConverterService mrConverterServiceUnderTest

def "conversion to OpenSamlLocalDynamicMetadataResolver with source directory name matching existing file (non-directory) succeeds"() {
given:
LocalDynamicMetadataResolver mr = new LocalDynamicMetadataResolver().with {
it.name = 'SHIBUI-1639'
it.sourceDirectory = File.createTempFile('foo', null).absolutePath
it.dynamicMetadataResolverAttributes = new DynamicMetadataResolverAttributes()
it
}
when:
mrConverterServiceUnderTest.convertToOpenSamlRepresentation(mr)
then:
noExceptionThrown()
}
}
20 changes: 18 additions & 2 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"private": true,
"dependencies": {
"@angular/animations": "8.2.11",
"@angular/cdk": "^8.2.3",
"@angular/common": "8.2.11",
"@angular/compiler": "8.2.11",
"@angular/core": "8.2.11",
Expand Down Expand Up @@ -73,4 +74,4 @@
"typescript": "3.5.3",
"webpack-bundle-analyzer": "^3.3.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ <h2 class="mb-4" [ngSwitch]="type$ | async">
<translate-i18n key="label.filters">Filters</translate-i18n>
</button>
</div>
<div class="btn-group" *ngIf="hasXml$ | async">
<a class="btn"
routerLink="../options"
routerLinkActive="btn-primary"
translate="action.options">Options</a>
<a class="btn"
routerLink="../xml"
routerLinkActive="btn-primary"
translate="action.xml">XML</a>
<div *ngIf="hasXml$ | async">
<div class="btn-group">
<a class="btn" routerLink="../options" routerLinkActive="btn-primary">
<span class="sr-only" translate="action.toggle-view">Toggle view:</span>
Options
</a>
<a class="btn" routerLink="../xml" routerLinkActive="btn-primary">
<span class="sr-only" translate="action.toggle-view">Toggle view:</span>
XML
</a>
</div>
</div>
</div>
<ng-container *ngIf="configuration$ | async">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ <h2 class="mb-4" [ngSwitch]="type$ | async">
<div class="container-fluid">
<div class="px-3 my-3 d-flex justify-content-end">
<div class="btn-group">
<a class="btn" routerLink="../options" routerLinkActive="btn-primary">Options</a>
<a class="btn" routerLink="../xml" routerLinkActive="btn-primary">XML</a>
<a class="btn" routerLink="../options" routerLinkActive="btn-primary">
<span class="sr-only" translate="action.toggle-view">Toggle view:</span>
Options
</a>
<a class="btn" routerLink="../xml" routerLinkActive="btn-primary">
<span class="sr-only" translate="action.toggle-view">Toggle view:</span>
XML
</a>
</div>
</div>
<div class="px-3 my-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
<a [routerLink]="['/', 'metadata', 'resolver', 'new', 'blank', 'common']"
[queryParams]="{'id': resolver.getId()}">{{ resolver.name }}</a>
</td>
<td>{{ resolver.getDisplayId() }}</td>
<td>{{ resolver.createdBy }}</td>
<td>{{ resolver.getCreationDate() ? (resolver.getCreationDate() | customDate) : '&mdash;' }}</td>
<td [attr.aria-label]="resolver.getDisplayId()">{{ resolver.getDisplayId() }}</td>
<td [attr.aria-label]="resolver.createdBy">{{ resolver.createdBy ? resolver.createdBy : '&mdash;' }}</td>
<td [attr.aria-label]="resolver.getCreationDate() ? (resolver.getCreationDate() | customDate) : 'unknown'">
{{ resolver.getCreationDate() ? (resolver.getCreationDate() | customDate) : '&mdash;' }}
</td>
<td class="text-right">
<span *ngIf="resolver.isDraft()">
<button class="btn btn-outline btn-sm btn-danger" (click)="delete.emit(resolver)">
<span class="sr-only">Delete</span>
<i class="fa fa-trash"></i>
</button>
&nbsp;
<span class="badge badge-warning" aria-label="Warning Badge: Incomplete Form"
<span class="badge badge-warning" tabindex="0" aria-label="Warning Badge: Incomplete Form"
translate="message.incomplete-form">
Incomplete Form
</span>
Expand All @@ -42,10 +44,13 @@
</button>
</ng-container>
<ng-container *ngIf="!toggleEnabled.observers.length">
<span class="badge" *ngIf="!resolver.isDraft()" [class.badge-danger]="!resolver.enabled"
<span tabindex="0"
[attr.aria-label]="(resolver.enabled ? 'value.enabled' : 'value.disabled') | translate"
class="badge"
*ngIf="!resolver.isDraft()"
[class.badge-danger]="!resolver.enabled"
[class.badge-success]="resolver.enabled">
<span *ngIf="resolver.enabled" translate="value.enabled">Enabled</span>
<span *ngIf="!resolver.enabled" translate="value.disabled">Disabled</span>
{{ (resolver.enabled ? 'value.enabled' : 'value.disabled') | translate }}
</span>
</ng-container>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
<td>{{ provider.createdBy }}</td>
<td>{{ provider.createdDate | customDate }}</td>
<td class="text-right">
<span class="badge"
<span tabindex="0"
class="badge"
[attr.aria-label]="(provider.enabled ? 'value.enabled' : 'value.disabled') | translate"
[class.badge-danger]="!provider.enabled"
[class.badge-success]="provider.enabled">
<span *ngIf="provider.enabled" translate="value.enabled">Enabled</span>
<span *ngIf="!provider.enabled" translate="value.disabled">Enabled</span>
{{ (provider.enabled ? 'value.enabled' : 'value.disabled') | translate }}
</span>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h3 class="tag tag-primary">
</label>
<auto-complete
id="target"
fieldId="target"
formControlName="target"
[matches]="searchResults$ | async"
[required]="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="widget form-group">
<label [for]="formProperty._canonicalPath" class="d-flex justify-content-between control-label">
<label [id]="formProperty._canonicalPath + '-label'" [for]="formProperty._canonicalPath" class="d-flex justify-content-between control-label">
<span [ngClass]="{'sr-only': formProperty.parent.schema.type === 'array'}">
{{ title | translate }}&nbsp;
<i class="fa fa-asterisk text-danger" aria-hidden="true" *ngIf="required"></i>
Expand All @@ -11,10 +11,10 @@
</label>
<span *ngIf="schema.description" class="sr-only" [translate]="schema.description">{{ schema.description }}</span>
<auto-complete
[id]="formProperty._canonicalPath"
[id]="formProperty._canonicalPath + 'autocomplete'"
[fieldId]="formProperty._canonicalPath"
[formControl]="control"
[matches]="schema.widget.data"
[matches]="data"
[required]="true"
[dropdown]="true"
[attr.placeholder]="schema.placeholder || '' | translate"
Expand All @@ -23,7 +23,8 @@
[attr.aria-label]="title | translate"
[attr.required]="schema.isRequired || null"
[attr.aria-invalid]="errorMessages && errorMessages.length > 0"
[attr.aria-describedby]="formProperty._canonicalPath + '-help'">
[attr.aria-describedby]="formProperty._canonicalPath + '-help'"
(onChange)="getData($event)">
</auto-complete>
<small class="form-text text-danger"
[id]="formProperty._canonicalPath + '-help'"
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/schema-form/widget/datalist/datalist.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { HARD_CODED_REQUIRED_MSG } from '../../model/messages';
templateUrl: `./datalist.component.html`
})
export class DatalistComponent extends ControlWidget implements AfterViewInit {

data: string[] = [];

constructor(
private widgetService: SchemaService
) {
Expand All @@ -25,6 +28,10 @@ export class DatalistComponent extends ControlWidget implements AfterViewInit {
console.log(this.formProperty);
}

getData(query: string): void {
this.data = [...this.schema.widget.data];
}

get required(): boolean {
return this.widgetService.isRequired(this.formProperty);
}
Expand Down
Loading

0 comments on commit 8a4c244

Please sign in to comment.