dhParameterSpec);
} else {
dhSession = null;
}
AssociationRequest associationRequest = AssociationRequest.createAssociationRequest(associationSessionType, dhSession);
Request request = new Request();
request.setMethod("POST");
request.setURL(new HttpUrl(opUrl));
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
StringBuilder body = new StringBuilder();
Map parameters = associationRequest.getParameterMap();
Set parameterEntries = parameters.entrySet();
Iterator parameterIterator = parameterEntries.iterator();
while (parameterIterator.hasNext()) {
if (0 != body.length()) {
body.append("&");
}
Map.Entry parameterEntry = (Map.Entry) parameterIterator.next();
body.append(parameterEntry.getKey());
body.append("=");
body.append(Encoding.urlEncode((String)parameterEntry.getValue()));
}
request.setHeader("Content-Length", Integer.toString(body.length()));
request.setContent(body.toString().getBytes());
Response response = HTTPClientFactory.getInstance().fetchResponse(request);
if (false == "200".equals(response.getStatus())) {
throw new RuntimeException("invalid status return code: " + response.getStatus());
}