Create a Feedback object

@param Certificate|null The certificate to use or null to use the default certificate from the given certificate factory
@return Feedback
554719
public function createFeedback(Certificate $certificate = null)
	{
		// Check if a certificate is given, if not use the default certificate
		if (null == $certificate && $this->getCertificateFactory() != null) {
			$certificate = $this->getCertificateFactory()->getDefaultCertificate();
		}

		// Check if there is a certificate to use after falling back on the default certificate
		if (null == $certificate) {
			throw new \RuntimeException('No certificate given for the creation of the feedback service and no default certificate available.');
		}

		return new Feedback($certificate);
	}
144621
public static PKIXCertPathBuilderResult verifyChain(X509Certificate testCert, X509Certificate... additionalCerts) {
        try {
            // Check for self-signed certificate
            if (isSelfSigned(testCert)) {
                throw new RuntimeException("The certificate is self-signed.  Nothing to verify.");
            }

            // Prepare a set of all certificates
            // chain builder must have all certs, including cert to validate
            // http://stackoverflow.com/a/10788392
            Set<X509Certificate> certs = new HashSet<X509Certificate>();
            certs.add(testCert);
            certs.addAll(Arrays.asList(additionalCerts));

            // Attempt to build the certification chain and verify it
            // Create the selector that specifies the starting certificate
            X509CertSelector selector = new X509CertSelector();
            selector.setCertificate(testCert);

            // Create the trust anchors (set of root CA certificates)
            Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
            for (X509Certificate cert : additionalCerts) {
                if (isSelfSigned(cert)) {
                    trustAnchors.add(new TrustAnchor(cert, null));
                }
            }

            // Configure the PKIX certificate builder
            PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustAnchors, selector);
            pkixParams.setRevocationEnabled(false);
            pkixParams.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters(certs), BC));

            // Build and verify the certification chain
            CertPathBuilder builder = CertPathBuilder.getInstance("PKIX", BC);
            PKIXCertPathBuilderResult verifiedCertChain = (PKIXCertPathBuilderResult) builder.build(pkixParams);

            // The chain is built and verified
            return verifiedCertChain;
        } catch (CertPathBuilderException e) {
            throw new RuntimeException("Error building certification path: " + testCert.getSubjectX500Principal(), e);
        } catch (Exception e) {
            throw new RuntimeException("Error verifying the certificate: " + testCert.getSubjectX500Principal(), e);
        }
    }
1079358
private X509Certificate createCACert(PublicKey publicKey, PrivateKey privateKey) throws Exception {

        // signers name
        X500Name issuerName = new X500Name("CN=www.mockserver.com, O=MockServer, L=London, ST=England, C=UK");

        // subjects name - the same as we are self signed.
        X500Name subjectName = issuerName;

        // serial
        BigInteger serial = BigInteger.valueOf(new Random().nextInt(Integer.MAX_VALUE));

        // create the certificate - version 3
        X509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(issuerName, serial, NOT_BEFORE, NOT_AFTER, subjectName, publicKey);
        builder.addExtension(Extension.subjectKeyIdentifier, false, createSubjectKeyIdentifier(publicKey));
        builder.addExtension(Extension.basicConstraints, true, new BasicConstraints(true));

        KeyUsage usage = new KeyUsage(KeyUsage.keyCertSign | KeyUsage.digitalSignature | KeyUsage.keyEncipherment | KeyUsage.dataEncipherment | KeyUsage.cRLSign);
        builder.addExtension(Extension.keyUsage, false, usage);

        ASN1EncodableVector purposes = new ASN1EncodableVector();
        purposes.add(KeyPurposeId.id_kp_serverAuth);
        purposes.add(KeyPurposeId.id_kp_clientAuth);
        purposes.add(KeyPurposeId.anyExtendedKeyUsage);
        builder.addExtension(Extension.extendedKeyUsage, false, new DERSequence(purposes));

        X509Certificate cert = signCertificate(builder, privateKey);
        cert.checkValidity(new Date());
        cert.verify(publicKey);

        return cert;
    }
475782
protected function addNodeCreatedFeedback($subject = null)
    {
        $node = $subject ?: $this->getSubject();
        $nodeCreated = new NodeCreated();
        $nodeCreated->setNode($node);
        $this->feedbackCollection->add($nodeCreated);
    }
631845
public String validate(KeyStore keyStore, String keyAlias) throws CertificateException {
        String result = null;
        if (keyAlias != null) {
            try {
                validate(keyStore, keyStore.getCertificate(keyAlias));
            } catch (KeyStoreException kse) {
                logger.debug("", kse);
                throw new CertificateException("Unable to validate certificate" +
                        " for alias [" + keyAlias + "]: " + kse.getMessage(), kse);
            }
            result = keyAlias;
        }
	return result;
    }
6436
public static base_response create(nitro_service client, sslcertreq resource) throws Exception {
		sslcertreq createresource = new sslcertreq();
		createresource.reqfile = resource.reqfile;
		createresource.keyfile = resource.keyfile;
		createresource.fipskeyname = resource.fipskeyname;
		createresource.keyform = resource.keyform;
		createresource.pempassphrase = resource.pempassphrase;
		createresource.countryname = resource.countryname;
		createresource.statename = resource.statename;
		createresource.organizationname = resource.organizationname;
		createresource.organizationunitname = resource.organizationunitname;
		createresource.localityname = resource.localityname;
		createresource.commonname = resource.commonname;
		createresource.emailaddress = resource.emailaddress;
		createresource.challengepassword = resource.challengepassword;
		createresource.companyname = resource.companyname;
		return createresource.perform_operation(client,"create");
	}
973099
public final ControlBrowseStatus createNewControlBrowseStatus() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlBrowseStatus");
    ControlBrowseStatus msg = null;
    try {
      msg = new ControlBrowseStatusImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlBrowseStatus");
    return msg;
  }
160344
public static X509CertChainValidatorExt buildCertificateValidator() {

    return buildCertificateValidator(
      DefaultVOMSValidator.DEFAULT_TRUST_ANCHORS_DIR, null, null, 0L,
      DEFAULT_NS_CHECKS, DEFAULT_CRL_CHECKS, DEFAULT_OCSP_CHECKS);
  }
432192
def create(gandi, private_key, certificate, certificate_id):
    
    if not certificate and not certificate_id:
        gandi.echo('One of --certificate or --certificate-id is needed.')
        return
    if certificate and certificate_id:
        gandi.echo('Only one of --certificate or --certificate-id is needed.')

    if os.path.isfile(private_key):
        with open(private_key) as fhandle:
            private_key = fhandle.read()

    if certificate:
        if os.path.isfile(certificate):
            with open(certificate) as fhandle:
                certificate = fhandle.read()
    else:
        cert = gandi.certificate.info(certificate_id)
        certificate = gandi.certificate.pretty_format_cert(cert)

    result = gandi.hostedcert.create(private_key, certificate)

    output_keys = ['id', 'subject', 'date_created', 'date_expire',
                   'fqdns', 'vhosts']

    output_hostedcert(gandi, result, output_keys)

    return result
1268031
@Override
    public ContinuityCheckRequestMessage createCCR() {
        ContinuityCheckRequestMessageImpl ccr = new ContinuityCheckRequestMessageImpl(_CCR_HOLDER.mandatoryCodes,
                _CCR_HOLDER.mandatoryVariableCodes, _CCR_HOLDER.optionalCodes, _CCR_HOLDER.mandatoryCodeToIndex,
                _CCR_HOLDER.mandatoryVariableCodeToIndex, _CCR_HOLDER.optionalCodeToIndex);
        return ccr;
    }
925790
public static CERTRecord
buildRecord(Name name, int dclass, long ttl, Certificate cert, int tag,
	    int alg)
{
	int type;
	byte [] data;

	try {
		if (cert instanceof X509Certificate) {
			type = CERTRecord.PKIX;
			data = cert.getEncoded();
		}
		else
			return null;

		return new CERTRecord(name, dclass, ttl, type, tag, alg, data);
	}
	catch (CertificateException e) {
		if (Options.check("verboseexceptions"))
			System.err.println("Cert build exception:" + e);
		return null;
	}
}
1322666
static X509Certificate selfSignedCertificate() throws CertificateException {
        return (X509Certificate) SslContext.X509_CERT_FACTORY.generateCertificate(
                new ByteArrayInputStream(CERT.getBytes(CharsetUtil.US_ASCII))
        );
    }
134894
private String httpsQuery() {

		String response = null;
		try {
			// Create a trust manager that does not validate certificate chains
			TrustManager[] trustAllCerts = new TrustManager[] { new LocalX509TrustManager()};

			// Install the all-trusting trust manager
			final SSLContext sc = SSLContext.getInstance("SSL");
			sc.init( null, trustAllCerts, new java.security.SecureRandom());
			HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory());

			// Create all-trusting host name verifier
			HostnameVerifier allHostsValid = new LocalHostnameVerifier();
			HttpsURLConnection.setDefaultHostnameVerifier( allHostsValid );

			URL restUrl = new URL( this.url );
			HttpsURLConnection conn = (HttpsURLConnection) restUrl.openConnection();
			response = query( conn );

		} catch( Exception e ) {
			this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." );
			Utils.logException(this.logger, e);
		}

		return response;
	}
157518
private SICoreConnection createConnection(Certificate[] certificate) throws SIAuthenticationException, SIResourceException, SINotAuthorizedException {
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled()) {
            SibTr.entry(CoreSPIConnFactory.tc, "createConnection", certificate);
        }

        // Check that the Messaging Engine is started
        checkStarted();

        Subject subject = null;

        try {
            subject = _authentication.login(certificate);
        } catch (MessagingAuthenticationException e) {
            throw new SIAuthenticationException(e.getMessage());
        }
        SICoreConnection connection = createConnection(subject, null);
        if (TraceComponent.isAnyTracingEnabled()
            && CoreSPIConnFactory.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConnFactory.tc, "createConnection", connection);
        return connection;
    }
561454
public ContinuityCheckRequestMessage createCCR(int cic) {
        ContinuityCheckRequestMessage msg = createCCR();
        CircuitIdentificationCode code = this.parameterFactory.createCircuitIdentificationCode();
        code.setCIC(cic);
        msg.setCircuitIdentificationCode(code);
        return msg;
    }
653491
def create_check(self, label=None, name=None, check_type=None,
            disabled=False, metadata=None, details=None,
            monitoring_zones_poll=None, timeout=None, period=None,
            target_alias=None, target_hostname=None, target_receiver=None,
            test_only=False, include_debug=False):
        
        return self._check_manager.create_check(label=label, name=name,
                check_type=check_type, disabled=disabled, metadata=metadata,
                details=details, monitoring_zones_poll=monitoring_zones_poll,
                timeout=timeout, period=period, target_alias=target_alias,
                target_hostname=target_hostname,
                target_receiver=target_receiver, test_only=test_only,
                include_debug=include_debug)
305350
@Override
	public Result<CertInfo> toCert(AuthzTrans trans, Result<CertResp> in, String[] trustChain) throws IOException {
		if(in.isOK()) {
			CertResp cin = in.value;
			CertInfo cout = newInstance(API.CERT);
			cout.setPrivatekey(cin.privateString());
			String value;
			if((value=cin.challenge())!=null) {
				cout.setChallenge(value);
			}
			cout.getCerts().add(cin.asCertString());
			if(trustChain!=null) {
				for(String c : trustChain) {
					cout.getCerts().add(c);
				}
			}
			if(cin.notes()!=null) {
				boolean first = true;
				StringBuilder sb = new StringBuilder();
				for(String n : cin.notes()) {
					if(first) {
						first = false;
					} else {
						sb.append('\n');
					}
					sb.append(n);
				}
				cout.setNotes(sb.toString());
			}
			return Result.ok(cout);
		} else {
			return Result.err(in);
		}
	}