diff options
author | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-22 19:47:16 +0530 |
---|---|---|
committer | Bharat saraswal <bharat.saraswal@huawei.com> | 2017-09-22 19:47:48 +0530 |
commit | 56d83f2aa390098fc8f3077194bdcba5c1c90090 (patch) | |
tree | c8732fd657088b4946e111ad139206813a984a6e /keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java | |
parent | a34455305b0c42a66017aa0e3935f00020351001 (diff) |
Resolved below sonar issues.
removed redundant code.
added method for resuablity of string builder.
rename variable to follow camelCase.
removed tab char and changed them with spaces.
Issue-ID:SO-98
Change-Id: Ib081df5cbfdb4d2183ac51cb6779177ec2009bc6
Signed-off-by: Bharat saraswal <bharat.saraswal@huawei.com>
Diffstat (limited to 'keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java')
-rw-r--r-- | keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java index 06da8ca..d5bfe22 100644 --- a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java @@ -15,63 +15,57 @@ import com.woorea.openstack.keystone.model.authentication.TokenAuthentication; import com.woorea.openstack.keystone.model.authentication.UsernamePassword; public class TokensResource { - - private final OpenStackClient CLIENT; - - public TokensResource(OpenStackClient client) { - CLIENT = client; - } - - public Authenticate.Builder authenticate() { - return new Authenticate().new Builder(); - } - - public Authenticate authenticate(Authentication authentication) { - return new Authenticate(authentication); - } - - public class Authenticate extends OpenStackRequest<Access> { - - private Authentication authentication; - - public Authenticate() { - - } - - public Authenticate(Authentication authentication) { - super(CLIENT, HttpMethod.POST, "/tokens", Entity.json(authentication), Access.class); - this.authentication = authentication; - } - - public Authenticate withTenantId(String tenantId) { - authentication.setTenantId(tenantId); - return this; - } - - public Authenticate withTenantName(String tenantName) { - authentication.setTenantName(tenantName); - return this; - } - - public class Builder { - - public Authenticate withUsernamePassword(String username, String password) { - Authentication authentication = new UsernamePassword(username, password); - return new Authenticate(authentication); - } - - public Authenticate withToken(String token) { - Authentication authentication = new TokenAuthentication(token); - return new Authenticate(authentication); - } - - public Authenticate withAccessKey(String accessKey, String secretKey) { - Authentication authentication = new AccessKey(accessKey, secretKey); - return new Authenticate(authentication); - } - - } - - } - + + private final OpenStackClient client; + + public TokensResource(OpenStackClient client) { + this.client = client; + } + + public Authenticate.Builder authenticate() { + return new Authenticate().new Builder(); + } + + public Authenticate authenticate(Authentication authentication) { + return new Authenticate(authentication); + } + + public class Authenticate extends OpenStackRequest<Access> { + + private Authentication authentication; + + public Authenticate() { + + } + + public Authenticate(Authentication authentication) { + super(client, HttpMethod.POST, "/tokens", Entity.json(authentication), Access.class); + this.authentication = authentication; + } + + public Authenticate withTenantId(String tenantId) { + authentication.setTenantId(tenantId); + return this; + } + + public Authenticate withTenantName(String tenantName) { + authentication.setTenantName(tenantName); + return this; + } + + public class Builder { + + public Authenticate withUsernamePassword(String username, String password) { + return new Authenticate(new UsernamePassword(username, password)); + } + + public Authenticate withToken(String token) { + return new Authenticate(new TokenAuthentication(token)); + } + + public Authenticate withAccessKey(String accessKey, String secretKey) { + return new Authenticate(new AccessKey(accessKey, secretKey)); + } + } + } } |