private void uploadCerts(ComputeManagementClient client, String cloudServiceName, byte[] certData){ try { // Try to upload to hosted service ServiceCertificateCreateParameters params = new ServiceCertificateCreateParameters(); params.setCertificateFormat(CertificateFormat.Pfx); params.setData(certData); client.getServiceCertificatesOperations().create(cloudServiceName, params); } catch (Exception e) { e.printStackTrace(); } }
/** * Initializes a new instance of the ServiceCertificateCreateParameters * class with required arguments. * * @param data The pfx or cer file. * @param certificateFormat The service certificate format. Azure supports * the pfx and cer file formats. */ public ServiceCertificateCreateParameters(byte[] data, CertificateFormat certificateFormat) { if (data == null) { throw new NullPointerException("data"); } if (certificateFormat == null) { throw new NullPointerException("certificateFormat"); } this.setData(data); this.setCertificateFormat(certificateFormat); } }
throw new NullPointerException("parameters"); if (parameters.getData() == null) { throw new NullPointerException("parameters.Data"); dataElement.appendChild(requestDoc.createTextNode(Base64.encode(parameters.getData()))); certificateFileElement.appendChild(dataElement); certificateFormatElement.appendChild(requestDoc.createTextNode(ComputeManagementClientImpl.certificateFormatToString(parameters.getCertificateFormat()))); certificateFileElement.appendChild(certificateFormatElement); if (parameters.getPassword() != null) { Element passwordElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Password"); passwordElement.appendChild(requestDoc.createTextNode(parameters.getPassword())); certificateFileElement.appendChild(passwordElement);
throw new NullPointerException("parameters"); if (parameters.getCertificateFormat() == null) { throw new NullPointerException("parameters.CertificateFormat"); if (parameters.getData() == null) { throw new NullPointerException("parameters.Data"); dataElement.appendChild(requestDoc.createTextNode(Base64.encode(parameters.getData()))); certificateFileElement.appendChild(dataElement); certificateFormatElement.appendChild(requestDoc.createTextNode(ComputeManagementClientImpl.certificateFormatToString(parameters.getCertificateFormat()))); certificateFileElement.appendChild(certificateFormatElement); if (parameters.getPassword() != null) { Element passwordElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Password"); passwordElement.appendChild(requestDoc.createTextNode(parameters.getPassword())); certificateFileElement.appendChild(passwordElement);