@@ -0,0 +1,2956 @@
+package org.jboss.pnc.auth;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.apache.http.client.ClientProtocolException;%0Aimport org.apache.http.client.entity.UrlEncodedFormEntity;%0Aimport org.apache.http.client.methods.CloseableHttpResponse;%0Aimport org.apache.http.client.methods.HttpPost;%0Aimport org.apache.http.impl.client.CloseableHttpClient;%0Aimport org.apache.http.impl.client.HttpClients;%0Aimport org.apache.http.message.BasicNameValuePair;%0A%0Apublic class SimpleOAuthConnect %7B%0A    %0A    public static String getAccessToken(String url, String clientId, String username, String password) %0A            throws ClientProtocolException, IOException%7B%0A        CloseableHttpClient httpclient = HttpClients.createDefault();%0A        HttpPost httpPost = new HttpPost(url);%0A%0A        // add header%0A        httpPost.setHeader(%22Content-Type%22, %22application/x-www-form-urlencoded%22);%0A%0A        List %3CBasicNameValuePair%3E urlParameters = new ArrayList %3CBasicNameValuePair%3E();%0A        urlParameters.add(new BasicNameValuePair(%22username%22, username));%0A        urlParameters.add(new BasicNameValuePair(%22password%22, password));%0A        urlParameters.add(new BasicNameValuePair(%22client_id%22, clientId));%0A        httpPost.setEntity(new UrlEncodedFormEntity(urlParameters));%0A        CloseableHttpResponse response = httpclient.execute(httpPost);%0A%0A        try %7B%0A            BufferedReader rd = new BufferedReader(%0A                    new InputStreamReader(response.getEntity().getContent()));%0A%0A            String line = %22%22;%0A            while ((line = rd.readLine()) != null) %7B%0A                if(line.contains(%22refresh_token%22)) %7B%0A                    String%5B%5D respContent = line.split(%22,%22);%0A                    for (int i = 0; i %3C respContent.length; i++) %7B%0A                        String split = respContent%5Bi%5D;%0A                        if(split.contains(%22refresh_token%22)) %7B%0A                            String refreshToken = split.split(%22:%22)%5B1%5D.substring(1,split.split(%22:%22)%5B1%5D.length() -1);%0A                        %7D%0A                        if(split.contains(%22access_token%22)) %7B%0A                            String accessToken = split.split(%22:%22)%5B1%5D.substring(1,split.split(%22:%22)%5B1%5D.length() -1);%0A                            return accessToken;%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A%0A        %7D finally %7B%0A            response.close();%0A        %7D%0A        return null;%0A%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        try %7B%0A            System.out.println(%22%3E%3E%3E Access token: %22 + SimpleOAuthConnect%0A                    .getAccessToken(args%5B0%5D, args%5B1%5D, args%5B2%5D, args%5B3%5D));%0A        %7D catch (ClientProtocolException e) %7B%0A            // TODO Auto-generated catch block%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            // TODO Auto-generated catch block%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A%0A%7D%0A

add simple OAuth client