From 56d83f2aa390098fc8f3077194bdcba5c1c90090 Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Fri, 22 Sep 2017 19:47:16 +0530 Subject: 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 --- .../openstack/keystone/api/TokensResource.java | 112 ++++++++++----------- 1 file changed, 53 insertions(+), 59 deletions(-) (limited to 'keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java') 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 { - - 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 { + + 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)); + } + } + } } -- cgit 1.2.3-korg