Configuration and Auto-Certificates
[aaf/authz.git] / cadi / aaf / src / main / java / org / onap / aaf / cadi / oauth / TokenClient.java
index 0628d4d..e0d6bf0 100644 (file)
@@ -130,7 +130,7 @@ public class TokenClient {
         */
        public void client_creds(final String client_id, final String client_secret) throws CadiException {
                if(client_id==null) {
-                       throw new CadiException(Config.AAF_ALT_CLIENT_ID + " is null");
+                       throw new CadiException("client_creds:client_id is null");
                }
                this.client_id = client_id;
                default_scope = FQI.reverseDomain(client_id);
@@ -274,7 +274,7 @@ public class TokenClient {
                Result<TimedToken> rtt = factory.get(key,hash,new Loader<TimedToken>() {
                        @Override
                        public Result<TimedToken> load(final String key) throws APIException, CadiException, LocatorException {
-                               final List<String> params = new ArrayList<String>();
+                               final List<String> params = new ArrayList<>();
                                params.add(scope);
                                addSecurity(params,authn_method);
                        
@@ -331,7 +331,7 @@ public class TokenClient {
                if(ss==null) {
                        throw new APIException("client_creds(...) must be set before obtaining Access Tokens");
                }
-               final List<String> params = new ArrayList<String>();
+               final List<String> params = new ArrayList<>();
                params.add("refresh_token="+token.getRefreshToken());
                addSecurity(params,AUTHN_METHOD.refresh_token);
                final String scope="scope="+token.getScope().replace(' ', '+');
@@ -373,7 +373,7 @@ public class TokenClient {
                return tkCon.best(new Retryable<Result<Introspect>>() {
                                @Override
                                public Result<Introspect> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
-                                       final List<String> params = new ArrayList<String>();
+                                       final List<String> params = new ArrayList<>();
                                        params.add("token="+token);
                                        addSecurity(params,AUTHN_METHOD.client_credentials);
                                        final String paramsa[] = new String[params.size()];
@@ -443,6 +443,11 @@ public class TokenClient {
                                                throw new APIException("Error Decrypting Password",e);
                                        }
                                }
+                               
+                               if(username!=null) {
+                                       params.add("username="+username);
+                               }
+
                                break;
                        case refresh_token:
                                if(client_id!=null) {