Skip to content

Commit

Permalink
Merge branch 'master' into SHIBUI-520
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Jul 9, 2018
2 parents 54c0807 + 9578401 commit 70dc512
Show file tree
Hide file tree
Showing 86 changed files with 1,937 additions and 433 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package edu.internet2.tier.shibboleth.admin.ui.controller;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* @author Bill Smith (wsmith@unicon.net)
*/
@AllArgsConstructor
@Getter
@Setter
@ToString
public class ErrorResponse {
private String errorCode;
private String errorMessage;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package edu.internet2.tier.shibboleth.admin.ui.controller;

import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolver;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolverValidationService;
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolverValidator;
import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -19,6 +20,7 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import java.io.IOException;
import java.net.URI;

import static edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.MetadataResolverValidator.ValidationResult;
Expand All @@ -34,6 +36,11 @@ public class MetadataResolversController {
@Autowired
MetadataResolverValidationService metadataResolverValidationService;

@ExceptionHandler({InvalidTypeIdException.class, IOException.class, HttpMessageNotReadableException.class})
public ResponseEntity<?> unableToParseJson(Exception ex) {
return ResponseEntity.badRequest().body(new ErrorResponse(HttpStatus.BAD_REQUEST.toString(), ex.getMessage()));
}

@GetMapping("/MetadataResolvers")
@Transactional(readOnly = true)
public ResponseEntity<?> getAll() {
Expand All @@ -56,6 +63,10 @@ public ResponseEntity<?> getOne(@PathVariable String resourceId) {
@PostMapping("/MetadataResolvers")
@Transactional
public ResponseEntity<?> create(@RequestBody MetadataResolver newResolver) {
if (resolverRepository.findByName(newResolver.getName()) != null) {
return ResponseEntity.status(HttpStatus.CONFLICT).build();
}

//TODO: we are disregarding attached filters if any sent from UI.
//Only deal with filters via filters endpoints?
newResolver.clearAllFilters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* A facade that aggregates {@link MetadataResolverValidator}s available to call just one of them supporting the type of a given resolver.
* If no {@link MetadataResolverValidator}s are configured, conciders provided MetadataResolver as valid.
* If no {@link MetadataResolverValidator}s are configured, considers provided MetadataResolver as valid.
* <p>
* Uses chain-of-responsibility design pattern
*
Expand All @@ -22,7 +22,7 @@ public MetadataResolverValidationService(List<MetadataResolverValidator<T>> vali
this.validators = validators != null ? validators : new ArrayList<>();
}

@SuppressWarnings("Uncheked")
@SuppressWarnings("Unchecked")
public ValidationResult validateIfNecessary(T metadataResolver) {
Optional<MetadataResolverValidator<T>> validator =
this.validators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.apache.lucene.index.IndexWriter
import org.opensaml.saml.metadata.resolver.ChainingMetadataResolver
import org.opensaml.saml.metadata.resolver.MetadataResolver
import org.opensaml.saml.metadata.resolver.impl.ResourceBackedMetadataResolver
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.io.ClassPathResource
Expand All @@ -21,6 +23,7 @@ class TestConfiguration {
final OpenSamlObjects openSamlObjects
final IndexWriter indexWriter
final MetadataResolverRepository metadataResolverRepository
final Logger logger = LoggerFactory.getLogger(TestConfiguration.class);

TestConfiguration(final OpenSamlObjects openSamlObjects, final IndexWriter indexWriter, final MetadataResolverRepository metadataResolverRepository) {
this.openSamlObjects =openSamlObjects
Expand Down
2 changes: 1 addition & 1 deletion backend/src/test/resources/metadata/incommon-short.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:icmd="http://id.incommon.org/metadata" xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute" xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi" xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui" xmlns:remd="http://refeds.org/metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="INC20180618T184502" Name="urn:mace:incommon" validUntil="2018-07-02T18:45:02Z">
<EntitiesDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:alg="urn:oasis:names:tc:SAML:metadata:algsupport" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:icmd="http://id.incommon.org/metadata" xmlns:idpdisc="urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol" xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init" xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute" xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi" xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui" xmlns:remd="http://refeds.org/metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:shibmd="urn:mace:shibboleth:metadata:1.0" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="INC20180618T184502" Name="urn:mace:incommon" validUntil="2099-07-02T18:45:02Z">
<EntityDescriptor entityID="https://carmenwiki.osu.edu/shibboleth">
<Extensions>
<mdrpi:RegistrationInfo registrationAuthority="https://incommon.org"/>
Expand Down
38 changes: 36 additions & 2 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
# Ui
# Angular

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.3.1.
Angular is a complete framework for UI development, meaning that in addition to rendering a web application in a browser, it also provides additional tools for other important UI considerations such as Internationalization (i18n), Accessibility (a11y), HTML 5 push state routing, an http library for connecting with our REST endpoints, a tool for scaffolding new services, components, pages, etc, and extensive end-to-end and unit testing toolset. In comparison to other frameworks, we rely on fewer 3rd party libraries or frameworks to handle these other concerns. The Angular community provides an extensive documentation website with full API documentation, as well as examples/tutorials. This includes a style-guide with rules for formatting code, which we follow on the SHIB-UI project.Angular is actively maintained by Google and has a large community and ecosystem.

## License

Angular is [licensed](https://angular.io/license) under the MIT license.

## Performance

Angular was designed for mobile from the ground up. Aside from limited processing power, mobile devices have other features and limitations that separate them from traditional computers. Touch interfaces, limited screen real estate, and mobile hardware have all been considered when developing the Angular framework. This has resulted in performance gains in Angular across the board, and makes it competitive with the many other UI frameworks available.

## Typescript

Angular uses [TypeScript](https://www.typescriptlang.org/), a superset of JavaScript that implements many new ESNext features as well as making JavaScript strongly typed. This makes errors and exceptions more likely to happen during compilation, resulting in fewer defects.

By focusing on making the framework easier for computers to process, Angular and TypeScript allow for a much richer development process. Tooling for TypeScript and Angular allows for immediate Angular-specific help and feedback with nearly every IDE and editor. Strong typing enables developers to use more productive development tools and practices like static checking when developing JavaScript applications.

However, developers can still write vanilla JavaScript for Angular that runs without transpilation.

## NGRX

The popular Redux state management system is implemented in SHIB-UI via the framework [NgRx](http://ngrx.github.io/). This provides reliable uni-directional data-flow in the UI which organizes the UI state in a clear and predictable way. One of NgRx's most important features is its simple testability since it is based primarily on pure functions.

# JSON-Schema

For Providers and Filters, the forms in SHIB-UI are built based on the standard [JSON-Schema](http://json-schema.org/). This makes the generation of forms in the editors and wizards of the application dynamic, so that if new properties are added to the specification for a Metadata Provider type, it can be added to the JSON-schema of the application without ever having to re-deploy the javascript code. Rendering of the forms is handled using [ngx-schema-form](https://github.com/makinacorpus/ngx-schema-form), a component library for connecting to a JSON-Schema to render Angular form components, and provides extensibility through support of custom components and validation rules.

# Bootstrap

[Bootstrap](http://getbootstrap.com/) 4 is used for the css framework in SHIB-UI, and provides our base theme, a responsive grid system, consistent styling across all major browsers, and pre-styled components which are connected to Angular using ng-bootstrap, a 3rd party framework.

# Development

## Scaffolding

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.1.

## Development server

Expand Down
1 change: 1 addition & 0 deletions ui/src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{ path: '', redirectTo: 'metadata', pathMatch: 'full' },
{ path: 'dashboard', redirectTo: 'metadata', pathMatch: 'full' },
{
path: 'metadata',
loadChildren: './metadata/metadata.module#MetadataModule'
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/domain/domain.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EntityDraftService } from './service/draft.service';
import { MetadataProviderService } from './service/provider.service';
import { EntityEffects } from './effect/entity.effect';
import { PreviewDialogComponent } from './component/preview-dialog.component';
import { MetadataFilterService } from './service/filter.service';

export const COMPONENTS = [
PreviewDialogComponent
Expand Down Expand Up @@ -42,7 +43,8 @@ export class DomainModule {
ListValuesService,
ProviderStatusEmitter,
ProviderValueEmitter,
MetadataProviderService
MetadataProviderService,
MetadataFilterService
]
};
}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/app/metadata/domain/domain.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {

import {
EntityAttributesFilter,
FileBackedHttpMetadataResolver,
FileBackedHttpMetadataProvider
FileBackedHttpMetadataResolver
} from './entity';
import {
FileBackedHttpMetadataProvider
} from './model/providers';

export type Filter =
| EntityAttributesFilter;
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/metadata/domain/entity/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './filter/entity-attributes-filter';
export * from './provider/file-backed-http-metadata-provider';
export * from './resolver/file-backed-http-metadata-resolver';

This file was deleted.

This file was deleted.

10 changes: 2 additions & 8 deletions ui/src/app/metadata/domain/model/metadata-provider.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import {
MetadataBase,
Organization,
Contact,
MDUI,
SecurityInfo,
SsoService,
IdpSsoDescriptor,
LogoutEndpoint,
RelyingPartyOverrides
} from '../model';

export interface MetadataProvider extends MetadataBase {
name: string;
'@type': string;
enabled: boolean;
resourceId: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MetadataProvider } from '../metadata-provider';

export interface FileBackedHttpMetadataProvider extends MetadataProvider {
metadataFilters: any[];
}
1 change: 1 addition & 0 deletions ui/src/app/metadata/domain/model/providers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './file-backed-http-metadata-provider';
Loading

0 comments on commit 70dc512

Please sign in to comment.