Builds an Openssl-style certificate validator.

@return an Openssl-style certificate validator configured as specified in
the parameters

@deprecated Create a {@link CertificateValidatorBuilder} object instead.
160344
public static X509CertChainValidatorExt buildCertificateValidator() {

    return buildCertificateValidator(
      DefaultVOMSValidator.DEFAULT_TRUST_ANCHORS_DIR, null, null, 0L,
      DEFAULT_NS_CHECKS, DEFAULT_CRL_CHECKS, DEFAULT_OCSP_CHECKS);
  }
1258567
public SamlServiceProvider build() {

        // Must ensure that OpenSAML is initialized before building a SAML service provider.
        SamlInitializer.ensureAvailability();

        if (entityId == null) {
            throw new IllegalStateException("entity ID is not specified");
        }
        if (credentialResolver == null) {
            throw new IllegalStateException(CredentialResolver.class.getSimpleName() + " is not specified");
        }
        if (authorizer == null) {
            throw new IllegalStateException(Authorizer.class.getSimpleName() + " is not specified");
        }

        final Credential signingCredential = credentialResolver.apply(signingKey);
        if (signingCredential == null) {
            throw new IllegalStateException("cannot resolve a " + Credential.class.getSimpleName() +
                                            " for signing: " + signingKey);
        }
        final Credential encryptionCredential = credentialResolver.apply(encryptionKey);
        if (encryptionCredential == null) {
            throw new IllegalStateException("cannot resolve a " + Credential.class.getSimpleName() +
                                            " for encryption: " + encryptionKey);
        }
        validateSignatureAlgorithm(signatureAlgorithm, signingCredential);
        validateSignatureAlgorithm(signatureAlgorithm, encryptionCredential);

        // Initialize single logout service configurations.
        final List<SamlEndpoint> sloEndpoints;
        if (this.sloEndpoints.isEmpty()) {
            // Add two endpoints by default if there's no SLO endpoint specified by a user.
            sloEndpoints = ImmutableList.of(ofHttpPost("/saml/slo/post"),
                                            ofHttpRedirect("/saml/slo/redirect"));
        } else {
            sloEndpoints = ImmutableList.copyOf(this.sloEndpoints);
        }

        // Initialize assertion consumer service configurations.
        final List<SamlAssertionConsumerConfig> assertionConsumerConfigs;
        if (acsConfigBuilders.isEmpty()) {
            // Add two endpoints by default if there's no ACS endpoint specified by a user.
            assertionConsumerConfigs =
                    ImmutableList.of(new SamlAssertionConsumerConfigBuilder(this)
                                             .endpoint(ofHttpPost("/saml/acs/post")).asDefault(),
                                     new SamlAssertionConsumerConfigBuilder(this)
                                             .endpoint(ofHttpRedirect("/saml/acs/redirect")))
                                 .stream()
                                 .map(SamlAssertionConsumerConfigBuilder::build)
                                 .collect(toImmutableList());
        } else {
            // If there is only one ACS, it will be automatically a default ACS.
            if (acsConfigBuilders.size() == 1) {
                acsConfigBuilders.get(0).asDefault();
            }

            assertionConsumerConfigs = acsConfigBuilders.stream()
                                                        .map(SamlAssertionConsumerConfigBuilder::build)
                                                        .collect(toImmutableList());
        }

        // Collect assertion consumer service endpoints for checking duplication and existence.
        final Set<SamlEndpoint> acsEndpoints =
                assertionConsumerConfigs.stream().map(SamlAssertionConsumerConfig::endpoint)
                                        .collect(toImmutableSet());
        if (acsEndpoints.size() != assertionConsumerConfigs.size()) {
            throw new IllegalStateException("duplicated access consumer services exist");
        }

        // Initialize identity provider configurations.
        if (idpConfigBuilders.isEmpty()) {
            throw new IllegalStateException("no identity provider configuration is specified");
        }
        // If there is only one IdP, it will be automatically a default IdP.
        if (idpConfigBuilders.size() == 1) {
            idpConfigBuilders.get(0).asDefault();
        }

        final ImmutableMap.Builder<String, SamlIdentityProviderConfig> idpConfigs = ImmutableMap.builder();
        SamlIdentityProviderConfig defaultIdpConfig = null;
        for (final SamlIdentityProviderConfigBuilder builder : idpConfigBuilders) {
            if (builder.acsEndpoint() != null && !acsEndpoints.contains(builder.acsEndpoint())) {
                throw new IllegalStateException("unspecified access consumer service at " +
                                                builder.acsEndpoint());
            }

            final SamlIdentityProviderConfig config = builder.build(credentialResolver);

            validateSignatureAlgorithm(signatureAlgorithm, config.signingCredential());
            validateSignatureAlgorithm(signatureAlgorithm, config.encryptionCredential());

            idpConfigs.put(config.entityId(), config);

            if (builder.isDefault()) {
                if (defaultIdpConfig != null) {
                    throw new IllegalStateException("there has to be only one default identity provider");
                }
                defaultIdpConfig = config;
            }
        }

        if (idpConfigSelector == null) {
            if (defaultIdpConfig == null) {
                throw new IllegalStateException("default identity provider does not exist");
            }

            // Configure a default identity provider selector which always returns a default identity provider.
            final SamlIdentityProviderConfig defaultConfig = defaultIdpConfig;
            idpConfigSelector =
                    (unused1, unused2, unused3) -> CompletableFuture.completedFuture(defaultConfig);
        }

        // entityID would be used as a secret by default.
        try {
            requestIdManager = firstNonNull(requestIdManager,
                                            SamlRequestIdManager.ofJwt(entityId, entityId,
                                                                       60, 5));
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException("cannot create a " + SamlRequestIdManager.class.getSimpleName(),
                                            e);
        }

        return new SamlServiceProvider(authorizer,
                                       entityId,
                                       hostname,
                                       signingCredential,
                                       encryptionCredential,
                                       signatureAlgorithm,
                                       hostConfigBuilder.toAutoFiller(),
                                       metadataPath,
                                       idpConfigs.build(),
                                       defaultIdpConfig,
                                       idpConfigSelector,
                                       assertionConsumerConfigs,
                                       sloEndpoints,
                                       requestIdManager,
                                       ssoHandler,
                                       sloHandler);
    }
601223
public List<FacesConfigDefaultValidatorsType<FacesConfigApplicationType<T>>> getAllDefaultValidators()
   {
      List<FacesConfigDefaultValidatorsType<FacesConfigApplicationType<T>>> list = new ArrayList<FacesConfigDefaultValidatorsType<FacesConfigApplicationType<T>>>();
      List<Node> nodeList = childNode.get("default-validators");
      for(Node node: nodeList)
      {
         FacesConfigDefaultValidatorsType<FacesConfigApplicationType<T>>  type = new FacesConfigDefaultValidatorsTypeImpl<FacesConfigApplicationType<T>>(this, "default-validators", childNode, node);
         list.add(type);
      }
      return list;
   }
49097
public static Builder builder() {
    return new AutoValue_MetricOptions.Builder()
        .setDescription("")
        .setUnit("1")
        .setLabelKeys(Collections.<LabelKey>emptyList())
        .setConstantLabels(Collections.<LabelKey, LabelValue>emptyMap());
  }
1284393
public OCSPReq build() throws OCSPException, IOException, CertificateEncodingException {
        SecureRandom generator = checkNotNull(this.generator, "generator");
        DigestCalculator calculator = checkNotNull(this.calculator, "calculator");
        X509Certificate certificate = checkNotNull(this.certificate, "certificate");
        X509Certificate issuer = checkNotNull(this.issuer, "issuer");

        BigInteger serial = certificate.getSerialNumber();

        CertificateID certId = new CertificateID(calculator,
                new X509CertificateHolder(issuer.getEncoded()), serial);

        OCSPReqBuilder builder = new OCSPReqBuilder();
        builder.addRequest(certId);

        byte[] nonce = new byte[8];
        generator.nextBytes(nonce);

        Extension[] extensions = new Extension[] {
                new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false,
                        new DEROctetString(nonce)) };

        builder.setRequestExtensions(new Extensions(extensions));

        return builder.build();
    }
749599
@Beta
  public Builder toBuilder() {
    Builder builder = new GoogleCredential.Builder()
        .setServiceAccountPrivateKey(serviceAccountPrivateKey)
        .setServiceAccountPrivateKeyId(serviceAccountPrivateKeyId)
        .setServiceAccountId(serviceAccountId)
        .setServiceAccountProjectId(serviceAccountProjectId)
        .setServiceAccountUser(serviceAccountUser)
        .setServiceAccountScopes(serviceAccountScopes)
        .setTokenServerEncodedUrl(getTokenServerEncodedUrl())
        .setTransport(getTransport())
        .setJsonFactory(getJsonFactory())
        .setClock(getClock());

    builder.setClientAuthentication(getClientAuthentication());

    return builder;
  }
1119356
@Nonnull
  public static <T> UBLPEValidatorBuilder <T> create (@Nonnull final Class <T> aClass)
  {
    return new UBLPEValidatorBuilder <> (aClass);
  }
898350
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException
    {
        if(isValidating()) {
            try {
                return new ValidatingDocumentBuilder(
                    _WrappedFactory.newDocumentBuilder(),
                    _Schema.newVerifier());
            } catch(VerifierConfigurationException ex) {
                throw new ParserConfigurationException(ex.getMessage());
            }
        } else
            //if validation is disabled, we simply return the implementation of wrapped DocumentBuilder
            return _WrappedFactory.newDocumentBuilder();
    }
372121
@Override
    public StructValidator getSimpleValidator()
    {
        /* Can we create a simple validator? Yes, if the sub-specs are
         * all simple (leaves == element tokens with no arity modifier);
         * this is always true for mixed.
         */
        ContentSpec[] specs = mContentSpecs;
        int len = specs.length;
        int i;

        if (mHasMixed) {
            i = len;
        } else {
            i = 0;
            for (; i < len; ++i) {
                if (!specs[i].isLeaf()) {
                    break;
                }
            }
        }

        if (i == len) { // all leaves, kewl
            PrefixedNameSet keyset = namesetFromSpecs(mNsAware, specs);
            return new Validator(mArity, keyset);
        }

        // Nah, need a DFA...
        return null;
    }
294702
public UserManagedCacheBuilder<K, V, T> withKeySerializingCopier() {
    UserManagedCacheBuilder<K, V, T> otherBuilder = new UserManagedCacheBuilder<>(this);
    otherBuilder.keyCopier = null;
    otherBuilder.useKeySerializingCopier = true;
    return otherBuilder;
  }
1126216
public static Builder builder() {
    return new AutoValue_Source.Builder()
        .setPath(DEV_NULL)
        .setCode("")
        .setOriginalCodeSupplier(null)
        .setSourceMap("")
        .setSourceUrl("")
        .setSourceMappingUrl("")
        .setRuntimes(ImmutableSet.of())
        .setLoadFlags(ImmutableMap.of())
        .setEstimatedSize(0);
  }
450913
public B tls(KeyManagerFactory keyManagerFactory,
                 Consumer<SslContextBuilder> tlsCustomizer) throws SSLException {
        requireNonNull(keyManagerFactory, "keyManagerFactory");
        requireNonNull(tlsCustomizer, "tlsCustomizer");

        tls(buildSslContext(() -> SslContextBuilder.forServer(keyManagerFactory), tlsCustomizer));
        return self();
    }
389669
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1784")
  @CanIgnoreReturnValue
  public static SslContextBuilder configure(SslContextBuilder builder, SslProvider provider) {
    switch (provider) {
      case JDK:
      {
        Provider jdkProvider = findJdkProvider();
        if (jdkProvider == null) {
          throw new IllegalArgumentException(
              "Could not find Jetty NPN/ALPN or Conscrypt as installed JDK providers");
        }
        return configure(builder, jdkProvider);
      }
      case OPENSSL:
      {
        ApplicationProtocolConfig apc;
        if (OpenSsl.isAlpnSupported()) {
          apc = NPN_AND_ALPN;
        } else {
          apc = NPN;
        }
        return builder
            .sslProvider(SslProvider.OPENSSL)
            .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
            .applicationProtocolConfig(apc);
      }
      default:
        throw new IllegalArgumentException("Unsupported provider: " + provider);
    }
  }
838999
public static Validator getExperimentalValidator() {
        return CascadingValidator.create(
                ParenthesesValidator.INSTANCE,
                ConfigurableValidator.create(ValidatorConfiguration.createExperimental()));
    }
577672
protected SAXBuilder createSAXBuilder() {
        SAXBuilder saxBuilder;
        if (validate) {
            saxBuilder = new SAXBuilder(XMLReaders.DTDVALIDATING);
        } else {
            saxBuilder = new SAXBuilder(XMLReaders.NONVALIDATING);
        }
        saxBuilder.setEntityResolver(RESOLVER);

        //
        // This code is needed to fix the security problem outlined in
        // http://www.securityfocus.com/archive/1/297714
        //
        // Unfortunately there isn't an easy way to check if an XML parser
        // supports a particular feature, so
        // we need to set it and catch the exception if it fails. We also need
        // to subclass the JDom SAXBuilder
        // class in order to get access to the underlying SAX parser - otherwise
        // the features don't get set until
        // we are already building the document, by which time it's too late to
        // fix the problem.
        //
        // Crimson is one parser which is known not to support these features.
        try {
            
            final XMLReader parser = saxBuilder.createParser();
            
            setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-general-entities", false);
            setFeature(saxBuilder, parser, "http://xml.org/sax/features/external-parameter-entities", false);
            setFeature(saxBuilder, parser, "http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

            if(!allowDoctypes) {
                setFeature(saxBuilder, parser, "http://apache.org/xml/features/disallow-doctype-decl", true);
            }

        } catch (final JDOMException e) {
            throw new IllegalStateException("JDOM could not create a SAX parser", e);
        }
        
        saxBuilder.setExpandEntities(false);

        return saxBuilder;

    }
318051
public static SSLSocketFactory getSslSocketFactory() {
    if (!sslDisabled) {
      return SSLSocketFactory.getSocketFactory();
    }

    try {
      final X509Certificate[] _AcceptedIssuers = new X509Certificate[] {};

      final SSLContext ctx = SSLContext.getInstance("TLS");
      final X509TrustManager tm = new X509TrustManager() {
        @Override
        public X509Certificate[] getAcceptedIssuers() {
          return _AcceptedIssuers;
        }
        @Override
        public void checkServerTrusted(final X509Certificate[] chain,
                                       final String authType) throws CertificateException {
        }
        @Override
        public void checkClientTrusted(final X509Certificate[] chain,
                                       final String authType) throws CertificateException {
        }
      };
      ctx.init(null, new TrustManager[] { tm }, new SecureRandom());

      return new SSLSocketFactory(ctx,
                                  SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    } catch (final Throwable t) {
      throw new RuntimeException(t);
    }
  }
1032604
private Validator createNewErrorValidator() {
        final Validator validator = schema.newValidator();
        validator.setErrorHandler(new Handler());
        return validator;
    }