hadoop-swiftfs: Allow configuring domain.id
Some vendors only provide an id for their domains and not name. Change-Id: I0254cb4ede8b739cb5ff06f525a49064e064d288
This commit is contained in:
parent
8c288a4ae1
commit
c080e3b598
|
@ -47,14 +47,16 @@ public class PasswordCredentialsV3 {
|
|||
* @param password user password
|
||||
* @param domain_name user's domain name
|
||||
*/
|
||||
public PasswordCredentialsV3(String name, String password, String domain_name) {
|
||||
public PasswordCredentialsV3(String name, String password, String domain_name, String domain_id) {
|
||||
this.name = name;
|
||||
this.password = password;
|
||||
this.domain = new HashMap();
|
||||
if (domain_name == null) {
|
||||
this.domain.put("id", "default");
|
||||
} else {
|
||||
if (domain_id != null) {
|
||||
this.domain.put("id", domain_id);
|
||||
} else if (domain_name != null) {
|
||||
this.domain.put("name", domain_name);
|
||||
} else {
|
||||
this.domain.put("id", "default");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,7 @@ public final class RestClientBindings {
|
|||
props.contains(SWIFT_APIKEY_PROPERTY) ? true : false);
|
||||
copy(conf, prefix + DOT_TRUST_ID, props, SWIFT_TRUST_ID_PROPERTY, false);
|
||||
copy(conf, prefix + DOT_DOMAIN_NAME, props, SWIFT_DOMAIN_NAME_PROPERTY, false);
|
||||
copy(conf, prefix + DOT_DOMAIN_ID, props, SWIFT_DOMAIN_ID_PROPERTY, false);
|
||||
copy(conf, prefix + DOT_TENANT, props, SWIFT_TENANT_PROPERTY, false);
|
||||
copy(conf, prefix + DOT_REGION, props, SWIFT_REGION_PROPERTY, false);
|
||||
copy(conf, prefix + DOT_HTTP_PORT, props, SWIFT_HTTP_PORT_PROPERTY, false);
|
||||
|
|
|
@ -211,6 +211,7 @@ public class SwiftProtocolConstants {
|
|||
public static final String DOT_PASSWORD = ".password";
|
||||
public static final String DOT_TRUST_ID = ".trust.id";
|
||||
public static final String DOT_DOMAIN_NAME = ".domain.name";
|
||||
public static final String DOT_DOMAIN_ID = ".domain.id";
|
||||
public static final String DOT_HTTP_PORT = ".http.port";
|
||||
public static final String DOT_HTTPS_PORT = ".https.port";
|
||||
public static final String DOT_REGION = ".region";
|
||||
|
@ -236,6 +237,7 @@ public class SwiftProtocolConstants {
|
|||
public static final String SWIFT_PASSWORD_PROPERTY = FS_SWIFT + DOT_PASSWORD;
|
||||
public static final String SWIFT_TRUST_ID_PROPERTY = FS_SWIFT + DOT_TRUST_ID;
|
||||
public static final String SWIFT_DOMAIN_NAME_PROPERTY = FS_SWIFT + DOT_DOMAIN_NAME;
|
||||
public static final String SWIFT_DOMAIN_ID_PROPERTY = FS_SWIFT + DOT_DOMAIN_ID;
|
||||
public static final String SWIFT_APIKEY_PROPERTY = FS_SWIFT + DOT_APIKEY;
|
||||
public static final String SWIFT_HTTP_PORT_PROPERTY = FS_SWIFT + DOT_HTTP_PORT;
|
||||
public static final String SWIFT_HTTPS_PORT_PROPERTY = FS_SWIFT
|
||||
|
|
|
@ -151,6 +151,11 @@ public final class SwiftRestClient {
|
|||
*/
|
||||
private final String domain_name;
|
||||
|
||||
/**
|
||||
* user's domain id
|
||||
*/
|
||||
private final String domain_id;
|
||||
|
||||
/**
|
||||
* user api key
|
||||
*/
|
||||
|
@ -491,6 +496,7 @@ public final class SwiftRestClient {
|
|||
password = props.getProperty(SWIFT_PASSWORD_PROPERTY);
|
||||
trust_id = props.getProperty(SWIFT_TRUST_ID_PROPERTY);
|
||||
domain_name = props.getProperty(SWIFT_DOMAIN_NAME_PROPERTY);
|
||||
domain_id = props.getProperty(SWIFT_DOMAIN_ID_PROPERTY);
|
||||
apiKey = props.getProperty(SWIFT_APIKEY_PROPERTY);
|
||||
//optional
|
||||
region = props.getProperty(SWIFT_REGION_PROPERTY);
|
||||
|
@ -515,13 +521,15 @@ public final class SwiftRestClient {
|
|||
if (trust_id == null) {
|
||||
if (password != null) {
|
||||
authRequest = new PasswordAuthenticationRequestV3(tenant,
|
||||
new PasswordCredentialsV3(username, password, domain_name));
|
||||
new PasswordCredentialsV3(username, password, domain_name,
|
||||
domain_id));
|
||||
} else {
|
||||
authRequest = new TokenAuthenticationRequestV3(apiKey);
|
||||
}
|
||||
} else {
|
||||
authRequest = new TrustAuthenticationRequest(
|
||||
new PasswordCredentialsV3(username, password, domain_name),
|
||||
new PasswordCredentialsV3(username, password, domain_name,
|
||||
domain_id),
|
||||
trust_id);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue