Skip to content

Commit

Permalink
SHIBUI-2264
Browse files Browse the repository at this point in the history
Intermediate checkin of (broken) code
  • Loading branch information
chasegawa committed May 6, 2022
1 parent 46a3542 commit dfddcbe
Show file tree
Hide file tree
Showing 37 changed files with 339 additions and 264 deletions.
25 changes: 15 additions & 10 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ springBoot {

generateLombokConfig.enabled = false

test {
useJUnitPlatform()
}

dependencies {
// opensaml deps
['opensaml-saml-api', 'opensaml-saml-impl', 'opensaml-xmlsec-api', 'opensaml-xmlsec-impl'].each {
Expand All @@ -123,7 +127,6 @@ dependencies {
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'}"
Expand Down Expand Up @@ -159,8 +162,6 @@ 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
Expand All @@ -169,16 +170,24 @@ dependencies {
compile "com.h2database:h2"
runtimeOnly 'org.postgresql:postgresql:42.3.4'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client:2.2.0'
runtimeOnly 'mysql:mysql-connector-java:5.1.48'
runtimeOnly 'mysql:mysql-connector-java:8.0.28'

//Swagger
compile 'io.springfox:springfox-swagger2:2.9.2'
compile 'io.springfox:springfox-swagger-ui:2.9.2'

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"
//testImplementation "org.spockframework:spock-junit4"
//testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
//testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
//testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.8.2'

testCompile 'org.springframework.boot:spring-boot-starter-test:2.6.7'
testCompile 'org.springframework.security:spring-security-test:5.6.3'
testCompile "org.spockframework:spock-core:2.1-groovy-2.5"
testCompile "org.spockframework:spock-spring:2.1-groovy-2.5"
testCompile 'org.skyscreamer:jsonassert:1.5.0'
testCompile "org.xmlunit:xmlunit-core:2.5.1"
testRuntime 'cglib:cglib-nodep:3.2.5'

Expand All @@ -198,14 +207,10 @@ dependencies {
integrationTestCompile 'jp.vmi:selenese-runner-java:3.20.0'
integrationTestCompile 'org.springframework.boot:spring-boot-starter-test:2.6.7'
integrationTestCompile 'org.springframework.security:spring-security-test:5.6.3'
integrationTestCompile 'org.spockframework:spock-core:2.1-groovy-2.5'
integrationTestCompile 'org.spockframework:spock-spring:2.1-groovy-2.5'

// CSV file support
compile 'com.opencsv:opencsv:4.4'

testCompile 'org.skyscreamer:jsonassert:1.5.0'

// Envers for persistent entities versioning
compile 'org.hibernate:hibernate-envers'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ public boolean isValid() {

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

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

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;


@Entity
@EqualsAndHashCode(callSuper = true)
public class AdditionalMetadataLocation extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.AdditionalMetadataLocation {

private String locationURI;
public class AdditionalMetadataLocation extends AbstractXMLObject
implements org.opensaml.saml.saml2.metadata.AdditionalMetadataLocation {
@Column(name = "locationuri", nullable = true) private String locationURI;

private String namespaceURI;

@Override
public String getLocationURI() {
public String getURI() {
return locationURI;
}

@Override
public void setLocationURI(String locationURI) {
public void setURI(String locationURI) {
this.locationURI = locationURI;
}

Expand All @@ -32,4 +32,4 @@ public String getNamespaceURI() {
public void setNamespaceURI(String namespaceURI) {
this.namespaceURI = namespaceURI;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;


@Entity
@EqualsAndHashCode(callSuper = true)
public class AffiliateMember extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.AffiliateMember {

private String localId;
@Column(name = "local_id")
private String uri;

@Override
public String getID() {
return this.localId;
public String getURI() {
return this.uri;
}

@Override
public void setID(String id) {
this.localId = id;
public void setURI(String uri) {
this.uri = uri;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public void setServiceDescriptions(List<ServiceDescription> serviceDescriptions)
}

@Override
public List<org.opensaml.saml.saml2.metadata.RequestedAttribute> getRequestAttributes() {
public List<org.opensaml.saml.saml2.metadata.RequestedAttribute> getRequestedAttributes() {
return (List<org.opensaml.saml.saml2.metadata.RequestedAttribute>) (List<? extends org.opensaml.saml.saml2.metadata.RequestedAttribute>) this.requestedAttributes;
}

public void setRequestedAttributes(List<RequestedAttribute> requestedAttributes) {
this.requestedAttributes = requestedAttributes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;


@Entity
@EqualsAndHashCode(callSuper = true)
public class AttributeProfile extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.AttributeProfile {

private String profileURI;
@Column(name = "profileuri") private String uri;

@Override
public String getProfileURI() {
return profileURI;
public String getURI() {
return uri;
}

@Override
public void setProfileURI(String profileURI) {
this.profileURI = profileURI;
public void setURI(String uri) {
this.uri = uri;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
package edu.internet2.tier.shibboleth.admin.ui.domain;

import lombok.EqualsAndHashCode;
import org.opensaml.core.xml.util.AttributeMap;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Map;

/**
* Since Java doesn't support multiple inheritance, this is based on a copy of previously written code - AbstractAttributeExtensibleXMLObject
*/
@Entity
@EqualsAndHashCode(callSuper = true)
public class AttributeValue extends AbstractXMLObject implements org.opensaml.saml.saml2.core.AttributeValue {
}
public class AttributeValue extends AbstractElementExtensibleXMLObject implements org.opensaml.saml.saml2.core.AttributeValue {
private transient final AttributeMap unknownAttributes = new AttributeMap(this);
private String textContent;
@ElementCollection private Map<QName, String> storageAttributeMap = new HashMap<>();

@Nullable
@Override
public String getTextContent() {
return null;
}

@Override
public void setTextContent(@Nullable String newContent) {
this.textContent = newContent;
}

@Nonnull
@Override
@Transient
public AttributeMap getUnknownAttributes() {
return this.unknownAttributes;
}

@PrePersist
void prePersist() {
this.storageAttributeMap = this.unknownAttributes;
}

@PostLoad
void postLoad() {
this.unknownAttributes.putAll(this.storageAttributeMap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;


@Entity
@EqualsAndHashCode(callSuper = true)
public class Company extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.Company {

private String name;
@Column(name = "name")
private String value;

@Override
public String getName() {
return name;
public String getValue() {
return value;
}

@Override
public void setName(String name) {
this.name = name;
public void setValue(String value) {
this.value = value;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package edu.internet2.tier.shibboleth.admin.ui.domain;

import lombok.EqualsAndHashCode;
import org.hibernate.envers.AuditOverride;
import org.hibernate.envers.Audited;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
@EqualsAndHashCode(callSuper = true)
@Audited
public class EmailAddress extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.EmailAddress {

private String address;
@Column(name = "address")
private String uri;

@Override
public String getAddress() {
return address;
public String getURI() {
return uri;
}

@Override
public void setAddress(String address) {
this.address = address;
public void setURI(String uri) {
this.uri = uri;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import lombok.EqualsAndHashCode;
import org.hibernate.envers.Audited;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.ext.saml2mdattr.impl.EntityAttributesImpl;
import org.opensaml.saml.saml2.core.Assertion;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -55,4 +57,17 @@ public List<XMLObject> getOrderedChildren() {

return Collections.unmodifiableList(children);
}
}

@Override
public List<SAMLObject> getEntityAttributesChildren() {
ArrayList<SAMLObject> children = new ArrayList<>();

if (this.getAssertions().size() == 0 && this.getAttributes().size() == 0) {
return null;
}

children.addAll(this.getAttributes());
children.addAll(this.getAssertions());
return children;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package edu.internet2.tier.shibboleth.admin.ui.domain;

import lombok.EqualsAndHashCode;
import org.hibernate.envers.AuditOverride;
import org.hibernate.envers.Audited;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
@EqualsAndHashCode(callSuper = true)
@Audited
public class GivenName extends AbstractXMLObject implements org.opensaml.saml.saml2.metadata.GivenName {

private String name;
@Column(name = "name")
private String value;

@Override
public String getName() {
return name;
public String getValue() {
return value;
}

@Override
public void setName(String name) {
this.name = name;
public void setValue(String value) {
this.value = value;
}
}
}
Loading

0 comments on commit dfddcbe

Please sign in to comment.