Step 2: Create a Connection Object - Java

Create a connection based on your grant type using the connection factory

//get ADP connection using Connection factory and configuration 
authorizationCodeConnection = (AuthorizationCodeConnection)
CONNECTION_FACTORY_INSTANCE.createConnection(authorizationCodeConfiguration);  

//get Url from authorization connection
authorizationUrl = "redirect:" + authorizationCodeConnection.getAuthorizationUrl();

//CALL BACK HANDLER
//get code value 
String requestCode = (String) request.getParameter("code”);

//map request code to connection configuration
((AuthorizationCodeConfiguration) authorizationCodeConnection.getConnectionConfiguration()).setAuthorizationCode(requestCode);