text: Q:
  
  How to authenticate when using cloudfoundry apis in a spring boot app
  
  I want to use cloudfoundry apis (https://apidocs.cloudfoundry.org/272/) in a simple spring boot app. 
  I'm following a documentation for implmenting a java client for it. (https://docs.cloudfoundry.org/buildpacks/java/java-client.html) 
  My pom.xml -> 
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <!-- https://mvnrepository.com/artifact/org.cloudfoundry/cloudfoundry-client-lib -->
  <dependency>
      <groupId>org.cloudfoundry</groupId>
      <artifactId>cloudfoundry-client-lib</artifactId>
      <version>1.1.4.RELEASE</version>
  </dependency>
  <dependency>
      <groupId>org.cloudfoundry</groupId>
      <artifactId>cloudfoundry-client-reactor</artifactId>
      <version>2.20.0.RELEASE</version>
  </dependency>
  <dependency>
      <groupId>org.cloudfoundry</groupId>
      <artifactId>cloudfoundry-operations</artifactId>
      <version>2.20.0.RELEASE</version>
  </dependency>
  <dependency>
      <groupId>io.projectreactor</groupId>
      <artifactId>reactor-core</artifactId>
      <version>3.1.0.RELEASE</version>
  </dependency>
  <dependency>
      <groupId>io.projectreactor.ipc</groupId>
      <artifactId>reactor-netty</artifactId>
      <version>0.7.0.RELEASE</version>
  </dependency>
  
  The Controller and Application file is exactly the same as mentioned in the sample simple spring boot startup kit. (https://spring.io/guides/gs/spring-boot/). 
  When using a standalone class (as mentioned in the cloudfoundry docs) it works,  but when using the same code in a spring boot app, it gives me - 
  {
      "timestamp": 1510245582167,
      "status": 401,
      "error": "Unauthorized",
      "message": "Full authentication is required to access this resource",
      "path": "/hello"
  }
  
  I noticed in the logs that when I have the cloudfoundry-client-lib dependency added, A filter chain is formed..  
  2017-11-09 11:34:38.086  INFO 8648 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], 
  [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@288ca5f0, 
  org.springframework.security.web.context.SecurityContextPersistenceFilter@2ba5aa7a, org.springframework.security.web.header.HeaderWriterFilter@4207609e, 
  org.springframework.security.web.authentication.logout.LogoutFilter@2c7a8af2,
  org.springframework.security.web.authentication.www.BasicAuthenticationFilter@21c815e4, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@22e5f96e,
  org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5b22d8a1, 
  org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4068102e, 
  org.springframework.security.web.session.SessionManagementFilter@67b100fe, 
  org.springframework.security.web.access.ExceptionTranslationFilter@704641e3,
  org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7efd28bd]
  
  How to deal with the authentication when using cloudfoundry lib or how to deal with bypassing the filter chain security? 
  
  A:
  
  Solution: CF Java Client v2 has a different API from v1, so you won't find CloudCredentials in v2. See the v2 README for examples of constructing a new client and providing credentials: https://github.com/cloudfoundry/cf-java-client#cloudfoundryclient-dopplerclient-uaaclient-builders Again, use only the v2 libraries and don't use any v1 libraries in the same app.
  
  I'm not sure exactly where that error is coming from, but you are mixing different major versions of the CF Java client in the same app. That's not likely to work very well. Refer to the project page for the CF Java Client and use only 2.x.x versions of all the org.cloudfoundry dependencies. All of the org.cloudfoundry dependencies should also be on the same versions.
  So replace:
  <dependency>
          <groupId>org.cloudfoundry</groupId>
          <artifactId>cloudfoundry-client-lib</artifactId>
          <version>1.1.1</version>
      </dependency>
      <dependency>
          <groupId>org.cloudfoundry</groupId>
          <artifactId>cloudfoundry-client-reactor</artifactId>
          <version>2.0.1.RELEASE</version>
      </dependency>
      <dependency>
          <groupId>org.cloudfoundry</groupId>
          <artifactId>cloudfoundry-operations</artifactId>
          <version>2.20.0.RELEASE</version>
      </dependency>
  
  with 
      <dependency>
          <groupId>org.cloudfoundry</groupId>
          <artifactId>cloudfoundry-client-reactor</artifactId>
          <version>2.20.0.RELEASE</version>
      </dependency>
      <dependency>
          <groupId>org.cloudfoundry</groupId>
          <artifactId>cloudfoundry-operations</artifactId>
          <version>2.20.0.RELEASE</version>
      </dependency>
  
  