Repository: SAP/cloud-security-xsuaa-integration
Pull request #933 (2022-07-07 10:04:37)

Bump spotbugs-maven-plugin from 4.7.0.0 to 4.7.1.0
Bumps [spotbugs-maven-plugin](https://github.com/spotbugs/spotbugs-maven-plugin) from 4.7.0.0 to 4.7.1.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/spotbugs/spotbugs-maven-plugin/releases">spotbugs-maven-plugin's releases</a>.</em></p>
<blockquote>
<h2>Spotbugs Maven Plugin 4.7.1.0</h2>
<ul>
<li>Support spotbugs 4.7.1</li>
<li>Add support for multiple bug inclusion, excusion, and baseline files.  See PR <a href="https://github-redirect.dependabot.com/spotbugs/spotbugs-maven-plugin/issues/436">#436</a></li>
<li>Build Updates including usage of asm bom, groovy bom, and adjustment to asm to ensure it works after maven changes</li>
<li>Invoker plugin set to groovy 3 while project is groovy 4 as invoker needs older groovy.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/f87e38e82db044e8c745cb6738abc3ef9c987aa5"><code>f87e38e</code></a> [maven-release-plugin] prepare release spotbugs-maven-plugin-4.7.1.0</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/22364463d63d7419465c82a19cfa2f3304d8db66"><code>2236446</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/spotbugs/spotbugs-maven-plugin/issues/447">#447</a> from hazendaz/spotbugs</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/993d405f7132fb98e4c9a35186e9af42fc411983"><code>993d405</code></a> [pom] Adjust since to match release version in flight</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/c0b2fff3389d38ecaa78b99b97c067030b08297a"><code>c0b2fff</code></a> [pom] Bump jgit to 5.13.1.202206130422-r</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/294077eaa20680e8988d4be6462e4e53d4c096f2"><code>294077e</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/spotbugs/spotbugs-maven-plugin/issues/436">#436</a> from hgschmie/multi-files</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/070c0e37195ae605cefcb408350d3b410a993bb9"><code>070c0e3</code></a> Support multiple bug baseline files.</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/b3e0d8cc60236829d6461e7d98619ede6f325336"><code>b3e0d8c</code></a> Support multiple bug exclusion files.</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/cd7fbd38ba321aa2dd35cd0a3ba663526bb32c93"><code>cd7fbd3</code></a> Support multiple bug inclusion files.</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/0dddbd64464d7f754160f00dea85b868d4ae949d"><code>0dddbd6</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/spotbugs/spotbugs-maven-plugin/issues/446">#446</a> from hazendaz/spotbugs</li>
<li><a href="https://github.com/spotbugs/spotbugs-maven-plugin/commit/b95221987fd0bcc200000b046fc1f925a6287b0c"><code>b952219</code></a> [pom] Order 'asm' first to overcome issues with maven changes</li>
<li>Additional commits viewable in <a href="https://github.com/spotbugs/spotbugs-maven-plugin/compare/spotbugs-maven-plugin-4.7.0.0...spotbugs-maven-plugin-4.7.1.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.github.spotbugs:spotbugs-maven-plugin&package-manager=maven&previous-version=4.7.0.0&new-version=4.7.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/env/pom.xml b/env/pom.xml
index 604f2b06..530bdd41 100644
--- a/env/pom.xml
+++ b/env/pom.xml
@@ -23,17 +23,25 @@
             <artifactId>java-api</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <!-- Required only in case of multiple xsuaa bindings -->
         <dependency>
-            <groupId>com.sap.cloud.security.xsuaa</groupId>
-            <artifactId>token-client</artifactId>
-            <version>${project.version}</version>
-            <scope>provided</scope>
+            <groupId>com.sap.cloud.environment.servicebinding</groupId>
+            <artifactId>java-sap-service-operator</artifactId>
+        </dependency>
+        <dependency><!-- optional if using TypedMapView etc. -->
+            <groupId>com.sap.cloud.environment.servicebinding.api</groupId>
+            <artifactId>java-consumption-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sap.cloud.environment.servicebinding.api</groupId>
+            <artifactId>java-access-api</artifactId>
         </dependency>
-        <!-- Required only in case of multiple xsuaa bindings -->
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -96,6 +104,11 @@
             <version>2.7.10</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/env/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java b/env/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
index 31a433e4..a9749439 100644
--- a/env/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
+++ b/env/src/main/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilder.java
@@ -159,10 +159,12 @@ public class OAuth2ServiceConfigurationBuilder {
 	 * @return this builder itself
 	 */
 	public OAuth2ServiceConfigurationBuilder withDomains(String... domains) {
-		if (Service.XSUAA.equals(service)) {
-			properties.put(XSUAA.UAA_DOMAIN, domains[0]);
-		} else {
-			this.domains = Arrays.asList(domains);
+		if (domains != null) {
+			if (Service.XSUAA.equals(service) && domains.length == 1) {
+				properties.put(XSUAA.UAA_DOMAIN, domains[0]);
+			} else {
+				this.domains = Arrays.asList(domains);
+			}
 		}
 		return this;
 	}
diff --git a/env/src/main/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerService.java b/env/src/main/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerService.java
deleted file mode 100644
index 0496c41a..00000000
--- a/env/src/main/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerService.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import com.sap.cloud.security.client.HttpClientFactory;
-import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import com.sap.cloud.security.xsuaa.client.DefaultOAuth2TokenService;
-import com.sap.cloud.security.xsuaa.client.OAuth2ServiceException;
-import com.sap.cloud.security.xsuaa.client.OAuth2TokenResponse;
-import com.sap.cloud.security.xsuaa.client.OAuth2TokenService;
-import com.sap.cloud.security.xsuaa.util.HttpClientUtil;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The DefaultServiceManagerService fetches information about service instances
- * and service instance plans.
- */
-class DefaultServiceManagerService {
-	private static final Logger LOGGER = LoggerFactory.getLogger(DefaultServiceManagerService.class);
-	private static final String SERVICE_PLANS = "/v1/service_plans";
-	private static final String SERVICE_INSTANCES = "/v1/service_instances";
-
-	private final CloseableHttpClient httpClient;
-	private final OAuth2ServiceConfiguration smConfiguration;
-	private final OAuth2TokenService defaultOAuth2TokenService;
-
-	DefaultServiceManagerService(OAuth2ServiceConfiguration smConfiguration) {
-		this(smConfiguration, HttpClientFactory.create(smConfiguration.getClientIdentity()));
-	}
-
-	DefaultServiceManagerService(OAuth2ServiceConfiguration smConfiguration, CloseableHttpClient httpClient) {
-		this.smConfiguration = smConfiguration;
-		this.httpClient = httpClient;
-		this.defaultOAuth2TokenService = new DefaultOAuth2TokenService(this.httpClient);
-	}
-
-	Map<String, String> getServiceInstancePlans() {
-		Map<String, String> servicePlans = getServicePlans();
-		Map<String, String> serviceInstances = getServiceInstances();
-		if (serviceInstances.isEmpty() || servicePlans.isEmpty()) {
-			LOGGER.warn("Couldn't fetch plans or instances from service-manager");
-			return Collections.emptyMap();
-		}
-		serviceInstances.keySet().forEach(k -> serviceInstances.put(k, servicePlans.get(serviceInstances.get(k))));
-		LOGGER.debug("Service Instances with plan names: {}", serviceInstances);
-		return serviceInstances;
-	}
-
-	// TODO make private, adjust tests
-	Map<String, String> getServicePlans() {
-		HttpUriRequest request = RequestBuilder.create("GET")
-				.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + retrieveAccessToken())
-				.setUri(smConfiguration.getProperty("sm_url") + SERVICE_PLANS)
-				.build();
-		Map<String, String> servicePlanMap = new HashMap<>();
-		try {
-			JSONArray responseArray = executeRequest(request);
-			responseArray.forEach(plan -> servicePlanMap.put((String) ((JSONObject) plan).get("id"),
-					(String) ((JSONObject) plan).get("name")));
-		} catch (OAuth2ServiceException e) {
-			LOGGER.warn("Unexpected error occurred: {}", e.getMessage());
-		}
-		LOGGER.debug("Service plans: {}", servicePlanMap);
-		return servicePlanMap;
-	}
-
-	// TODO make private, adjust tests
-	Map<String, String> getServiceInstances() {
-		HttpUriRequest request = RequestBuilder.create("GET")
-				.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + retrieveAccessToken())
-				.setUri(smConfiguration.getProperty("sm_url") + SERVICE_INSTANCES)
-				.build();
-		Map<String, String> serviceInstanceMap = new HashMap<>();
-		try {
-			JSONArray responseArray = executeRequest(request);
-			responseArray.forEach(plan -> serviceInstanceMap.put((String) ((JSONObject) plan).get("name"),
-					(String) ((JSONObject) plan).get("service_plan_id")));
-		} catch (OAuth2ServiceException e) {
-			LOGGER.warn("Unexpected error occurred: {}", e.getMessage());
-		}
-		LOGGER.debug("Service instances: {}", serviceInstanceMap);
-		return serviceInstanceMap;
-	}
-
-	private JSONArray executeRequest(HttpUriRequest httpRequest) throws OAuth2ServiceException {
-		LOGGER.debug("Executing Http request to {} with headers {}", httpRequest.getURI(),
-				httpRequest.getAllHeaders());
-		try (CloseableHttpResponse response = httpClient.execute(httpRequest)) {
-			int statusCode = response.getStatusLine().getStatusCode();
-			LOGGER.debug("Received statusCode {} from {}", statusCode, httpRequest.getURI());
-			if (statusCode == HttpStatus.SC_OK) {
-				return handleResponse(response);
-			} else {
-				String responseBodyAsString = HttpClientUtil.extractResponseBodyAsString(response);
-				LOGGER.debug("Received response body: {}", responseBodyAsString);
-				throw OAuth2ServiceException.builder("Error accessing service-manager endpoint")
-						.withStatusCode(statusCode)
-						.withUri(httpRequest.getURI())
-						.withResponseBody(responseBodyAsString)
-						.build();
-			}
-		} catch (IOException e) {
-			throw new OAuth2ServiceException(String.format("Unexpected error accessing service-manager endpoint %s: %s",
-					httpRequest.getURI(), e.getMessage()));
-		}
-	}
-
-	private JSONArray handleResponse(HttpResponse response) throws IOException {
-		String responseBody = HttpClientUtil.extractResponseBodyAsString(response);
-		return new JSONObject(responseBody).getJSONArray("items");
-	}
-
-	@Nullable
-	private String retrieveAccessToken() {
-		try {
-			OAuth2TokenResponse oAuth2TokenResponse = defaultOAuth2TokenService
-					.retrieveAccessTokenViaClientCredentialsGrant(smConfiguration.getUrl().resolve("/oauth/token"),
-							smConfiguration.getClientIdentity(), null, null, null, false);
-			return oAuth2TokenResponse.getAccessToken();
-		} catch (OAuth2ServiceException e) {
-			LOGGER.warn("Couldn't retrieve access token for service manager.", e);
-			return null;
-		}
-	}
-}
diff --git a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sEnvironment.java b/env/src/main/java/com/sap/cloud/security/config/k8s/K8sEnvironment.java
index 4b044e00..27dccf0d 100644
--- a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sEnvironment.java
+++ b/env/src/main/java/com/sap/cloud/security/config/k8s/K8sEnvironment.java
@@ -5,18 +5,25 @@
  */
 package com.sap.cloud.security.config.k8s;
 
+import com.sap.cloud.environment.servicebinding.api.DefaultServiceBindingAccessor;
+import com.sap.cloud.environment.servicebinding.api.ServiceBinding;
+import com.sap.cloud.environment.servicebinding.api.TypedMapView;
 import com.sap.cloud.security.config.Environment;
 import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
+import com.sap.cloud.security.config.OAuth2ServiceConfigurationBuilder;
 import com.sap.cloud.security.config.Service;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
+import static com.sap.cloud.security.config.cf.CFConstants.IAS.DOMAINS;
+import static com.sap.cloud.security.config.cf.CFConstants.SERVICE_PLAN;
+import static com.sap.cloud.security.config.cf.CFConstants.XSUAA.UAA_DOMAIN;
 import static com.sap.cloud.security.config.k8s.K8sConstants.Plan;
 
 /**
@@ -28,11 +35,12 @@ import static com.sap.cloud.security.config.k8s.K8sConstants.Plan;
 public class K8sEnvironment implements Environment {
 	private static final Logger LOGGER = LoggerFactory.getLogger(K8sEnvironment.class);
 
-	private static K8sEnvironment instance;
-	private final Map<Service, Map<String, OAuth2ServiceConfiguration>> k8sServiceConfigurations;
+	static K8sEnvironment instance;
+	private final Map<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfigurations;
 
 	private K8sEnvironment() {
-		k8sServiceConfigurations = new K8sServiceConfigurationProvider().getServiceConfigurations();
+		serviceConfigurations = new EnumMap<>(Service.class);
+		loadAll();
 	}
 
 	public static K8sEnvironment getInstance() {
@@ -48,15 +56,66 @@ public class K8sEnvironment implements Environment {
 		return Type.KUBERNETES;
 	}
 
+	private void loadAll() {
+		List<ServiceBinding> serviceBindings = DefaultServiceBindingAccessor.getInstance().getServiceBindings();
+
+		Map<String, OAuth2ServiceConfiguration> xsuaaPlans = serviceBindings.stream()
+				.filter(b -> Service.XSUAA.getCFName().equalsIgnoreCase(b.getServiceName().orElse(null)))
+				.map(this::mapToOAuth2ServiceConfiguration)
+				.collect(Collectors.toMap(config -> config.getProperty(SERVICE_PLAN),
+						Function.identity()));
+		Map<String, OAuth2ServiceConfiguration> identityPlans = serviceBindings.stream()
+				.filter(b -> Service.IAS.getCFName().equalsIgnoreCase(b.getServiceName().orElse(null)))
+				.map(this::mapToOAuth2ServiceConfiguration)
+				.collect(Collectors.toMap(config -> config.getProperty(SERVICE_PLAN),
+						Function.identity()));
+		serviceConfigurations.put(Service.XSUAA, xsuaaPlans);
+		serviceConfigurations.put(Service.IAS, identityPlans);
+	}
+
+	private OAuth2ServiceConfiguration mapToOAuth2ServiceConfiguration(ServiceBinding b) {
+		if (!b.getServiceName().isPresent()) {
+			LOGGER.error("Ignores Service Binding with name {} as service name is not provided.", b.getName());
+			return null; // as of now, method is never called when service name isn't given
+		}
+		final Service service = Service.from(b.getServiceName().get());
+		OAuth2ServiceConfigurationBuilder configBuilder = OAuth2ServiceConfigurationBuilder.forService(service)
+				.withProperties(TypedMapView.ofCredentials(b).getEntries(String.class))
+				.withProperty(SERVICE_PLAN, b.getServicePlan().orElse(Plan.APPLICATION.name()).toUpperCase());
+		switch (service) {
+		case XSUAA:
+			configBuilder.withProperty(UAA_DOMAIN,
+					(String) b.getCredentials().get(UAA_DOMAIN));
+			break;
+		case IAS:
+			List<String> domains = TypedMapView.ofCredentials(b).getListView(DOMAINS).getItems(String.class);
+			LOGGER.info("first domain : {}", domains.get(0));
+			configBuilder.withDomains(domains.toArray(new String[] {}));
+			break;
+		}
+		return configBuilder.build();
+	}
+
+	/**
+	 * Loads all configurations of all service instances of the dedicated service.
+	 *
+	 * @param service
+	 *            the service name
+	 * @return the list of all found configurations or empty map, in case there are
+	 *         no service bindings.
+	 */
+	Map<String, OAuth2ServiceConfiguration> getServiceConfigurationsOf(Service service) {
+		return serviceConfigurations.getOrDefault(service, Collections.emptyMap());
+	}
+
 	@Nullable
 	@Override
 	public OAuth2ServiceConfiguration getXsuaaConfiguration() {
-		Map<String, OAuth2ServiceConfiguration> xsuaaPlans = k8sServiceConfigurations.get(Service.XSUAA);
-
-		return Optional.ofNullable(xsuaaPlans.get(Plan.APPLICATION.name()))
-				.orElse(Optional.ofNullable(xsuaaPlans.get(Plan.BROKER.name()))
-						.orElse(Optional.ofNullable(xsuaaPlans.get(Plan.SPACE.name()))
-								.orElse(Optional.ofNullable(xsuaaPlans.get(Plan.DEFAULT.name()))
+		return Optional.ofNullable(getServiceConfigurationsOf(Service.XSUAA).get(Plan.APPLICATION.name()))
+				.orElse(Optional.ofNullable(getServiceConfigurationsOf(Service.XSUAA).get(Plan.BROKER.name()))
+						.orElse(Optional.ofNullable(getServiceConfigurationsOf(Service.XSUAA).get(Plan.SPACE.name()))
+								.orElse(Optional
+										.ofNullable(getServiceConfigurationsOf(Service.XSUAA).get(Plan.DEFAULT.name()))
 										.orElse(null))));
 
 	}
@@ -65,7 +124,7 @@ public class K8sEnvironment implements Environment {
 	@Override
 	public OAuth2ServiceConfiguration getXsuaaConfigurationForTokenExchange() {
 		if (getNumberOfXsuaaConfigurations() > 1) {
-			return k8sServiceConfigurations.get(Service.XSUAA).get(Plan.BROKER.name());
+			return getServiceConfigurationsOf(Service.XSUAA).get(Plan.BROKER.name());
 		}
 		return getXsuaaConfiguration();
 	}
@@ -73,17 +132,17 @@ public class K8sEnvironment implements Environment {
 	@Nullable
 	@Override
 	public OAuth2ServiceConfiguration getIasConfiguration() {
-		Set<Map.Entry<String, OAuth2ServiceConfiguration>> iasConfigEntries = k8sServiceConfigurations
-				.get(Service.IAS).entrySet();
-		if (iasConfigEntries.size() > 1) {
-			LOGGER.warn("{} IAS bindings found. Using the first one from the list", iasConfigEntries.size());
+		if (getServiceConfigurationsOf(Service.IAS).size() > 1) {
+			LOGGER.warn("{} IAS bindings found. Using the first one from the list",
+					getServiceConfigurationsOf(Service.IAS).size());
 		}
-		return iasConfigEntries.stream().findFirst().map(Map.Entry::getValue).orElse(null);
+		return getServiceConfigurationsOf(Service.IAS).entrySet().stream().findFirst().map(Map.Entry::getValue)
+				.orElse(null);
 	}
 
 	@Override
 	public int getNumberOfXsuaaConfigurations() {
-		return k8sServiceConfigurations.get(Service.XSUAA).size();
+		return getServiceConfigurationsOf(Service.XSUAA).size();
 	}
 
 }
diff --git a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProvider.java b/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProvider.java
deleted file mode 100644
index 4588dfde..00000000
--- a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProvider.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import com.sap.cloud.security.config.Service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The K8sServiceConfigurationProvider provides the information of all bound
- * service configurations.
- */
-class K8sServiceConfigurationProvider {
-	private static final Logger LOGGER = LoggerFactory.getLogger(K8sServiceConfigurationProvider.class);
-	private static final String APPLICATION = "APPLICATION";
-
-	private DefaultServiceManagerService serviceManagerClient;
-	private final K8sServiceConfigurationResolver serviceConfigurationResolver;
-
-	K8sServiceConfigurationProvider() {
-		this.serviceConfigurationResolver = new K8sServiceConfigurationResolver();
-		if (serviceConfigurationResolver
-				.loadOauth2ServiceConfig(Service.XSUAA).size() > 1
-				&& serviceConfigurationResolver.loadServiceManagerConfig() != null) {
-			this.serviceManagerClient = new DefaultServiceManagerService(
-					serviceConfigurationResolver.loadServiceManagerConfig());
-		}
-	}
-
-	void setServiceManagerClient(DefaultServiceManagerService serviceManagerClient) {
-		this.serviceManagerClient = serviceManagerClient;
-	}
-
-	/**
-	 * Gets all service configurations from the mounted file volumes.
-	 *
-	 * @return the service configurations map of IAS and XSUAA services with their
-	 *         corresponding OAuth2ServiceConfigurations. For Xsuaa Map key is the
-	 *         service plan name, for IAS key is the service instance name.
-	 */
-	EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> getServiceConfigurations() {
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfigurations = new EnumMap<>(Service.class);
-
-		serviceConfigurations.put(Service.XSUAA, mapXsuaaServicePlans(serviceConfigurationResolver
-				.loadOauth2ServiceConfig(Service.XSUAA)));
-		serviceConfigurations.put(Service.IAS, serviceConfigurationResolver
-				.loadOauth2ServiceConfig(Service.IAS));
-
-		return serviceConfigurations;
-	}
-
-	private Map<String, OAuth2ServiceConfiguration> mapXsuaaServicePlans(
-			Map<String, OAuth2ServiceConfiguration> allXsuaaServices) {
-		Map<String, OAuth2ServiceConfiguration> allXsuaaServicesWithPlans = new HashMap<>();// <planName, config>
-
-		if (!allXsuaaServices.isEmpty() && allXsuaaServices.size() > 1) {
-			if (serviceManagerClient == null) {
-				return getSingleXsuaaConfigWithApplicationPlan(allXsuaaServices, "No service-manager client available");
-			}
-			Map<String, String> serviceInstancePlans = serviceManagerClient.getServiceInstancePlans();// <xsuaaName,planName>
-			if (serviceInstancePlans.isEmpty()) {
-				return getSingleXsuaaConfigWithApplicationPlan(allXsuaaServices,
-						"No plans or instances were fetched from service manager");
-			}
-			allXsuaaServices.keySet().forEach(
-					k -> allXsuaaServicesWithPlans.put(serviceInstancePlans.get(k).toUpperCase(),
-							allXsuaaServices.get(k)));
-		} else if (allXsuaaServices.size() == 1) {
-			return getSingleXsuaaConfigWithApplicationPlan(allXsuaaServices, null);
-		}
-		return allXsuaaServicesWithPlans;
-	}
-
-	private Map<String, OAuth2ServiceConfiguration> getSingleXsuaaConfigWithApplicationPlan(
-			Map<String, OAuth2ServiceConfiguration> allXsuaaServices, @Nullable String warningMessage) {
-		Map.Entry<String, OAuth2ServiceConfiguration> xsuaaServiceEntrySet = allXsuaaServices.entrySet().iterator()
-				.next();
-		if (warningMessage != null) {
-			LOGGER.warn("{}, taking first Xsuaa service instance '{}' and assigning 'application' plan", warningMessage,
-					xsuaaServiceEntrySet.getKey());
-		} else {
-			LOGGER.info("Assigning 'application' plan to '{}' service", xsuaaServiceEntrySet.getKey());
-		}
-		return Collections.singletonMap(APPLICATION, xsuaaServiceEntrySet.getValue());
-	}
-}
diff --git a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolver.java b/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolver.java
deleted file mode 100644
index 6cc11bc6..00000000
--- a/env/src/main/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolver.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import com.sap.cloud.security.config.OAuth2ServiceConfigurationBuilder;
-import com.sap.cloud.security.config.Service;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static com.sap.cloud.security.config.k8s.K8sConstants.*;
-
-/**
- * The K8sServiceConfigurationResolver manages the service secret access from
- * the file system.
- */
-class K8sServiceConfigurationResolver {
-	private static final Logger LOGGER = LoggerFactory.getLogger(K8sServiceConfigurationResolver.class);
-
-	private String xsuaaPath;
-	private String iasPath;
-	private String serviceManagerPath;
-
-	K8sServiceConfigurationResolver() {
-		resolveServiceConfigurationPaths();
-	}
-
-	/**
-	 * Loads Service manager OAuth2 service configuration.
-	 *
-	 * @return OAuth2 service configuration
-	 */
-	@Nullable
-	OAuth2ServiceConfiguration loadServiceManagerConfig() {
-		File[] serviceBindings = new File(serviceManagerPath).listFiles();
-		if (serviceBindings == null || serviceBindings.length == 0) {
-			LOGGER.warn("No service-manager binding was found in {}", serviceManagerPath);
-			return null;
-		}
-		Map<String, String> smPropertiesMap = getServiceProperties(serviceBindings[0]);
-		return OAuth2ServiceConfigurationBuilder.forService(Service.XSUAA).withProperties(smPropertiesMap).build();
-	}
-
-	/**
-	 * Loads XSUAA or IAS OAuth2 service configuration.
-	 *
-	 * @param service
-	 *            IAS or XSUAA service
-	 * @return the map of service instance name and it's OAuth2 service
-	 *         configurations
-	 */
-	Map<String, OAuth2ServiceConfiguration> loadOauth2ServiceConfig(Service service) {
-		Map<String, OAuth2ServiceConfiguration> allServices = new HashMap<>();
-		File[] serviceBindings = getServiceBindings(service);
-		if (serviceBindings == null || serviceBindings.length == 0) {
-			LOGGER.warn("No service bindings for {} service were found", service);
-		} else {
-			LOGGER.info("Found {} {} service binding/s", serviceBindings.length, service);
-			for (File binding : serviceBindings) {
-				Map<String, String> servicePropertiesMap = getServiceProperties(binding);
-				if (!servicePropertiesMap.isEmpty()) {
-					OAuth2ServiceConfiguration config;
-					if (servicePropertiesMap.containsKey("domains")) {
-						config = OAuth2ServiceConfigurationBuilder.forService(service)
-								.withProperties(servicePropertiesMap)
-								.withDomains(
-										servicePropertiesMap.get("domains").replaceAll("[\\[\"\\s\\]]+", "").split(","))
-								.build();
-					} else {
-						config = OAuth2ServiceConfigurationBuilder.forService(service)
-								.withProperties(servicePropertiesMap)
-								.build();
-					}
-					allServices.put(binding.getName(), config);
-				}
-			}
-		}
-		return allServices;
-	}
-
-	@Nullable
-	private File[] getServiceBindings(Service service) {
-		String path = service == Service.XSUAA ? xsuaaPath : iasPath;
-		LOGGER.debug("Retrieving {} service bindings from K8s secret file {}", service, path);
-		File[] bindings = new File(path).listFiles();
-		if (bindings != null) {
-			return Arrays.stream(bindings).filter(File::isDirectory).toArray(File[]::new);
-		}
-		return null;
-	}
-
-	private List<File> getBindingFiles(@Nonnull File binding) {
-		File[] bindingFiles = new File(binding.getPath()).listFiles();
-		if (bindingFiles == null || bindingFiles.length == 0) {
-			LOGGER.warn("No service binding files were found for {}", binding.getName());
-			return Collections.emptyList();
-		}
-		return Arrays.stream(bindingFiles).filter(File::isFile)
-				.collect(Collectors.toList());
-	}
-
-	private Map<String, String> getServiceProperties(File binding) {
-		List<File> serviceBindingFiles = getBindingFiles(binding);
-		if (serviceBindingFiles.isEmpty()) {
-			return Collections.emptyMap();
-		}
-		return mapServiceProperties(serviceBindingFiles);
-	}
-
-	private Map<String, String> mapServiceProperties(List<File> servicePropertiesList) {
-		final Map<String, String> serviceProperties = new HashMap<>();
-		for (final File property : servicePropertiesList) {
-			try {
-				final List<String> lines = readLinesFromFile(property);
-				if (!lines.isEmpty()) {
-					serviceProperties.put(property.getName(), String.join("\\n", lines));
-				} else {
-					LOGGER.warn("{} value is empty", property.getName());
-				}
-			} catch (IOException ex) {
-				LOGGER.error("Failed to read content of service configuration property files", ex);
-				return serviceProperties;
-			}
-		}
-		LOGGER.debug("{} attributes: {}", servicePropertiesList.get(0).getParentFile().getName(), serviceProperties);
-		return serviceProperties;
-	}
-
-	@Nonnull
-	private static List<String> readLinesFromFile(File property) throws IOException {
-		return Files.readAllLines(Paths.get(property.getAbsolutePath()));
-	}
-
-	private void resolveServiceConfigurationPaths() {
-		this.xsuaaPath = getUserDefinedConfigurationPath(XSUAA_CONFIG_PATH);
-		this.iasPath = getUserDefinedConfigurationPath(IAS_CONFIG_PATH);
-		this.serviceManagerPath = getUserDefinedConfigurationPath(SM_CONFIG_PATH);
-		if (this.xsuaaPath == null) {
-			this.xsuaaPath = XSUAA_CONFIG_PATH_DEFAULT;
-		}
-		if (this.iasPath == null) {
-			this.iasPath = IAS_CONFIG_PATH_DEFAULT;
-		}
-		if (this.serviceManagerPath == null) {
-			this.serviceManagerPath = SERVICE_MANAGER_CONFIG_PATH_DEFAULT;
-		}
-	}
-
-	@Nullable
-	private String getUserDefinedConfigurationPath(String xsuaaConfigPath) {
-		// Resolves also empty string as null
-		if (System.getenv(xsuaaConfigPath) == null || System.getenv(xsuaaConfigPath).isEmpty()) {
-			return null;
-		}
-		return System.getenv(xsuaaConfigPath);
-	}
-}
diff --git a/java-api/src/main/java/com/sap/cloud/security/config/Service.java b/java-api/src/main/java/com/sap/cloud/security/config/Service.java
index 4147a994..fff4d2f5 100644
--- a/java-api/src/main/java/com/sap/cloud/security/config/Service.java
+++ b/java-api/src/main/java/com/sap/cloud/security/config/Service.java
@@ -8,6 +8,8 @@ package com.sap.cloud.security.config;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nullable;
+
 /**
  * Represents a supported identity service.
  */
@@ -39,4 +41,14 @@ public enum Service {
 	public String getCFName() {
 		return cloudFoundryName;
 	}
+
+	@Nullable
+	public static Service from(String cloudFoundryName) {
+		for (Service service : values()) {
+			if (service.cloudFoundryName.equalsIgnoreCase(cloudFoundryName)) {
+				return service;
+			}
+		}
+		return null;
+	}
 }
diff --git a/java-api/src/main/java/com/sap/cloud/security/config/k8s/K8sConstants.java b/java-api/src/main/java/com/sap/cloud/security/config/k8s/K8sConstants.java
index 9c4d2c8a..1883e55c 100644
--- a/java-api/src/main/java/com/sap/cloud/security/config/k8s/K8sConstants.java
+++ b/java-api/src/main/java/com/sap/cloud/security/config/k8s/K8sConstants.java
@@ -13,22 +13,6 @@ import com.sap.cloud.security.config.cf.CFConstants;
  */
 public class K8sConstants {
 	public static final String KUBERNETES_SERVICE_HOST = "KUBERNETES_SERVICE_HOST";
-	static final String XSUAA_CONFIG_PATH_DEFAULT = "/etc/secrets/sapbtp/xsuaa";
-	static final String IAS_CONFIG_PATH_DEFAULT = "/etc/secrets/sapbtp/identity";
-	static final String SERVICE_MANAGER_CONFIG_PATH_DEFAULT = "/etc/secrets/sapbtp/service-manager";
-
-	/**
-	 * System variable name for user defined Xsuaa configuration path
-	 */
-	static final String XSUAA_CONFIG_PATH = "XSUAA_CONFIG_PATH";
-	/**
-	 * System variable name for user defined IAS configuration path
-	 */
-	static final String IAS_CONFIG_PATH = "IAS_CONFIG_PATH";
-	/**
-	 * System variable name for user defined Service manager configuration path
-	 */
-	static final String SM_CONFIG_PATH = "SM_CONFIG_PATH";
 
 	private K8sConstants() {
 	}
diff --git a/java-security/README.md b/java-security/README.md
index 659ac3ce..8cfe33ea 100644
--- a/java-security/README.md
+++ b/java-security/README.md
@@ -96,9 +96,6 @@ To access service instance configurations from the application, Kubernetes secre
 Library will look up the configuration files in the following paths:
 - XSUAA: `/etc/secrets/sapbtp/xsuaa/<YOUR XSUAA INSTANCE NAME>`
 - IAS: `/etc/secrets/sapbtp/identity/<YOUR IAS INSTANCE NAME>`
-- Service-manager: `/etc/secrets/sapbtp/service-manager/<YOUR SERVICE-MANAGER NAME>`
-
-:exclamation: service-manager binding is mandatory to resolve multiple Xsuaa bindings! If it is not provided the first Xsuaa binding from a list is used and treated as instance with `application` plan.
 
 Detailed information on how to use ``java-security`` library in Kubernetes/Kyma environment can be found in [java-security-usage](/samples/java-security-usage/README.md#deployment-on-kymakubernetes) sample README.
 
diff --git a/pom.xml b/pom.xml
index e8340afd..6393bf29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
 		<log4j2.version>2.18.0</log4j2.version>
 		<slf4j.api.version>1.7.36</slf4j.api.version> <!--see also here http://www.slf4j.org/faq.html#changesInVersion18 -->
 		<org.json.version>20220320</org.json.version>
+		<sap.cloud.env.servicebinding.version>0.3.1</sap.cloud.env.servicebinding.version>
 		<google.jsr305.version>3.0.2</google.jsr305.version>
 		<apache.httpclient.version>4.5.13</apache.httpclient.version>
 		<caffeine.version>2.9.3</caffeine.version>
@@ -82,7 +83,7 @@
 		<wiremock.version>2.33.2</wiremock.version>
 		<javax.annotation.version>1.3.2</javax.annotation.version>
 		<spotbugs.annotations.version>4.7.1</spotbugs.annotations.version>
-		<spotbugs.version>4.7.0.0</spotbugs.version>
+		<spotbugs.version>4.7.1.0</spotbugs.version>
 		<skipTests>false</skipTests>
 		<jacoco.skip>${skipTests}</jacoco.skip>
 	</properties>
@@ -131,6 +132,13 @@
 				<type>pom</type>
 				<scope>import</scope>
 			</dependency>
+			<dependency>
+				<groupId>com.sap.cloud.environment.servicebinding</groupId>
+				<artifactId>java-bom</artifactId>
+				<version>${sap.cloud.env.servicebinding.version}</version>
+				<type>pom</type>
+				<scope>import</scope>
+			</dependency>
 			<!-- spring core -->
 			<dependency>
 				<groupId>org.springframework</groupId>
diff --git a/spring-security/README.md b/spring-security/README.md
index 258b8cf1..82649b2d 100644
--- a/spring-security/README.md
+++ b/spring-security/README.md
@@ -29,9 +29,6 @@ To access service instance configurations from the application, Kubernetes secre
 Library will look up the configuration files in the following paths:
 - XSUAA: `/etc/secrets/sapbtp/xsuaa/<YOUR XSUAA INSTANCE NAME>`
 - IAS: `/etc/secrets/sapbtp/identity/<YOUR IAS INSTANCE NAME>`
-- Service-manager: `/etc/secrets/sapbtp/service-manager/<YOUR SERVICE-MANAGER NAME>`
-
-:exclamation: service-manager binding is mandatory to resolve multiple Xsuaa bindings! If it is not provided the first Xsuaa binding from a list is used and treated as instance with `application` plan.
 
 Detailed information on how to use ``spring-security`` library in Kubernetes/Kyma environment can be found in [spring-security-hybrid-usage](/samples/spring-security-hybrid-usage/README.md#deployment-on-kymakubernetes) sample README.
 
diff --git a/spring-xsuaa/README.md b/spring-xsuaa/README.md
index 3bb9d47e..bcf0dc0a 100644
--- a/spring-xsuaa/README.md
+++ b/spring-xsuaa/README.md
@@ -11,9 +11,6 @@ To access service instance configurations from the application, Kubernetes secre
 Library will look up the configuration files in the following paths:
 - XSUAA: `/etc/secrets/sapbtp/xsuaa/<YOUR XSUAA INSTANCE NAME>`
 - IAS: `/etc/secrets/sapbtp/identity/<YOUR IAS INSTANCE NAME>`
-- Service-manager: `/etc/secrets/sapbtp/service-manager/<YOUR SERVICE-MANAGER NAME>`
-
-:exclamation: service-manager binding is mandatory to resolve multiple Xsuaa bindings! If it is not provided the first Xsuaa binding from a list is used and treated as instance with `application` plan.
 
 Detailed information on how to use ``spring-xsuaa`` library in Kubernetes/Kyma environment can be found in [spring-security-basic-auth](/samples/spring-security-basic-auth/README.md#deployment-on-kymakubernetes) sample README.
 


Test patch:
diff --git a/env/src/test/java/com/sap/cloud/security/config/EnvironmentsK8sTest.java b/env/src/test/java/com/sap/cloud/security/config/EnvironmentsK8sTest.java
index 3960462c..5688a757 100644
--- a/env/src/test/java/com/sap/cloud/security/config/EnvironmentsK8sTest.java
+++ b/env/src/test/java/com/sap/cloud/security/config/EnvironmentsK8sTest.java
@@ -5,12 +5,19 @@
  */
 package com.sap.cloud.security.config;
 
+import com.sap.cloud.environment.servicebinding.api.DefaultServiceBindingAccessor;
+import com.sap.cloud.environment.servicebinding.SapServiceOperatorLayeredServiceBindingAccessor;
 import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
 import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
 
+import java.nio.file.Paths;
+
+import static com.sap.cloud.environment.servicebinding.SapServiceOperatorLayeredServiceBindingAccessor.DEFAULT_PARSING_STRATEGIES;
 import static com.sap.cloud.security.config.k8s.K8sConstants.KUBERNETES_SERVICE_HOST;
 
 @ExtendWith(SystemStubsExtension.class)
@@ -18,10 +25,20 @@ class EnvironmentsK8sTest {
 
 	private static final String K8S_HOST_VALUE = "0.0.0.0";
 
-	@Test
-	void getCurrent_returnsOnlySingleK8sInstance(EnvironmentVariables environmentVariables) {
+	@BeforeAll
+	static void beforeAll(EnvironmentVariables environmentVariables) {
 		environmentVariables.set(KUBERNETES_SERVICE_HOST, K8S_HOST_VALUE);
+		DefaultServiceBindingAccessor.setInstance(new SapServiceOperatorLayeredServiceBindingAccessor(
+				Paths.get(EnvironmentsK8sTest.class.getResource("/k8s").getPath()), DEFAULT_PARSING_STRATEGIES));
+	}
 
+	@AfterAll
+	static void afterAll() {
+		DefaultServiceBindingAccessor.setInstance(null);
+	}
+
+	@Test
+	void getCurrent_returnsOnlySingleK8sInstance() {
 		Environment firstEnvironment = Environments.getCurrent();
 		Environment secondEnvironment = Environments.getCurrent();
 
@@ -30,8 +47,7 @@ class EnvironmentsK8sTest {
 	}
 
 	@Test
-	void getCurrent_returnsK8s(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(KUBERNETES_SERVICE_HOST, K8S_HOST_VALUE);
+	void getCurrent_returnsK8s() {
 		Environment cut = Environments.getCurrent();
 		Assertions.assertThat(cut.getType()).isEqualTo(Environment.Type.KUBERNETES);
 	}
diff --git a/env/src/test/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilderTest.java b/env/src/test/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilderTest.java
index 881adb07..8a7d2f42 100644
--- a/env/src/test/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilderTest.java
+++ b/env/src/test/java/com/sap/cloud/security/config/OAuth2ServiceConfigurationBuilderTest.java
@@ -5,7 +5,6 @@
  */
 package com.sap.cloud.security.config;
 
-import com.sap.cloud.security.xsuaa.client.XsuaaDefaultEndpoints;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -221,8 +220,5 @@ public class OAuth2ServiceConfigurationBuilderTest {
 		assertThat(configuration.getUrl()).isNull();
 		assertThat(configuration.getCertUrl()).isEqualTo(URI.create(url));
 		assertThat(configuration.getCredentialType()).isEqualTo(CredentialType.X509);
-
-		XsuaaDefaultEndpoints endpoints = new XsuaaDefaultEndpoints(configuration);
-		assertThat(endpoints.getAuthorizeEndpoint().toString()).isEqualTo("http://the.cert.Url.org/oauth/authorize");
 	}
 }
\ No newline at end of file
diff --git a/env/src/test/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerServiceTest.java b/env/src/test/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerServiceTest.java
deleted file mode 100644
index fe202dfd..00000000
--- a/env/src/test/java/com/sap/cloud/security/config/k8s/DefaultServiceManagerServiceTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-class DefaultServiceManagerServiceTest {
-	static DefaultServiceManagerService cut;
-
-	@BeforeAll
-	static void beforeAll() {
-		Map<String, String> serviceInstanceMap = new HashMap<>();
-		serviceInstanceMap.put("xsuaa-application", "037e7df6-5843-4174-9cb4-69a1f9a4da7e");
-		serviceInstanceMap.put("xsuaa-broker", "bb769fcb-c8b9-4612-beac-18be9743a3b7");
-
-		Map<String, String> servicePlanMap = new HashMap<>();
-		servicePlanMap.put("bb769fcb-c8b9-4612-beac-18be9743a3b7", "broker");
-		servicePlanMap.put("037e7df6-5843-4174-9cb4-69a1f9a4da7e", "application");
-		servicePlanMap.put("12345678-1234-1234-abcd-123456789123", "another-plan");
-
-		cut = mock(DefaultServiceManagerService.class);
-		when(cut.getServicePlans()).thenReturn(servicePlanMap);
-		when(cut.getServiceInstances()).thenReturn(serviceInstanceMap);
-		when(cut.getServiceInstancePlans()).thenCallRealMethod();
-	}
-
-	@Test
-	void getServiceInstancePlans() {
-		Map<String, String> instancePlans = cut.getServiceInstancePlans();
-		assertEquals(2, instancePlans.size());
-		assertEquals("application", instancePlans.get("xsuaa-application"));
-		assertEquals("broker", instancePlans.get("xsuaa-broker"));
-	}
-
-}
\ No newline at end of file
diff --git a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sEnvironmentTest.java b/env/src/test/java/com/sap/cloud/security/config/k8s/K8sEnvironmentTest.java
index 2dd59c51..7c49c812 100644
--- a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sEnvironmentTest.java
+++ b/env/src/test/java/com/sap/cloud/security/config/k8s/K8sEnvironmentTest.java
@@ -5,87 +5,52 @@
  */
 package com.sap.cloud.security.config.k8s;
 
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import com.sap.cloud.environment.servicebinding.SapServiceOperatorLayeredServiceBindingAccessor;
+import com.sap.cloud.environment.servicebinding.api.DefaultServiceBindingAccessor;
+import com.sap.cloud.environment.servicebinding.api.ServiceBinding;
+import com.sap.cloud.environment.servicebinding.api.ServiceBindingAccessor;
 import com.sap.cloud.security.config.Environment;
 import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import org.apache.commons.io.IOUtils;
+import com.sap.cloud.security.config.cf.CFConstants;
 import org.junit.jupiter.api.*;
-import org.junit.jupiter.api.extension.ExtendWith;
-import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
-import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
+import org.mockito.Mockito;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
+import java.nio.file.Paths;
+import java.util.*;
 
-import static com.sap.cloud.security.config.k8s.K8sConstants.*;
+import static com.sap.cloud.environment.servicebinding.SapServiceOperatorLayeredServiceBindingAccessor.DEFAULT_PARSING_STRATEGIES;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
-@ExtendWith(SystemStubsExtension.class)
 class K8sEnvironmentTest {
 
-	private static final String K8S_HOST_VALUE = "0.0.0.0";
-	private static final WireMockServer WIREMOCK_SERVER = new WireMockServer(
-			WireMockConfiguration.wireMockConfig().port(1111));
 	private static Environment cut;
-	static String token;
-	static String serviceInstances;
-	static String servicePlans;
 
-	@BeforeAll
-	static void beforeAll(EnvironmentVariables environmentVariables) throws IOException {
-		environmentVariables.set(KUBERNETES_SERVICE_HOST, K8S_HOST_VALUE);
-		String absolutePath = new File("src/test/resources").getAbsolutePath();
-
-		environmentVariables.set(XSUAA_CONFIG_PATH, absolutePath + "/k8s/xsuaa");
-		environmentVariables.set(IAS_CONFIG_PATH, absolutePath + "/k8s/identity");
-		environmentVariables.set(SM_CONFIG_PATH, absolutePath + "/k8s/service-manager");
-
-		token = IOUtils.resourceToString("/xsuaaCCAccessTokenRSA256.txt", StandardCharsets.UTF_8);
-		serviceInstances = IOUtils.resourceToString("/k8s/serviceInstances.json", StandardCharsets.UTF_8);
-		servicePlans = IOUtils.resourceToString("/k8s/servicePlans.json", StandardCharsets.UTF_8);
-
-		WIREMOCK_SERVER.start();
+	@BeforeEach
+	void beforeEach() {
+		DefaultServiceBindingAccessor.setInstance(new SapServiceOperatorLayeredServiceBindingAccessor(
+				Paths.get(K8sEnvironmentTest.class.getResource("/k8s").getPath()), DEFAULT_PARSING_STRATEGIES));
 	}
 
 	@AfterEach
-	void tearDown() {
-		WIREMOCK_SERVER.resetAll();
-	}
-
-	@AfterAll
-	static void afterAll(EnvironmentVariables environmentVariables) throws Exception {
-		environmentVariables.teardown();
-		WIREMOCK_SERVER.stop();
+	void afterEach() {
+		K8sEnvironment.instance = null;
+		DefaultServiceBindingAccessor.setInstance(null);
 	}
 
 	@Test
 	void getXsuaaConfiguration() {
-		WIREMOCK_SERVER.stubFor(
-				WireMock.post("/oauth/token").willReturn(WireMock.ok().withHeader("Content-Type", "application/json")
-						.withBody("{\"access_token\": \"" + token + "\",  \"expires_in\": 1799}")));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(servicePlans)));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(serviceInstances)));
-
 		cut = K8sEnvironment.getInstance();
 		OAuth2ServiceConfiguration config = cut.getXsuaaConfiguration();
 		assertEquals("xsuaaClientId", config.getClientId());
+		assertEquals("uaadomain.org", config.getProperty(CFConstants.XSUAA.UAA_DOMAIN));
+		assertEquals("xsuaa-basic", config.getProperty(CFConstants.XSUAA.APP_ID));
+		assertEquals("xsuaaSecret", config.getClientSecret());
+		assertEquals("https://auth.sap.com", config.getUrl().toString());
 	}
 
 	@Test
 	void getIasConfiguration() {
-		WIREMOCK_SERVER.stubFor(
-				WireMock.post("/oauth/token").willReturn(WireMock.ok().withHeader("Content-Type", "application/json")
-						.withBody("{\"access_token\": \"" + token + "\",  \"expires_in\": 1799}")));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(servicePlans)));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(serviceInstances)));
-
 		cut = K8sEnvironment.getInstance();
 		OAuth2ServiceConfiguration config = cut.getIasConfiguration();
 		assertEquals("iasClientId2", config.getClientId());
@@ -96,72 +61,57 @@ class K8sEnvironmentTest {
 
 	@Test
 	void getNumberOfXsuaaConfigurations() {
-		WIREMOCK_SERVER.stubFor(
-				WireMock.post("/oauth/token").willReturn(WireMock.ok().withHeader("Content-Type", "application/json")
-						.withBody("{\"access_token\": \"" + token + "\",  \"expires_in\": 1799}")));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(servicePlans)));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(serviceInstances)));
-
 		cut = K8sEnvironment.getInstance();
 		assertEquals(2, cut.getNumberOfXsuaaConfigurations());
 	}
 
 	@Test
 	void getXsuaaConfigurationForTokenExchange() {
-		WIREMOCK_SERVER.stubFor(
-				WireMock.post("/oauth/token").willReturn(WireMock.ok().withHeader("Content-Type", "application/json")
-						.withBody("{\"access_token\": \"" + token + "\",  \"expires_in\": 1799}")));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(servicePlans)));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(serviceInstances)));
-
 		cut = K8sEnvironment.getInstance();
 		OAuth2ServiceConfiguration config = cut.getXsuaaConfigurationForTokenExchange();
 		assertEquals("xsuaaBrokerClientId", config.getClientId());
+		assertEquals("uaadomain.org", config.getProperty(CFConstants.XSUAA.UAA_DOMAIN));
+		assertEquals("xsuaa-broker", config.getProperty(CFConstants.XSUAA.APP_ID));
 	}
 
-	@Disabled("Doesn't work with Surefire plugin, can be tested in IDE with test config forkMode=method")
 	@Test
-	void getXsuaaConfiguration_smCallFails() {
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.unauthorized()));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.unauthorized()));
+	void getNoConfigIfNoServiceNameIsGiven() {
+		ServiceBindingAccessor accessor = Mockito.mock(ServiceBindingAccessor.class);
+		ServiceBinding binding = Mockito.mock(ServiceBinding.class);
+		Mockito.when(binding.getServiceName()).thenReturn(Optional.empty());
+		Mockito.when(accessor.getServiceBindings()).thenReturn(Collections.singletonList(binding));
+		DefaultServiceBindingAccessor.setInstance(accessor);
 
 		cut = K8sEnvironment.getInstance();
-		OAuth2ServiceConfiguration config = cut.getXsuaaConfiguration();
-		assertEquals("xsuaaClientId", config.getClientId());
-		assertEquals(1, cut.getNumberOfXsuaaConfigurations());
+		assertEquals(0, cut.getNumberOfXsuaaConfigurations());
+		assertNull(cut.getIasConfiguration());
+		assertNull(cut.getXsuaaConfiguration());
 	}
 
-	@Disabled("Doesn't work with Surefire plugin, can be tested in IDE with test config forkMode=method")
 	@Test
-	void getXsuaaConfiguration_smCallFails_noServiceInstances() {
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.badRequest()));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(servicePlans)));
+	void getNoConfigIfNoServicesAreGiven() {
+		ServiceBindingAccessor accessor = Mockito.mock(ServiceBindingAccessor.class);
+		Mockito.when(accessor.getServiceBindings()).thenReturn(Collections.emptyList());
+		DefaultServiceBindingAccessor.setInstance(accessor);
 
 		cut = K8sEnvironment.getInstance();
-		OAuth2ServiceConfiguration config = cut.getXsuaaConfiguration();
-		assertEquals("xsuaaClientId", config.getClientId());
-		assertEquals(1, cut.getNumberOfXsuaaConfigurations());
+		assertEquals(0, cut.getNumberOfXsuaaConfigurations());
+		assertNull(cut.getIasConfiguration());
+		assertNull(cut.getXsuaaConfiguration());
 	}
 
-	@Disabled("Doesn't work with Surefire plugin, can be tested in IDE with test config forkMode=method")
 	@Test
-	void getXsuaaConfiguration_smCallFails_noServicePlans() {
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_plans")
-				.willReturn(WireMock.badRequest()));
-		WIREMOCK_SERVER.stubFor(WireMock.get("/v1/service_instances")
-				.willReturn(WireMock.ok().withHeader("Content-Type", "application/json").withBody(serviceInstances)));
+	void getNoConfigIfNoServicePlanIsGiven() {
+		ServiceBindingAccessor accessor = Mockito.mock(ServiceBindingAccessor.class);
+		ServiceBinding binding = Mockito.mock(ServiceBinding.class);
+		Mockito.when(binding.getServicePlan()).thenReturn(Optional.empty());
+		Mockito.when(accessor.getServiceBindings()).thenReturn(Collections.singletonList(binding));
+		DefaultServiceBindingAccessor.setInstance(accessor);
 
 		cut = K8sEnvironment.getInstance();
-		OAuth2ServiceConfiguration config = cut.getXsuaaConfiguration();
-		assertEquals("xsuaaClientId", config.getClientId());
-		assertEquals(1, cut.getNumberOfXsuaaConfigurations());
+		assertEquals(0, cut.getNumberOfXsuaaConfigurations());
+		assertNull(cut.getIasConfiguration());
+		assertNull(cut.getXsuaaConfiguration());
 	}
+
 }
\ No newline at end of file
diff --git a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProviderTest.java b/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProviderTest.java
deleted file mode 100644
index 07965016..00000000
--- a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationProviderTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import com.sap.cloud.security.config.Service;
-import nl.altindag.log.LogCaptor;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mockito;
-import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
-import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.sap.cloud.security.config.k8s.K8sConstants.*;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(SystemStubsExtension.class)
-class K8sServiceConfigurationProviderTest {
-
-	private static final String ABSOLUTE_PATH = new File("src/test/resources").getAbsolutePath();
-	private static K8sServiceConfigurationProvider cut;
-	private static DefaultServiceManagerService smMock;
-	private static LogCaptor logCaptor;
-
-	@BeforeAll
-	static void beforeAll() {
-		logCaptor = LogCaptor.forClass(K8sServiceConfigurationProvider.class);
-	}
-
-	@AfterEach
-	void tearDown() {
-		logCaptor.clearLogs();
-	}
-
-	@BeforeEach
-	void beforeEach(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa");
-		environmentVariables.set(IAS_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/identity");
-		environmentVariables.set(SM_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/service-manager");
-		Map<String, String> serviceInstancePlanMap = new HashMap<>();
-		serviceInstancePlanMap.put("xsuaa-application", "application");
-		serviceInstancePlanMap.put("xsuaa-broker", "broker");
-
-		smMock = Mockito.mock(DefaultServiceManagerService.class);
-		when(smMock.getServiceInstancePlans()).thenReturn(serviceInstancePlanMap);
-
-		cut = new K8sServiceConfigurationProvider();
-		cut.setServiceManagerClient(smMock);
-	}
-
-	@Test
-	void getServiceConfigurations() {
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfig = cut
-				.getServiceConfigurations();
-		assertThat(serviceConfig).hasSize(2);
-		assertThat(serviceConfig.get(Service.XSUAA)).hasSize(2);
-		assertThat(serviceConfig.get(Service.IAS)).hasSize(2);
-		assertThat(serviceConfig.get(Service.XSUAA).get(Plan.APPLICATION.toString())).isNotNull();
-		assertThat(serviceConfig.get(Service.XSUAA).get(Plan.BROKER.toString())).isNotNull();
-		assertThat(serviceConfig.get(Service.XSUAA).get(Plan.DEFAULT.toString())).isNull();
-	}
-
-	@Test
-	void getServiceConfigurations_noXsuaaPlansAvailable() {
-		when(smMock.getServiceInstancePlans()).thenReturn(Collections.emptyMap());
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfig = cut
-				.getServiceConfigurations();
-
-		assertThat(serviceConfig.get(Service.XSUAA)).isNotNull();
-		assertThat(serviceConfig.get(Service.XSUAA)).hasSize(1);
-		assertThat(serviceConfig.get(Service.XSUAA).get(Plan.APPLICATION.toString())).isNotNull();
-		assertThat(logCaptor.getWarnLogs().get(0))
-				.startsWith("No plans or instances were fetched from service manager");
-	}
-
-	@Test
-	void getServiceConfigurations_noSmClient() {
-		cut.setServiceManagerClient(null);
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfig = cut.getServiceConfigurations();
-
-		assertThat(serviceConfig.get(Service.XSUAA)).isNotNull();
-		assertThat(serviceConfig.get(Service.XSUAA)).hasSize(1);
-		assertThat(serviceConfig.get(Service.XSUAA).get(Plan.APPLICATION.toString())).isNotNull();
-		assertThat(logCaptor.getWarnLogs().get(0)).startsWith("No service-manager client available");
-	}
-
-	@Test
-	void getServiceConfigurations_noServiceBindingsAvailable(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/no/binding");
-		environmentVariables.set(IAS_CONFIG_PATH, ABSOLUTE_PATH + "/no/binding");
-		environmentVariables.set(SM_CONFIG_PATH, ABSOLUTE_PATH + "/no/binding");
-
-		cut = new K8sServiceConfigurationProvider();
-
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfig = cut.getServiceConfigurations();
-		assertThat(serviceConfig).hasSize(2);
-		assertThat(serviceConfig.get(Service.XSUAA)).isEmpty();
-		assertThat(serviceConfig.get(Service.IAS)).isEmpty();
-	}
-
-	@Test
-	void getServiceConfiguration_singleXsuaa(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa-single");
-
-		cut = new K8sServiceConfigurationProvider();
-		EnumMap<Service, Map<String, OAuth2ServiceConfiguration>> serviceConfig = cut.getServiceConfigurations();
-		assertThat(serviceConfig.get(Service.XSUAA)).hasSize(1);
-		assertThat(logCaptor.getInfoLogs().get(0)).startsWith("Assigning 'application' plan");
-		assertThat(logCaptor.getWarnLogs()).isEmpty();
-	}
-}
\ No newline at end of file
diff --git a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolverTest.java b/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolverTest.java
deleted file mode 100644
index fc173972..00000000
--- a/env/src/test/java/com/sap/cloud/security/config/k8s/K8sServiceConfigurationResolverTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2018-2021 SAP SE or an SAP affiliate company and Cloud Security Client Java contributors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.sap.cloud.security.config.k8s;
-
-import com.sap.cloud.security.config.OAuth2ServiceConfiguration;
-import com.sap.cloud.security.config.Service;
-import nl.altindag.log.LogCaptor;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
-import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
-
-import java.io.File;
-import java.util.Map;
-
-import static com.sap.cloud.security.config.k8s.K8sConstants.*;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.*;
-
-@ExtendWith(SystemStubsExtension.class)
-class K8sServiceConfigurationResolverTest {
-
-	private static K8sServiceConfigurationResolver cut;
-	public static final String ABSOLUTE_PATH = new File("src/test/resources").getAbsolutePath();
-	private static LogCaptor logCaptor;
-
-	@BeforeAll
-	static void beforeAll() {
-		logCaptor = LogCaptor.forClass(K8sServiceConfigurationResolver.class);
-	}
-
-	@AfterEach
-	void tearDown() {
-		logCaptor.clearLogs();
-	}
-
-	@Test
-	void loadServiceManagerConfig(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(SM_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/service-manager");
-		cut = new K8sServiceConfigurationResolver();
-
-		assertEquals("smClientId", cut.loadServiceManagerConfig().getClientId());
-	}
-
-	@Test
-	void loadOauth2ServiceConfig(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa");
-		environmentVariables.set(IAS_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/identity");
-		cut = new K8sServiceConfigurationResolver();
-
-		assertEquals(2, cut.loadOauth2ServiceConfig(Service.XSUAA).size());
-		assertEquals(2, cut.loadOauth2ServiceConfig(Service.IAS).size());
-		assertEquals("xsuaaClientId",
-				cut.loadOauth2ServiceConfig(Service.XSUAA).get("xsuaa-application").getClientId());
-		assertEquals("xsuaaBrokerClientId",
-				cut.loadOauth2ServiceConfig(Service.XSUAA).get("xsuaa-broker").getClientId());
-		assertEquals("iasClientId", cut.loadOauth2ServiceConfig(Service.IAS).get("ias1").getClientId());
-		assertEquals("iasClientId2", cut.loadOauth2ServiceConfig(Service.IAS).get("ias2").getClientId());
-	}
-
-	@Test
-	void loadOAuth2ServiceConfig_noValidXsuaaServiceBinding(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa-invalid");
-		cut = new K8sServiceConfigurationResolver();
-		Map<String, OAuth2ServiceConfiguration> xsuaaConfig = cut.loadOauth2ServiceConfig(Service.XSUAA);
-
-		assertEquals(1, xsuaaConfig.size());
-		assertThat(logCaptor.getInfoLogs()).contains("Found 3 XSUAA service binding/s");
-		assertEquals("clientId", xsuaaConfig.get("xsuaa-folder-file").getClientId());
-		assertNull(xsuaaConfig.get("xsuaa-folder-file").getClientSecret());
-		assertThat(logCaptor.getWarnLogs()).contains("clientid value is empty");
-		assertDoesNotThrow(() -> cut.loadOauth2ServiceConfig(Service.XSUAA));
-	}
-
-	@Test
-	void loadOAuth2ServiceConfig_noIasServiceBinding(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(IAS_CONFIG_PATH, "/no/path");
-		cut = new K8sServiceConfigurationResolver();
-		Map<String, OAuth2ServiceConfiguration> iasConfig = cut.loadOauth2ServiceConfig(Service.IAS);
-
-		assertEquals(0, iasConfig.size());
-		assertThat(logCaptor.getWarnLogs()).contains("No service bindings for IAS service were found");
-		assertDoesNotThrow(() -> cut.loadOauth2ServiceConfig(Service.IAS));
-	}
-
-	@Test
-	void loadOAuth2ServiceConfig_noXsuaaServiceBinding(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa-no-bindings");
-		cut = new K8sServiceConfigurationResolver();
-
-		assertDoesNotThrow(() -> cut.loadOauth2ServiceConfig(Service.XSUAA));
-		assertThat(logCaptor.getWarnLogs()).contains("No service bindings for XSUAA service were found");
-		assertEquals(0, cut.loadOauth2ServiceConfig(Service.XSUAA).size());
-	}
-
-	@Test
-	void loadOAuth2ServiceConfig_singleXsuaaServiceBinding(EnvironmentVariables environmentVariables) {
-		environmentVariables.set(XSUAA_CONFIG_PATH, ABSOLUTE_PATH + "/k8s/xsuaa-single");
-		cut = new K8sServiceConfigurationResolver();
-
-		assertDoesNotThrow(() -> cut.loadOauth2ServiceConfig(Service.XSUAA));
-		assertThat(logCaptor.getInfoLogs()).contains("Found 1 XSUAA service binding/s");
-		assertEquals(1, cut.loadOauth2ServiceConfig(Service.XSUAA).size());
-	}
-}
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/identity/ias2/clientid b/env/src/test/resources/k8s/identity/ias-single/clientid
similarity index 100%
rename from env/src/test/resources/k8s/identity/ias2/clientid
rename to env/src/test/resources/k8s/identity/ias-single/clientid
diff --git a/env/src/test/resources/k8s/identity/ias2/clientsecret b/env/src/test/resources/k8s/identity/ias-single/clientsecret
similarity index 100%
rename from env/src/test/resources/k8s/identity/ias2/clientsecret
rename to env/src/test/resources/k8s/identity/ias-single/clientsecret
diff --git a/env/src/test/resources/k8s/identity/ias2/domains b/env/src/test/resources/k8s/identity/ias-single/domains
similarity index 100%
rename from env/src/test/resources/k8s/identity/ias2/domains
rename to env/src/test/resources/k8s/identity/ias-single/domains
diff --git a/env/src/test/resources/k8s/identity/ias1/clientid b/env/src/test/resources/k8s/identity/ias1/clientid
deleted file mode 100644
index ad064933..00000000
--- a/env/src/test/resources/k8s/identity/ias1/clientid
+++ /dev/null
@@ -1,1 +0,0 @@
-iasClientId
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/service-manager/sm/clientid b/env/src/test/resources/k8s/service-manager/sm/clientid
deleted file mode 100644
index 7389157a..00000000
--- a/env/src/test/resources/k8s/service-manager/sm/clientid
+++ /dev/null
@@ -1,1 +0,0 @@
-smClientId
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/service-manager/sm/clientsecret b/env/src/test/resources/k8s/service-manager/sm/clientsecret
deleted file mode 100644
index 7300d932..00000000
--- a/env/src/test/resources/k8s/service-manager/sm/clientsecret
+++ /dev/null
@@ -1,1 +0,0 @@
-smClientSecret
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/service-manager/sm/sm_url b/env/src/test/resources/k8s/service-manager/sm/sm_url
deleted file mode 100644
index c7b7e767..00000000
--- a/env/src/test/resources/k8s/service-manager/sm/sm_url
+++ /dev/null
@@ -1,1 +0,0 @@
-http://localhost:1111
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/service-manager/sm/url b/env/src/test/resources/k8s/service-manager/sm/url
deleted file mode 100644
index c7b7e767..00000000
--- a/env/src/test/resources/k8s/service-manager/sm/url
+++ /dev/null
@@ -1,1 +0,0 @@
-http://localhost:1111
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/service-manager/sm/xsappname b/env/src/test/resources/k8s/service-manager/sm/xsappname
deleted file mode 100644
index ae94e515..00000000
--- a/env/src/test/resources/k8s/service-manager/sm/xsappname
+++ /dev/null
@@ -1,1 +0,0 @@
-service-manager
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/serviceInstances.json b/env/src/test/resources/k8s/serviceInstances.json
deleted file mode 100644
index c3077cc0..00000000
--- a/env/src/test/resources/k8s/serviceInstances.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
-  "num_items": 3,
-  "items": [
-    {
-      "id": "1307a163-b5cf-4c2c-8714-13ba5f072012",
-      "ready": true,
-      "name": "xsuaa-application",
-      "service_plan_id": "037e7df6-5843-4174-9cb4-69a1f9a4da7e",
-      "platform_id": "",
-      "context": {
-        "clusterid": "",
-        "instance_name": "xsuaa-application",
-        "namespace": "dev",
-        "platform": "sapcp",
-        "zone_id": "",
-        "global_account_id": "sap",
-        "subdomain": "",
-        "crm_customer_id": "",
-        "origin": "kubernetes",
-        "license_type": "SAPDEV",
-        "subaccount_id": "",
-        "region": ""
-      },
-      "usable": true,
-      "created_at": "2021-07-14T13:58:07.067851Z",
-      "updated_at": "2021-07-14T13:58:07.067851Z",
-      "labels": {
-        "subaccount_id": [
-          ""
-        ]
-      }
-    },
-    {
-      "id": "73643785-56da-4165-b6b3-d13cc571be7f",
-      "ready": true,
-      "name": "xsuaa-broker",
-      "service_plan_id": "bb769fcb-c8b9-4612-beac-18be9743a3b7",
-      "platform_id": "",
-      "context": {
-        "clusterid": "",
-        "instance_name": "xsuaa-broker",
-        "namespace": "dev",
-        "platform": "sapcp",
-        "subdomain": "",
-        "region": "",
-        "crm_customer_id": "",
-        "global_account_id": "sap",
-        "license_type": "SAPDEV",
-        "subaccount_id": "",
-        "origin": "kubernetes",
-        "zone_id": ""
-      },
-      "usable": true,
-      "created_at": "2021-07-28T12:06:34.34308Z",
-      "updated_at": "2021-07-28T12:06:34.34308Z",
-      "labels": {
-        "subaccount_id": [
-          ""
-        ]
-      }
-    },
-    {
-      "id": "d3c68611-c8a0-4c96-ac0c-1edd0ac3d2ef",
-      "ready": true,
-      "name": "service-manager",
-      "service_plan_id": "ca8adb0e-d560-41aa-bf63-12ec2af02035",
-      "platform_id": "",
-      "context": {
-        "clusterid": "",
-        "instance_name": "service-manager",
-        "namespace": "dev",
-        "platform": "sapcp",
-        "zone_id": "",
-        "crm_customer_id": "",
-        "subdomain": "",
-        "region": "",
-        "origin": "kubernetes",
-        "global_account_id": "sap",
-        "license_type": "SAPDEV",
-        "subaccount_id": ""
-      },
-      "usable": true,
-      "created_at": "2021-07-28T15:19:20.17765Z",
-      "updated_at": "2021-07-28T15:19:20.17765Z",
-      "labels": {
-        "subaccount_id": [
-          ""
-        ]
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/servicePlans.json b/env/src/test/resources/k8s/servicePlans.json
deleted file mode 100644
index a1b23f2b..00000000
--- a/env/src/test/resources/k8s/servicePlans.json
+++ /dev/null
@@ -1,120 +0,0 @@
-{
-  "num_items": 3,
-  "items": [
-    {
-      "id": "037e7df6-5843-4174-9cb4-69a1f9a4da7e",
-      "ready": true,
-      "name": "application",
-      "description": "Application plan to be used for business applications",
-      "catalog_id": "ThGdx5loQ6XhvcdY6dLlEXcTgQD7641pDKXJfzwYGLg=",
-      "catalog_name": "application",
-      "free": true,
-      "bindable": true,
-      "metadata": {
-        "supportedPlatforms": [
-          "cloudfoundry",
-          "sapcp",
-          "kubernetes"
-        ],
-        "supportedMinOSBVersion": "2.11",
-        "sibling_resolution": {
-          "resolution_property": "siblingIds",
-          "name_paths": [
-            "scopes.#.granted-apps",
-            "scopes.#.grant-as-authority-to-apps",
-            "foreign-scope-references",
-            "authorities",
-            "role-collections.#.role-template-references"
-          ],
-          "value_regexp": "\\$XSSERVICENAME\\((.*)\\)",
-          "enabled": true
-        },
-        "bullets": [
-          "Tenant isolation",
-          "Supports different OAuth flows (Client credentials, authorization code, SAML bearer assertion)",
-          "One OAuth client per service instance"
-        ],
-        "supportedMaxOSBVersion": "2.14"
-      },
-      "service_offering_id": "a3199d59-3fdc-41f5-a258-8ea36ff26762",
-      "created_at": "2019-06-26T13:51:49.854908Z",
-      "updated_at": "2021-08-02T09:32:35.244776Z",
-      "labels": {
-        "complementary": [
-          "true"
-        ]
-      }
-    },
-    {
-      "id": "bb769fcb-c8b9-4612-beac-18be9743a3b7",
-      "ready": true,
-      "name": "broker",
-      "description": "Broker plan to be used by business reuse services / service brokers",
-      "catalog_id": "HWEgt9/jJGFjzT8j+/x9pGivrAuKbUMUK8PgWEx3cLY=",
-      "catalog_name": "broker",
-      "free": true,
-      "bindable": true,
-      "metadata": {
-        "supportedPlatforms": [
-          "cloudfoundry",
-          "sapcp",
-          "kubernetes"
-        ],
-        "supportedMinOSBVersion": "2.11",
-        "sibling_resolution": {
-          "resolution_property": "siblingIds",
-          "name_paths": [
-            "scopes.#.granted-apps",
-            "scopes.#.grant-as-authority-to-apps",
-            "foreign-scope-references",
-            "authorities",
-            "role-collections.#.role-template-references"
-          ],
-          "value_regexp": "\\$XSSERVICENAME\\((.*)\\)",
-          "enabled": true
-        },
-        "bullets": [
-          "Tenant isolation",
-          "Supports different OAuth flows (Client credentials, user token)",
-          "One OAuth client for the reuse service itself + one per instance of the reuse service"
-        ],
-        "supportedMaxOSBVersion": "2.14"
-      },
-      "service_offering_id": "a3199d59-3fdc-41f5-a258-8ea36ff26762",
-      "created_at": "2019-06-26T13:51:49.854908Z",
-      "updated_at": "2021-08-02T09:32:35.190203Z",
-      "labels": {
-        "complementary": [
-          "true"
-        ]
-      }
-    },
-    {
-      "id": "b0fd827c-2391-4619-bfb8-56b8b1dc197b",
-      "ready": true,
-      "name": "application",
-      "description": "Register an application into your Identity Authentication tenant",
-      "catalog_id": "86af6685-7bae-40b8-b564-378284c8fcc9",
-      "catalog_name": "application",
-      "free": true,
-      "bindable": true,
-      "metadata": {
-        "sibling_resolution": {
-          "names_path": "consumed-services.#.service-instance-name",
-          "resolution_property": "siblingIds",
-          "enabled": true
-        },
-        "supportedMinOSBVersion": "2.11",
-        "supportedMaxOSBVersion": "2.15"
-      },
-      "service_offering_id": "b518cc1f-8523-4331-b7a1-d6f196854b05",
-      "created_at": "2020-10-28T11:53:29.219855Z",
-      "updated_at": "2021-08-02T09:25:26.195847Z",
-      "labels": {
-        "commercial_name": [
-          "application"
-        ]
-      }
-    }
-  ]
-}
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-invalid/fileInsteadOfFolder b/env/src/test/resources/k8s/xsuaa-invalid/fileInsteadOfFolder
deleted file mode 100644
index e69de29b..00000000
diff --git a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-folder-file/clientid b/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-folder-file/clientid
deleted file mode 100644
index 9b640fd5..00000000
--- a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-folder-file/clientid
+++ /dev/null
@@ -1,1 +0,0 @@
-clientId
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-no-file-content/clientid b/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-no-file-content/clientid
deleted file mode 100644
index e69de29b..00000000
diff --git a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-no-file-content/xsappname b/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-no-file-content/xsappname
deleted file mode 100644
index e69de29b..00000000
diff --git a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-wrong-tree-structure/clientid/clientid b/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-wrong-tree-structure/clientid/clientid
deleted file mode 100644
index 7a9df4f6..00000000
--- a/env/src/test/resources/k8s/xsuaa-invalid/xsuaa-wrong-tree-structure/clientid/clientid
+++ /dev/null
@@ -1,1 +0,0 @@
-myClientId
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientid b/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientid
deleted file mode 100644
index 1e9e7e0a..00000000
--- a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientid
+++ /dev/null
@@ -1,1 +0,0 @@
-xsuaaClientId
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientsecret b/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientsecret
deleted file mode 100644
index 6430bd24..00000000
--- a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/clientsecret
+++ /dev/null
@@ -1,1 +0,0 @@
-xsuaaSecret
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/url b/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/url
deleted file mode 100644
index d064b73f..00000000
--- a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/url
+++ /dev/null
@@ -1,1 +0,0 @@
-https://auth.sap.com
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/xsappname b/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/xsappname
deleted file mode 100644
index 1e73b8cc..00000000
--- a/env/src/test/resources/k8s/xsuaa-single/xsuaa-application/xsappname
+++ /dev/null
@@ -1,1 +0,0 @@
-xsuaa-basic
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa/xsuaa-application/plan b/env/src/test/resources/k8s/xsuaa/xsuaa-application/plan
new file mode 100644
index 00000000..e1993483
--- /dev/null
+++ b/env/src/test/resources/k8s/xsuaa/xsuaa-application/plan
@@ -0,0 +1,1 @@
+application
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa/xsuaa-application/uaadomain b/env/src/test/resources/k8s/xsuaa/xsuaa-application/uaadomain
new file mode 100644
index 00000000..a2a6594c
--- /dev/null
+++ b/env/src/test/resources/k8s/xsuaa/xsuaa-application/uaadomain
@@ -0,0 +1,1 @@
+uaadomain.org
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa/xsuaa-broker/plan b/env/src/test/resources/k8s/xsuaa/xsuaa-broker/plan
new file mode 100644
index 00000000..641bf493
--- /dev/null
+++ b/env/src/test/resources/k8s/xsuaa/xsuaa-broker/plan
@@ -0,0 +1,1 @@
+broker
\ No newline at end of file
diff --git a/env/src/test/resources/k8s/xsuaa/xsuaa-broker/uaadomain b/env/src/test/resources/k8s/xsuaa/xsuaa-broker/uaadomain
new file mode 100644
index 00000000..a2a6594c
--- /dev/null
+++ b/env/src/test/resources/k8s/xsuaa/xsuaa-broker/uaadomain
@@ -0,0 +1,1 @@
+uaadomain.org
\ No newline at end of file
diff --git a/env/src/test/resources/simplelogger.properties b/env/src/test/resources/simplelogger.properties
new file mode 100644
index 00000000..c20bc008
--- /dev/null
+++ b/env/src/test/resources/simplelogger.properties
@@ -0,0 +1,2 @@
+org.slf4j.simpleLogger.defaultLogLevel: WARN
+org.slf4j.simpleLogger.log.com.sap.cloud.environment.servicebinding: DEBUG
\ No newline at end of file