BigInteger[] keys = DiffieHellman.BASE_2.generateRandomKeys(Constants.DIFFIE_HELLMAN_MODULUS);
String publicKeyString = new String(B64Code.encode(keys[1].toByteArray()));
associationData.put(Constants.OPENID_DH_CONSUMER_PUBLIC, publicKeyString);
Response response = context.getHttpConnector().doPOST(user.getOpenIdServer(), (Map<?,?>)null,
associationData, Constants.DEFAULT_ENCODING);
associationData.put(CLIENT_PRIVATE_KEY_ATTR, keys[0].toString());
BufferedReader br = null;
try
{
br = new BufferedReader(new InputStreamReader(response.getInputStream(), Constants.DEFAULT_ENCODING), 1024);
parseInputByLineSeparator(br, ':', associationData);
}
finally
{
if(br!=null)
br.close();
response.close();
}
user.setAssocHandle((String)associationData.get(Constants.Assoc.ASSOC_HANDLE));
user.setAssociationData(associationData);
return user.isAssociated();