Example usage for java.lang System clearProperty

List of usage examples for java.lang System clearProperty

Introduction

In this page you can find the example usage for java.lang System clearProperty.

Prototype

public static String clearProperty(String key) 

Source Link

Document

Removes the system property indicated by the specified key.

Usage

From source file:com.mine.cassandra.sink.CassandraSinkIntegrationTests.java

@AfterClass
public static void cleanup() {
    System.clearProperty("spring.cassandra.port");
}

From source file:org.settings4j.helper.web.Log4jConfigurationLoaderTest.java

@Before
public void setUp() throws Exception {
    TestUtils.reconfigureSettings4jWithDefaultConfig();

    // clearProperties
    System.clearProperty(LOG4J_CONFIG_KEY);
    System.clearProperty(LOG4J_DOCUMENT_BUILDER_FACTORY);

    // Configure Log4j
    DOMConfigurator.configure(Loader.getResource("org/settings4j/helper/web/log4j-Config-Default.xml"));
}

From source file:com.talis.inject.guice.PropertiesConfiguredModuleFactoryTest.java

@Test(expected = ConfigurationException.class)
public void propertiesFileNotFound() throws Exception {

    File noFile = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    assertFalse(noFile.exists());/*from   w w  w .j  ava 2 s .c  om*/
    System.clearProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP);
    try {
        System.setProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP,
                noFile.getAbsolutePath());
        new PropertiesConfiguredModuleFactory().getModules();
    } finally {
        System.clearProperty(PropertiesConfiguredModuleFactory.PROPERTIES_LOCATION_PROP);
    }
}

From source file:com.apifest.doclet.integration.tests.DocletModeTest.java

@AfterMethod
public void clearProperties() {
    System.clearProperty("propertiesFilePath");
}

From source file:com.thoughtworks.go.agent.AgentProcessParentImplTest.java

@After
public void tearDown() {
    System.clearProperty("sleep.for.download");
    FileUtils.deleteQuietly(stdoutLog);
    FileUtils.deleteQuietly(stderrLog);

    cleanup();
}

From source file:com.sec.ose.osi.util.ProxyUtil.java

public void setProxyInfo(String mProxyHost, String mProxyPort, String mProxyBypass) {
    if (!getProxyHost().equals(mProxyHost))
        Property.getInstance().setProperty(Property.PROXY_HOST, mProxyHost);
    if (!getProxyPort().equals(mProxyPort))
        Property.getInstance().setProperty(Property.PROXY_PORT, mProxyPort);
    if (!getProxyBypass().equals(mProxyBypass))
        Property.getInstance().setProperty(Property.PROXY_BYPASS, mProxyBypass);

    if (!isValidProxyInfo(mProxyHost, mProxyPort, mProxyBypass)) {
        System.setProperty("proxySet", "false");
        System.clearProperty("http.proxyHost");
        System.clearProperty("http.proxyPort");
        log.debug("Proxy disabled..");
    } else {//from ww  w.j a  v a 2 s .c  o m
        System.setProperty("proxySet", "true");
        System.setProperty("http.proxyHost", mProxyHost);
        System.setProperty("http.proxyPort", mProxyPort);
        System.setProperty("http.nonProxyHosts", mProxyBypass);
        log.debug("Proxy enabled..[" + mProxyHost + ":" + mProxyPort + "]");
        if (mProxyBypass.length() > 0)
            log.debug("nonProxyHosts : [" + mProxyBypass + "]");
    }

}

From source file:org.apache.solr.cloud.LeaderFailureAfterFreshStartTest.java

@Override
public void distribTearDown() throws Exception {
    if (!success) {
        printLayoutOnTearDown = true;//from   ww  w.  j  a  v  a 2  s  .c  o  m
    }
    System.clearProperty("solr.directoryFactory");
    System.clearProperty("solr.ulog.numRecordsToKeep");
    System.clearProperty("tests.zk.violationReportAction");
    super.distribTearDown();
}

From source file:org.josso.auth.scheme.validation.OCSPX509CertificateValidator.java

public void validate(X509Certificate certificate) throws X509CertificateValidationException {

    try {//w  w  w  . jav a2  s. c om
        if (_url != null) {
            log.debug("Using the OCSP server at: " + _url);
            Security.setProperty("ocsp.responderURL", _url);
        } else {
            log.debug("Using the OCSP server specified in the " + "Authority Info Access (AIA) extension "
                    + "of the certificate");
        }

        // configure the proxy
        if (_httpProxyHost != null && _httpProxyPort != null) {
            System.setProperty("http.proxyHost", _httpProxyHost);
            System.setProperty("http.proxyPort", _httpProxyPort);
        } else {
            System.clearProperty("http.proxyHost");
            System.clearProperty("http.proxyPort");
        }

        // get certificate path
        CertPath cp = generateCertificatePath(certificate);

        // get trust anchors
        Set<TrustAnchor> trustedCertsSet = generateTrustAnchors();

        // init PKIX parameters
        PKIXParameters params = new PKIXParameters(trustedCertsSet);

        // init cert store
        Set<X509Certificate> certSet = new HashSet<X509Certificate>();
        if (_ocspCert == null) {
            _ocspCert = getCertificate(_ocspResponderCertificateAlias);
        }
        if (_ocspCert != null) {
            certSet.add(_ocspCert);
            CertStoreParameters storeParams = new CollectionCertStoreParameters(certSet);
            CertStore store = CertStore.getInstance("Collection", storeParams);
            params.addCertStore(store);
            Security.setProperty("ocsp.responderCertSubjectName",
                    _ocspCert.getSubjectX500Principal().getName());
        }

        // activate certificate revocation checking
        params.setRevocationEnabled(true);

        // activate OCSP
        Security.setProperty("ocsp.enable", "true");

        // perform validation
        CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
        PKIXCertPathValidatorResult cpvResult = (PKIXCertPathValidatorResult) cpv.validate(cp, params);
        X509Certificate trustedCert = (X509Certificate) cpvResult.getTrustAnchor().getTrustedCert();

        if (trustedCert == null) {
            log.debug("Trsuted Cert = NULL");
        } else {
            log.debug("Trusted CA DN = " + trustedCert.getSubjectDN());
        }

    } catch (CertPathValidatorException e) {
        log.error(e, e);
        throw new X509CertificateValidationException(e);
    } catch (Exception e) {
        log.error(e, e);
        throw new X509CertificateValidationException(e);
    }
    log.debug("CERTIFICATE VALIDATION SUCCEEDED");
}

From source file:org.josso.auth.scheme.validation.CRLX509CertificateValidator.java

public void validate(X509Certificate certificate) throws X509CertificateValidationException {

    try {/* w w w.ja  va 2  s .  c  o  m*/
        URL crlUrl = null;
        if (_url != null) {
            crlUrl = new URL(_url);
            log.debug("Using the CRL server at: " + _url);
        } else {
            log.debug("Using the CRL server specified in the certificate.");
            System.setProperty("com.sun.security.enableCRLDP", "true");
        }

        // configure the proxy
        if (_httpProxyHost != null && _httpProxyPort != null) {
            System.setProperty("http.proxyHost", _httpProxyHost);
            System.setProperty("http.proxyPort", _httpProxyPort);
        } else {
            System.clearProperty("http.proxyHost");
            System.clearProperty("http.proxyPort");
        }

        // get certificate path
        CertPath cp = generateCertificatePath(certificate);

        // get trust anchors
        Set<TrustAnchor> trustedCertsSet = generateTrustAnchors();

        // init PKIX parameters
        PKIXParameters params = new PKIXParameters(trustedCertsSet);

        // activate certificate revocation checking
        params.setRevocationEnabled(true);

        // disable OCSP
        Security.setProperty("ocsp.enable", "false");

        // get a certificate revocation list
        if (crlUrl != null) {
            URLConnection connection = crlUrl.openConnection();
            connection.setDoInput(true);
            connection.setUseCaches(false);
            DataInputStream inStream = new DataInputStream(connection.getInputStream());
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            X509CRL crl = (X509CRL) cf.generateCRL(inStream);
            inStream.close();
            params.addCertStore(CertStore.getInstance("Collection",
                    new CollectionCertStoreParameters(Collections.singletonList(crl))));
        }

        // perform validation
        CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
        PKIXCertPathValidatorResult cpvResult = (PKIXCertPathValidatorResult) cpv.validate(cp, params);
        X509Certificate trustedCert = (X509Certificate) cpvResult.getTrustAnchor().getTrustedCert();

        if (trustedCert == null) {
            log.debug("Trsuted Cert = NULL");
        } else {
            log.debug("Trusted CA DN = " + trustedCert.getSubjectDN());
        }

    } catch (CertPathValidatorException e) {
        log.error(e, e);
        throw new X509CertificateValidationException(e);
    } catch (Exception e) {
        log.error(e, e);
        throw new X509CertificateValidationException(e);
    }
    log.debug("CERTIFICATE VALIDATION SUCCEEDED");
}