Fixed bug when checking if refresh token is set in CLI config.json
This commit is contained in:
@@ -50,18 +50,17 @@ public class CfCliParamsProvider implements ClientParamsProvider {
|
||||
if (userData != null) {
|
||||
String refreshToken = (String) userData.get(REFRESH_TOKEN);
|
||||
// Only support connecting to CF via refresh token for now
|
||||
if (refreshToken == null) {
|
||||
return null;
|
||||
}
|
||||
CFCredentials credentials = CFCredentials.fromRefreshToken(refreshToken);
|
||||
boolean sslDisabled = (Boolean) userData.get(SSL_DISABLED);
|
||||
String target = (String) userData.get(TARGET);
|
||||
Map<String, Object> orgFields = (Map<String, Object>) userData.get(ORGANIZATION_FIELDS);
|
||||
Map<String, Object> spaceFields = (Map<String, Object>) userData.get(SPACE_FIELDS);
|
||||
if (target != null && orgFields != null && spaceFields != null) {
|
||||
String orgName = (String) orgFields.get(NAME);
|
||||
String spaceName = (String) spaceFields.get(NAME);
|
||||
params.add(new CFClientParams(target, null, credentials, orgName, spaceName, sslDisabled));
|
||||
if (isRefreshTokenSet(refreshToken)) {
|
||||
CFCredentials credentials = CFCredentials.fromRefreshToken(refreshToken);
|
||||
boolean sslDisabled = (Boolean) userData.get(SSL_DISABLED);
|
||||
String target = (String) userData.get(TARGET);
|
||||
Map<String, Object> orgFields = (Map<String, Object>) userData.get(ORGANIZATION_FIELDS);
|
||||
Map<String, Object> spaceFields = (Map<String, Object>) userData.get(SPACE_FIELDS);
|
||||
if (target != null && orgFields != null && spaceFields != null) {
|
||||
String orgName = (String) orgFields.get(NAME);
|
||||
String spaceName = (String) spaceFields.get(NAME);
|
||||
params.add(new CFClientParams(target, null, credentials, orgName, spaceName, sslDisabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +72,10 @@ public class CfCliParamsProvider implements ClientParamsProvider {
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRefreshTokenSet(String token) {
|
||||
return token != null && token.trim().length() > 0;
|
||||
}
|
||||
|
||||
private File getConfigJsonFile() throws IOException, InterruptedException {
|
||||
// Support Unix systems for now
|
||||
@@ -95,4 +98,5 @@ public class CfCliParamsProvider implements ClientParamsProvider {
|
||||
private String getUnixHomeDir() throws IOException, InterruptedException {
|
||||
return System.getProperty("user.home");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ public interface ClientParamsProvider {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return non-null list of params to connect to Cloud Foundry
|
||||
* @return non-null list of VALID params to connect to Cloud Foundry
|
||||
* @throws Exception if failure to resolve any params for Cloud Foundry
|
||||
*/
|
||||
List<CFClientParams> getParams() throws Exception;
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user