forked from dbarentine/keycloak-wsfed
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLOUDTRUST-2708] Add install.sh and fix some Sonar code smells
- Loading branch information
Showing
65 changed files
with
1,801 additions
and
960 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...wsfed-tests/src/test/java/com/quest/keycloak/common/wsfed/parsers/AbstractParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.quest.keycloak.common.wsfed.parsers; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.function.Function; | ||
|
||
import javax.xml.stream.XMLEventReader; | ||
|
||
import org.picketlink.common.exceptions.ParsingException; | ||
import org.picketlink.common.util.StaxParserUtil; | ||
|
||
public abstract class AbstractParserTest { | ||
@SuppressWarnings({ "unchecked" }) | ||
protected <T> T parseFile(String filename, Class<T> clazz, Function<String, String>... updaters) throws ParsingException, IOException { | ||
return clazz.cast(new WSTrustParser().parse(getXMLEventReader(filename, updaters))); | ||
} | ||
|
||
protected InputStream getInputStream(String filename) { | ||
InputStream stream = WSTRequestSecurityTokenResponseCollectionParserTest.class.getResourceAsStream(filename); | ||
if (stream==null) { | ||
try { | ||
stream = new FileInputStream("src/test/resources"+filename); | ||
} catch (IOException e) { | ||
// Ignore | ||
} | ||
} | ||
return stream; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
protected XMLEventReader getXMLEventReader(String filename, Function<String, String>... updaters) throws IOException { | ||
if (updaters==null) { | ||
return StaxParserUtil.getXMLEventReader(getInputStream(filename)); | ||
} | ||
String xml; | ||
try (InputStream input = getInputStream(filename)) { | ||
byte[] content = new byte[input.available()]; | ||
input.read(content); | ||
xml = new String(content, StandardCharsets.UTF_8); | ||
} | ||
if (updaters!=null) { | ||
for(Function<String, String> updater : updaters) { | ||
xml = updater.apply(xml); | ||
} | ||
} | ||
try (InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) { | ||
return StaxParserUtil.getXMLEventReader(stream); | ||
} | ||
} | ||
} |
Oops, something went wrong.