KEYCLOAK-2238 Added null check into AbstractAdapterTest

This commit is contained in:
Tomas Kyjovsky 2016-01-20 07:21:31 +01:00
parent 9a63039d1a
commit efb82cbafb

View file

@ -95,28 +95,32 @@ public abstract class AbstractAdapterTest extends AbstractAuthTest {
}
protected void modifyClientWebOrigins(RealmRepresentation realm, String regex, String replacement) {
for (ClientRepresentation client : realm.getClients()) {
List<String> webOrigins = client.getWebOrigins();
if (webOrigins != null) {
List<String> newWebOrigins = new ArrayList<>();
for (String uri : webOrigins) {
newWebOrigins.add(uri.replaceAll(regex, replacement));
if (realm.getClients() != null) {
for (ClientRepresentation client : realm.getClients()) {
List<String> webOrigins = client.getWebOrigins();
if (webOrigins != null) {
List<String> newWebOrigins = new ArrayList<>();
for (String uri : webOrigins) {
newWebOrigins.add(uri.replaceAll(regex, replacement));
}
client.setWebOrigins(newWebOrigins);
}
client.setWebOrigins(newWebOrigins);
}
}
}
protected void modifySamlMasterURLs(RealmRepresentation realm, String regex, String replacement) {
for (ClientRepresentation client : realm.getClients()) {
if (client.getProtocol() != null && client.getProtocol().equals("saml")) {
log.info("Modifying master URL of SAML client: " + client.getClientId());
String masterUrl = client.getAdminUrl();
if (masterUrl == null) {
masterUrl = client.getBaseUrl();
if (realm.getClients() != null) {
for (ClientRepresentation client : realm.getClients()) {
if (client.getProtocol() != null && client.getProtocol().equals("saml")) {
log.info("Modifying master URL of SAML client: " + client.getClientId());
String masterUrl = client.getAdminUrl();
if (masterUrl == null) {
masterUrl = client.getBaseUrl();
}
masterUrl = masterUrl.replaceFirst(regex, replacement);
client.setAdminUrl(masterUrl);
}
masterUrl = masterUrl.replaceFirst(regex, replacement);
client.setAdminUrl(masterUrl);
}
}
}