Skip to content

Commit

Permalink
[SHIBUI-999]
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
jj committed Nov 14, 2018
1 parent 7833ae1 commit 06fb86e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
3 changes: 0 additions & 3 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ dependencies {

//JSON schema validator
compile 'org.sharegov:mjson:1.4.1'

//Apache commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.6'
}

def generatedSrcDir = new File(buildDir, 'generated/src/main/java')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package edu.internet2.tier.shibboleth.admin.ui.jsonschema

import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityDescriptorRepresentation
import mjson.Json
import org.apache.commons.io.IOUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.MethodParameter
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpInputMessage
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand Down Expand Up @@ -43,26 +41,18 @@ class RelyingPartyOverridesJsonSchemaValidatingControllerAdvice extends RequestB
HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter,
Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
throws IOException {
def baos = new ByteArrayOutputStream()
IOUtils.copy(inputMessage.body, baos)
def bytes = baos.toByteArray()
def bytes = inputMessage.body.bytes
def schema = Json.schema(this.jsonSchemaLocation.uri)

def stream = new ByteArrayInputStream(bytes)
def validationResult = schema.validate(Json.read(stream.getText()))
if (!validationResult.at('ok')) {
throw new JsonSchemaValidationFailedException(validationResult.at('errors').asList())
}
return new HttpInputMessage() {
@Override
InputStream getBody() throws IOException {
return new ByteArrayInputStream(bytes)
}

@Override
HttpHeaders getHeaders() {
return inputMessage.getHeaders()
}
}
return [
getBody: { new ByteArrayInputStream(bytes) },
getHeaders: { inputMessage.headers }
] as HttpInputMessage
}

@ExceptionHandler(JsonSchemaValidationFailedException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public List<Attribute> getAttributeListFromRelyingPartyOverridesRepresentation(M
case BOOLEAN:
if (overrideProperty.getPersistType() != null &&
!overrideProperty.getPersistType().equalsIgnoreCase("boolean") &&
Boolean.valueOf((String)entry.getValue())) {
(Boolean)entry.getValue()) {
list.add(attributeUtility.createAttributeWithStringValues(overrideProperty.getAttributeName(),
overrideProperty.getAttributeFriendlyName(),
overrideProperty.getPersistValue()));
Expand Down

0 comments on commit 06fb86e

Please sign in to comment.