Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/shibui-2274
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/AbstractAuditable.java
#	backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/security/controller/UsersController.java
  • Loading branch information
chasegawa committed Jun 9, 2022
2 parents f35209a + 1573adc commit e9a35d2
Show file tree
Hide file tree
Showing 51 changed files with 532 additions and 394 deletions.
91 changes: 51 additions & 40 deletions backend/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'groovy'
id 'war'
id 'org.springframework.boot' version '2.4.2'
id 'com.gorylenko.gradle-git-properties' version '1.4.21'
id 'io.freefair.lombok' version '5.3.0'
id 'com.palantir.docker' version '0.28.0'
id 'com.palantir.docker-run' version '0.28.0'
id "groovy"
id "war"
id "org.springframework.boot"
id "io.freefair.lombok"
id "com.gorylenko.gradle-git-properties" version "1.4.21"
id "com.palantir.docker" version "0.28.0"
id "com.palantir.docker-run" version "0.28.0"
}

apply plugin: 'io.spring.dependency-management'
Expand All @@ -14,18 +14,26 @@ apply plugin: 'jacoco'
sourceCompatibility = 11
targetCompatibility = 11

test {
useJUnitPlatform() // Needed by spock to find specification tests
}

repositories {
jcenter()
maven {
url 'https://build.shibboleth.net/nexus/content/groups/public'
artifactUrls = ['https://build.shibboleth.net/nexus/content/repositories/thirdparty-snapshots']
}
maven { // for the springboot plugin
url "https://plugins.gradle.org/m2/"
}
mavenLocal()
mavenCentral()
}

configurations.all {
resolutionStrategy {
force 'org.cryptacular:cryptacular:1.1.3'
force "org.cryptacular:cryptacular:${project.'cryptacularVersion'}"

eachDependency { details ->
if (details.requested.group == 'org.seleniumhq.selenium' && details.requested.name != 'htmlunit-driver') {
Expand Down Expand Up @@ -105,7 +113,7 @@ bootWar {
}

springBoot {
mainClassName = 'edu.internet2.tier.shibboleth.admin.ui.ShibbolethUiApplication'
mainClass = 'edu.internet2.tier.shibboleth.admin.ui.ShibbolethUiApplication'
buildInfo()
}

Expand All @@ -114,43 +122,41 @@ generateLombokConfig.enabled = false
dependencies {
// opensaml deps
['opensaml-saml-api', 'opensaml-saml-impl', 'opensaml-xmlsec-api', 'opensaml-xmlsec-impl'].each {
compile "org.opensaml:${it}:${project.'opensaml.version'}"
compile "org.opensaml:${it}:${project.'opensamlVersion'}"
}

// Left here to save time later - when pac4j is/was updated, I needed all of these to get the runtime right with the SAML2 client
// runtimeOnly "org.bouncycastle:bcprov-jdk15on:1.69"
// runtimeOnly "org.bouncycastle:bcprov-ext-jdk15on:1.69"
// runtimeOnly "org.bouncycastle:bcutil-jdk15on:1.69"
// runtimeOnly "org.bouncycastle:bcpkix-jdk15on:1.69"

runtimeOnly "org.bouncycastle:bcprov-jdk15on:1.70"
runtimeOnly "org.bouncycastle:bcprov-ext-jdk15on:1.70"
runtimeOnly "org.bouncycastle:bcutil-jdk15on:1.70"
runtimeOnly "org.bouncycastle:bcpkix-jdk15on:1.70"

// shibboleth idp deps
['idp-profile-spring', 'idp-profile-api'].each {
compile "net.shibboleth.idp:${it}:${project.'shibboleth.version'}"
compile "net.shibboleth.idp:${it}:${project.'shibbolethVersion'}"
}

// hibernate deps
['hibernate-core'].each {
compile "org.hibernate:${it}:${project.'hibernate.version'}"
compile "org.hibernate:${it}:${project.'hibernateVersion'}"
}

// spring boot auto-config starters
['starter-web', 'starter-data-jpa', 'starter-security', 'starter-actuator', 'devtools', 'starter-webflux', 'starter-thymeleaf', 'starter-mail', 'starter-validation'].each {
compile "org.springframework.boot:spring-boot-${it}"
}
// To override older version with security issue - https://www.lunasec.io/docs/blog/log4j-zero-day/
implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.15.0'
implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
implementation "org.apache.logging.log4j:log4j-to-slf4j:${project.'log4JVersion'}"
implementation "org.apache.logging.log4j:log4j-api:${project.'log4JVersion'}"

// TODO: figure out what this should really be
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'
runtimeOnly "org.springframework.boot:spring-boot-starter-tomcat:${project.'springbootVersion'}"

//Spring Configuration Annotation Processor - makes IntelliJ happy about @ConfigurationProperties
compileOnly "org.springframework.boot:spring-boot-configuration-processor"
compileOnly "org.springframework.boot:spring-boot-configuration-processor:${project.'springbootVersion'}"

// lucene deps
['core', 'analyzers-common', 'queryparser'].each {
compile "org.apache.lucene:lucene-${it}:${project.'lucene.version'}"
compile "org.apache.lucene:lucene-${it}:${project.'luceneVersion'}"
}

compile "org.liquibase:liquibase-core"
Expand All @@ -159,29 +165,31 @@ dependencies {
//For easy data mocking capabilities
compile 'net.andreinc.mockneat:mockneat:0.1.4'

compile 'org.codehaus.groovy:groovy-all:3.0.7'

//So it works on Java 9 without explicitly requiring to load that module (needed by Hibernate)
runtimeOnly 'javax.xml.bind:jaxb-api:2.3.0'
// runtime libraries for later java versions
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:2.3.0'

compile "com.h2database:h2"
runtimeOnly "org.postgresql:postgresql:42.2.20"
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:2.2.0'
runtimeOnly 'mysql:mysql-connector-java:5.1.48'
runtimeOnly 'org.postgresql:postgresql:42.3.4'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:3.0.4'
runtimeOnly 'mysql:mysql-connector-java:8.0.29'

//Swagger 3
implementation 'org.springdoc:springdoc-openapi-ui:1.6.8'

testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.springframework.security:spring-security-test"
testCompile "org.spockframework:spock-core:1.3-groovy-2.5"
testCompile "org.spockframework:spock-spring:1.3-groovy-2.5"
compile 'org.codehaus.groovy:groovy-all:3.0.10'
testImplementation platform("org.spockframework:spock-bom:2.1-groovy-3.0")
testImplementation "org.spockframework:spock-core"
testImplementation "org.spockframework:spock-spring"

testCompile "org.springframework.boot:spring-boot-starter-test:${project.'springbootVersion'}"
testCompile "org.springframework.security:spring-security-test:${project.'springSecurityVersion'}"
testCompile 'org.skyscreamer:jsonassert:1.5.0'
testCompile "org.xmlunit:xmlunit-core:2.5.1"
testRuntime 'cglib:cglib-nodep:3.2.5'

compile "net.shibboleth.ext:spring-extensions:5.4.0"
compile "net.shibboleth.ext:spring-extensions:6.2.0"

//JSON schema generator
testCompile 'com.kjetland:mbknor-jackson-jsonschema_2.12:1.0.29'
Expand All @@ -195,18 +203,18 @@ dependencies {
integrationTestCompile configurations.compile
integrationTestCompile 'com.saucelabs:sebuilder-interpreter:1.0.6'
integrationTestCompile 'jp.vmi:selenese-runner-java:3.20.0'
integrationTestCompile "org.springframework.boot:spring-boot-starter-test"
integrationTestCompile "org.springframework.security:spring-security-test"
integrationTestCompile "org.spockframework:spock-core:1.3-groovy-2.5"
integrationTestCompile "org.spockframework:spock-spring:1.3-groovy-2.5"
integrationTestCompile "org.springframework.boot:spring-boot-starter-test:${project.'springbootVersion'}"
integrationTestCompile "org.springframework.security:spring-security-test:${project.'springSecurityVersion'}"

// CSV file support
compile 'com.opencsv:opencsv:4.4'
compile 'com.opencsv:opencsv:4.4', {
exclude group: 'commons-collections'
}

testCompile 'org.skyscreamer:jsonassert:1.5.0'
compile "org.apache.commons:commons-collections4:${project.'commonsCollections4Version'}"

// Envers for persistent entities versioning
compile 'org.hibernate:hibernate-envers'
compile "org.hibernate:hibernate-envers:${project.'hibernateVersion'}"

//Pacj4 sub-project
runtimeOnly project(':pac4j-module')
Expand All @@ -218,7 +226,9 @@ dependencies {
enversTestCompile sourceSets.test.output
enversTestCompile configurations.compile
enversTestCompile configurations.testCompile
enversTestCompile configurations.testImplementation

enversTestRuntime configurations.testImplementation
enversTestRuntime configurations.runtime
enversTestRuntime configurations.testRuntime
}
Expand Down Expand Up @@ -246,6 +256,7 @@ task enversTest(type: Test) {
classpath = sourceSets.enversTest.runtimeClasspath
systemProperties = System.properties
systemProperties['user.dir'] = workingDir
useJUnitPlatform()
}

check {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import groovy.util.logging.Slf4j
import groovy.xml.DOMBuilder
import groovy.xml.MarkupBuilder
import net.shibboleth.utilities.java.support.scripting.EvaluableScript
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.collections4.CollectionUtils
import org.opensaml.saml.common.profile.logic.EntityIdPredicate
import org.opensaml.saml.metadata.resolver.MetadataResolver
import org.opensaml.saml.metadata.resolver.filter.MetadataFilter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.internet2.tier.shibboleth.admin.ui.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
Expand All @@ -17,7 +17,7 @@
*/

@Configuration
@EnableConfigurationProperties({ResourceProperties.class})
@EnableConfigurationProperties({WebProperties.class})
public class StaticResourcesConfiguration implements WebMvcConfigurer {
static final String[] STATIC_RESOURCES = new String[]{
"/**/*.css",
Expand All @@ -36,16 +36,17 @@ public class StaticResourcesConfiguration implements WebMvcConfigurer {
};

@Autowired
private ResourceProperties resourceProperties = new ResourceProperties();
private WebProperties resourceProperties = new WebProperties();

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler(STATIC_RESOURCES)
.addResourceLocations(resourceProperties.getStaticLocations())
.addResourceLocations(resourceProperties.getResources().getStaticLocations())
.setCachePeriod(10);
registry.addResourceHandler("/**")
.addResourceLocations(
Arrays.stream(resourceProperties.getStaticLocations())
Arrays.stream(resourceProperties.getResources().getStaticLocations())
.map(l -> l + "index.html")
.toArray(String[]::new)
)
Expand All @@ -59,4 +60,4 @@ protected Resource getResource(String resourcePath, Resource location) throws IO
}
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
package edu.internet2.tier.shibboleth.admin.ui.domain;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import io.swagger.v3.oas.annotations.Hidden;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.envers.Audited;
Expand All @@ -25,10 +12,19 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.EqualsAndHashCode;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;


@MappedSuperclass
Expand All @@ -44,14 +40,14 @@ public abstract class AbstractAuditable implements Auditable {

@CreationTimestamp
@CreatedDate
@Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)")
@Column(nullable = false, updatable = false)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
@Hidden
private LocalDateTime createdDate;

@UpdateTimestamp
@LastModifiedDate
@Column(nullable = false, columnDefinition = "DATETIME(6)")
@Column(nullable = false)
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS")
@Hidden
private LocalDateTime modifiedDate;
Expand Down Expand Up @@ -90,7 +86,7 @@ public LocalDateTime getCreatedDate() {

@Override
public void setCreatedDate(LocalDateTime createdDate) {
this.createdDate = createdDate;
this.createdDate = createdDate == null ? null : createdDate.truncatedTo(ChronoUnit.NANOS);
}

@Override
Expand All @@ -100,7 +96,7 @@ public LocalDateTime getModifiedDate() {

@Override
public void setModifiedDate(LocalDateTime modifiedDate) {
this.modifiedDate = modifiedDate;
this.modifiedDate = modifiedDate == null ? null : modifiedDate.truncatedTo(ChronoUnit.NANOS);
}

public String getCreatedBy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.saml2.common.CacheableSAMLObject;
import org.opensaml.saml.saml2.common.TimeBoundSAMLObject;
import org.opensaml.xmlsec.signature.Signature;
import org.opensaml.xmlsec.signature.SignableXMLObject;
import org.opensaml.xmlsec.signature.Signature;

import javax.annotation.Nullable;
import javax.persistence.CascadeType;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
import java.time.Duration;
import java.time.Instant;
import java.util.List;


@MappedSuperclass
@EqualsAndHashCode(callSuper = true)
@Audited
Expand All @@ -42,23 +43,27 @@ public boolean isValid() {
}

@Override
public Long getCacheDuration() {
return cacheDuration;
public Duration getCacheDuration() {
return null == cacheDuration ? null : Duration.ofMillis(cacheDuration);
}

@Override
public void setCacheDuration(Long cacheDuration) {
this.cacheDuration = cacheDuration;
public void setCacheDuration(@Nullable final Duration duration) {
if (duration == null) {
cacheDuration = null;
} else {
cacheDuration = duration.toMillis();
}
}

@Override
public DateTime getValidUntil() {
return validUntil;
public Instant getValidUntil() {
return null == validUntil ? null : Instant.ofEpochMilli(validUntil.getMillis());
}

@Override
public void setValidUntil(DateTime validUntil) {
this.validUntil = validUntil;
public void setValidUntil(Instant validUntilInstant) {
this.validUntil = new DateTime(validUntilInstant.toEpochMilli());
}

@Override
Expand Down Expand Up @@ -102,4 +107,4 @@ public List<XMLObject> getOrderedChildren() {

return null; //TODO ?
}
}
}
Loading

0 comments on commit e9a35d2

Please sign in to comment.