Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static RegisterAgentResponse registerAgent(
- RegisterAgent registerAgent,
- ClientResource clientResource)
- throws Exception{
- System.out.println("IS IT EVEN GETTING HERE?!");
- Form form = new Form();
- BigInteger mod = new BigInteger("93740173714873692520486809225128030132198461438147249362129501889664779512410440220785650833428588898698591424963196756217514115251721698086685512592960422731696162410024157767288910468830028582731342024445624992243984053669314926468760439060317134193339836267660799899385710848833751883032635625332235630111");
- BigInteger exp = new BigInteger("65537");
- PublicKey aggrPublicKey= RSACrypto.generatePublicKey(mod,exp);
- String key = "THis is my key";
- byte[] aggkey = AESCrypto.generateKey(key.getBytes("UTF-8"));
- byte[] base64_aggkey = Base64.encodeBase64(aggkey);
- byte[] enc_key = RSACrypto.encryptPublic(aggrPublicKey,base64_aggkey);
- byte[] send_key = Base64.encodeBase64(enc_key);
- String send_key_string = new String(send_key,"UTF-8");
- String enc_key_string = new String(enc_key,"UTF-8");
- String base64_aggkey_string = new String(base64_aggkey,"UTF-8");
- String test= new String(Base64.decodeBase64(send_key));
- System.out.println("This should be the *data* : " +base64_aggkey_string + " Size of : "+ base64_aggkey_string.length());
- System.out.println("This is the encoded data ,length ("+ send_key_string.length()+") , encoded_data : "+send_key_string);
- System.out.println("This is the decoded data : "+ test + " Size of : "+ test.length());
- form.add("key", send_key_string);
- form.add("agentID", Long.toString(Constants.DEFAULT_AGENT_ID));
- form.add(Constants.AGGR_MSG_KEY
- , new String(Base64.encodeBase64(registerAgent.toByteArray())));
- Representation response= clientResource.post(form.getWebRepresentation(null));
- return RegisterAgentResponse.parseFrom((Base64.decodeBase64(response.getText().getBytes())));
- }
Add Comment
Please, Sign In to add comment