public static String generateSelfLlink(SslTrustCertificateState body) { return UriUtils.buildUriPath(SELF_LINK, generateFingerprint(body)); } }
private SslTrustCertificateState createSslTrustCertificateState( SslTrustImportRequest request, X509Certificate[] certChain) { String sslTrust = CertificateUtilExtended.toPEMformat(certChain, getHost()); SslTrustCertificateState sslTrustState = new SslTrustCertificateState(); sslTrustState.certificate = sslTrust; SslTrustCertificateState.populateCertificateProperties(sslTrustState, certChain[0]); sslTrustState.tenantLinks = request.tenantLinks; sslTrustState.documentSelfLink = SslTrustCertificateFactoryService .generateSelfLlink(sslTrustState); sslTrustState.origin = request.hostUri.toString(); return sslTrustState; }
private void startServices() { host.startFactory(new ComputeService()); host.startService(new SslTrustCertificateFactoryService()); waitForServices( SslTrustCertificateService.FACTORY_LINK, ComputeService.FACTORY_LINK); }
/** * Override the handlePost method to set the documentSelfLink. We don't want to have multiple * certificate states with the same certificate, so we build the documentSelfLink ourselves * * @param op */ @Override public void handlePost(Operation op) { if (op.isSynchronize()) { op.complete(); return; } if (op.hasBody()) { SslTrustCertificateState body = (SslTrustCertificateState) op.getBody(this.stateType); if (body == null) { op.fail(new IllegalArgumentException("structured body is required")); return; } if (body.documentSourceLink != null) { op.fail(new IllegalArgumentException("clone request not supported")); return; } body.documentSelfLink = generateSelfLlink(body); op.setBody(body); op.complete(); } else { op.fail(new IllegalArgumentException("body is required")); } }
private AdapterRequest prepareAdapterRequest(ContainerHostOperationType operationType, ComputeState cs, SslTrustCertificateState sslTrust) { AdapterRequest request = new AdapterRequest(); request.operationTypeId = operationType.id; request.serviceTaskCallback = ServiceTaskCallback.createEmpty(); request.resourceReference = UriUtils.buildUri(getHost(), ComputeService.FACTORY_LINK); request.customProperties = cs.customProperties == null ? new HashMap<>() : new HashMap<>(cs.customProperties); request.customProperties.putIfAbsent(ComputeConstants.HOST_URI_PROP_NAME, cs.address); if (sslTrust != null) { request.customProperties.put(SSL_TRUST_CERT_PROP_NAME, sslTrust.certificate); request.customProperties.put(SSL_TRUST_ALIAS_PROP_NAME, SslTrustCertificateFactoryService.generateFingerprint(sslTrust)); } return request; }