Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

In this page you can find the example usage for java.lang Boolean getBoolean.

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:com.seajas.search.utilities.tags.URLTag.java

/**
 * Rewrite a URL./*from w  ww.  ja  va2  s .  c  o m*/
 * 
 * @param context
 * @param request
 * @param url
 * @param fullUrl
 * @return String
 */
public static String rewriteURL(final ServletContext context, final HttpServletRequest request,
        final String url, final Boolean fullUrl) {
    String rewrittenURL = url;

    String contextName = context.getContextPath();

    if (contextName == null)
        contextName = System.getProperty(SYSTEM_DEFAULT_CONTEXT);

    if (contextName.startsWith("/"))
        contextName = contextName.substring(1);

    if (Boolean.getBoolean(SYSTEM_REWRITTEN_URLS)) {
        if (rewrittenURL.startsWith(contextName))
            rewrittenURL = rewrittenURL.substring(contextName.length());
        if (rewrittenURL.startsWith("/" + contextName))
            rewrittenURL = rewrittenURL.substring(contextName.length() + 1);

        // Make sure the index link redirects to '/'

        if (rewrittenURL.equals("/index.html"))
            rewrittenURL = "/";
    } else if (!rewrittenURL.startsWith("/" + contextName))
        rewrittenURL = "/" + contextName + rewrittenURL;

    if (fullUrl) {
        String forwardedFor = request.getHeader("X-Forwarded-Host");

        rewrittenURL = request.getScheme() + "://"
                + (StringUtils.isEmpty(forwardedFor)
                        ? request.getServerName()
                                + (request.getServerPort() != 80 ? ":" + request.getServerPort() : "")
                        : forwardedFor)
                + (rewrittenURL.startsWith("/") ? rewrittenURL : "/" + rewrittenURL);
    }

    return rewrittenURL;
}

From source file:org.eclipse.gyrex.preferences.internal.CloudPreferencesScopeFactory.java

@Override
public IEclipsePreferences create(final IEclipsePreferences parent, final String name) {
    // sanity check
    if (!CloudScope.NAME.equals(name)) {
        LOG.error("Cloud preference factory called with illegal node name {} for parent {}.",
                new Object[] { name, parent.absolutePath(), new Exception("Call Stack") });
        throw new IllegalArgumentException("invalid node name");
    }/*from w w  w.  j a va2  s  .c  om*/

    // allow explicit fallback to instance based preferences
    if (Platform.inDevelopmentMode() && Boolean.getBoolean("gyrex.preferences.instancebased")) {
        LOG.info("Using instance based preferences as specified via system property!");
        return new InstanceBasedPreferences(parent, name);
    }

    // check if already created
    final CloudPreferences node = rootCloudNode.get();
    if (null != node) {
        if (PreferencesDebug.debug) {
            LOG.debug("Cloud preference factory called multiple times for name {} and parent {}.",
                    new Object[] { name, parent.absolutePath(), new Exception("Call Stack") });
        }
        return node;
    }

    if (PreferencesDebug.debug) {
        LOG.debug("Creating ZooKeeper preferences '{}' (parent {})", name, parent);
    }

    // create
    rootCloudNode.compareAndSet(null, new CloudPreferences(parent, name, service));

    // register shut-down hook
    PreferencesActivator.getInstance().addShutdownParticipant(this);

    // done
    return rootCloudNode.get();
}

From source file:springapp.web.LoginController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    logger.debug("login");

    String loginUserName = request.getParameter("username");
    String password = request.getParameter("password");
    String rememberMe = request.getParameter("rememberMe");

    Subject currentUser = SecurityUtils.getSubject();

    if (currentUser == null) {
        logger.debug("currentUser == null");
    } else {/*from  w w  w  .ja va 2  s  . c o  m*/

        logger.debug("currentUser != null");
        logger.debug("currentUser.isAuthenticated() : " + currentUser.isAuthenticated());

    }

    try {

        if (!currentUser.isAuthenticated()) {

            //collect user principals and credentials in a gui specific manner 
            //such as username/password html form, X509 certificate, OpenID, etc.
            //We'll use the username/password example here since it is the most common.
            //(do you know what movie this is from? ;)
            UsernamePasswordToken token = new UsernamePasswordToken(loginUserName, password);
            //this is all you have to do to support 'remember me' (no config - built in!):
            token.setRememberMe(Boolean.getBoolean(rememberMe));

            currentUser.login(token);
            //if no exception, that's it, we're done!
        }

    } catch (UnknownAccountException uae) {
        //username wasn't in the system, show them an error message?
        logger.error("username wasn't in the system");
    } catch (IncorrectCredentialsException ice) {
        //password didn't match, try again?
        logger.error("password didn't match");
    } catch (LockedAccountException lae) {
        //account for that username is locked - can't login.  Show them a message?
        logger.error("account for that username is locked");
    } catch (AuthenticationException ae) {
        //unexpected condition - error?
        logger.error("unexpected condition");
    }

    logger.debug("User [" + currentUser.getPrincipal() + "] logged in successfully.");

    if (currentUser.hasRole("schwartz")) {
        logger.debug("May the Schwartz be with you!");
    } else {
        logger.debug("Hello, mere mortal.");
    }

    if (currentUser.isPermitted("lightsaber:weild")) {
        logger.debug("You may use a lightsaber ring.  Use it wisely.");
    } else {
        logger.debug("Sorry, lightsaber rings are for schwartz masters only.");
    }

    if (currentUser.isPermitted("winnebago:drive:eagle5")) {
        logger.debug("You are permitted to 'drive' the 'winnebago' with license plate (id) 'eagle5'.  "
                + "Here are the keys - have fun!");
    } else {
        logger.debug("Sorry, you aren't allowed to drive the 'eagle5' winnebago!");
    }

    logger.debug("context path:" + request.getContextPath());
    //        return new ModelAndView("hello.jsp");
    return new ModelAndView("/hello.jsp");
}

From source file:org.apache.stratos.common.statistics.publisher.WSO2CEPStatisticsPublisher.java

public WSO2CEPStatisticsPublisher(StreamDefinition streamDefinition) {
    this.streamDefinition = streamDefinition;
    this.ip = System.getProperty("thrift.receiver.ip");
    this.port = System.getProperty("thrift.receiver.port");
    this.username = "admin";
    this.password = "admin";

    enabled = Boolean.getBoolean("cep.stats.publisher.enabled");
    if (enabled) {
        init();//from  w  ww .j ava2  s .  c  o m
    }
}

From source file:io.spring.initializr.web.project.ProjectGenerationSmokeTests.java

@Before
public void setup() throws IOException {
    Assume.assumeTrue("Smoke tests disabled (set System property 'smoke.test')",
            Boolean.getBoolean("smoke.test"));
    this.downloadDir = this.folder.newFolder();
    FirefoxProfile fxProfile = new FirefoxProfile();
    fxProfile.setPreference("browser.download.folderList", 2);
    fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
    fxProfile.setPreference("browser.download.dir", this.downloadDir.getAbsolutePath());
    fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
            "application/zip,application/x-compress,application/octet-stream");
    FirefoxOptions options = new FirefoxOptions().setProfile(fxProfile);
    this.driver = new FirefoxDriver(options);
    ((JavascriptExecutor) this.driver).executeScript("window.focus();");

    Actions actions = new Actions(this.driver);
    this.enterAction = actions.sendKeys(Keys.ENTER).build();
}

From source file:org.gradle.testkit.runner.internal.DefaultGradleRunner.java

DefaultGradleRunner(GradleExecutor gradleExecutor, TestKitDirProvider testKitDirProvider) {
    this.gradleExecutor = gradleExecutor;
    this.testKitDirProvider = testKitDirProvider;
    this.debug = Boolean.getBoolean(DEBUG_SYS_PROP);
}

From source file:org.apache.stratos.haproxy.extension.HAProxyContext.java

private HAProxyContext() {
    this.haProxyPrivateIp = System.getProperty(Constants.HAPROXY_PRIVATE_IP);
    this.executableFilePath = System.getProperty(Constants.EXECUTABLE_FILE_PATH);
    this.templatePath = System.getProperty(Constants.TEMPLATES_PATH);
    this.templateName = System.getProperty(Constants.TEMPLATES_NAME);
    this.scriptsPath = System.getProperty(Constants.SCRIPTS_PATH);
    this.confFilePath = System.getProperty(Constants.CONF_FILE_PATH);
    this.statsSocketFilePath = System.getProperty(Constants.STATS_SOCKET_FILE_PATH);
    this.cepStatsPublisherEnabled = Boolean.getBoolean(Constants.CEP_STATS_PUBLISHER_ENABLED);
    this.thriftReceiverIp = System.getProperty(Constants.THRIFT_RECEIVER_IP);
    this.thriftReceiverPort = System.getProperty(Constants.THRIFT_RECEIVER_PORT);
    this.networkPartitionId = System.getProperty(Constants.NETWORK_PARTITION_ID);

    if (log.isDebugEnabled()) {
        log.debug(Constants.HAPROXY_PRIVATE_IP + " = " + haProxyPrivateIp);
        log.debug(Constants.EXECUTABLE_FILE_PATH + " = " + executableFilePath);
        log.debug(Constants.TEMPLATES_PATH + " = " + templatePath);
        log.debug(Constants.TEMPLATES_NAME + " = " + templateName);
        log.debug(Constants.SCRIPTS_PATH + " = " + scriptsPath);
        log.debug(Constants.CONF_FILE_PATH + " = " + confFilePath);
        log.debug(Constants.STATS_SOCKET_FILE_PATH + " = " + statsSocketFilePath);
        log.debug(Constants.CEP_STATS_PUBLISHER_ENABLED + " = " + cepStatsPublisherEnabled);
        log.debug(Constants.THRIFT_RECEIVER_IP + " = " + thriftReceiverIp);
        log.debug(Constants.THRIFT_RECEIVER_PORT + " = " + thriftReceiverPort);
        log.debug(Constants.NETWORK_PARTITION_ID + " = " + networkPartitionId);
    }/*from   w  ww  . j  a  v a 2 s  .c o m*/
}

From source file:org.springframework.security.core.SpringSecurityCoreVersion.java

/**
 * Disable if springVersion and springSecurityVersion are the same to allow working
 * with Uber Jars./*from  w w  w  . ja  va  2  s  .  c  o m*/
 *
 * @param springVersion
 * @param springSecurityVersion
 * @return
 */
private static boolean disableChecks(String springVersion, String springSecurityVersion) {
    if (springVersion == null || springVersion.equals(springSecurityVersion)) {
        return true;
    }
    return Boolean.getBoolean(DISABLE_CHECKS);
}

From source file:org.wso2.carbon.am.tests.util.APIMgtTestUtil.java

public static APIBean getAPIBeanFromHttpResponse(HttpResponse httpResponse) {
    JSONObject jsonObject = null;//from   w ww.j a va  2 s.c o  m
    String APIName = null;
    String APIProvider = null;
    String APIVersion = null;
    APIBean apiBean = null;
    try {
        jsonObject = new JSONObject(httpResponse.getData());
        APIName = ((JSONObject) jsonObject.get("api")).getString("name");
        APIVersion = ((JSONObject) jsonObject.get("api")).getString("version");
        APIProvider = ((JSONObject) jsonObject.get("api")).getString("provider");
        APIIdentifier identifier = new APIIdentifier(APIProvider, APIName, APIVersion);
        apiBean = new APIBean(identifier);
        apiBean.setContext(((JSONObject) jsonObject.get("api")).getString("context"));
        apiBean.setDescription(((JSONObject) jsonObject.get("api")).getString("description"));
        apiBean.setWsdlUrl(((JSONObject) jsonObject.get("api")).getString("wsdl"));
        apiBean.setTags(((JSONObject) jsonObject.get("api")).getString("tags"));
        apiBean.setAvailableTiers(((JSONObject) jsonObject.get("api")).getString("availableTiers"));
        apiBean.setThumbnailUrl(((JSONObject) jsonObject.get("api")).getString("thumb"));
        apiBean.setSandboxUrl(((JSONObject) jsonObject.get("api")).getString("sandbox"));
        apiBean.setBusinessOwner(((JSONObject) jsonObject.get("api")).getString("bizOwner"));
        apiBean.setBusinessOwnerEmail(((JSONObject) jsonObject.get("api")).getString("bizOwnerMail"));
        apiBean.setTechnicalOwner(((JSONObject) jsonObject.get("api")).getString("techOwner"));
        apiBean.setTechnicalOwnerEmail(((JSONObject) jsonObject.get("api")).getString("techOwnerMail"));
        apiBean.setWadlUrl(((JSONObject) jsonObject.get("api")).getString("wadl"));
        apiBean.setVisibility(((JSONObject) jsonObject.get("api")).getString("visibility"));
        apiBean.setVisibleRoles(((JSONObject) jsonObject.get("api")).getString("roles"));
        apiBean.setEndpointUTUsername(((JSONObject) jsonObject.get("api")).getString("epUsername"));
        apiBean.setEndpointUTPassword(((JSONObject) jsonObject.get("api")).getString("epPassword"));
        apiBean.setEndpointSecured(
                (Boolean.getBoolean(((JSONObject) jsonObject.get("api")).getString("endpointTypeSecured"))));
        apiBean.setTransports(((JSONObject) jsonObject.get("api")).getString("transport_http"));
        apiBean.setTransports(((JSONObject) jsonObject.get("api")).getString("transport_https"));
        apiBean.setInSequence(((JSONObject) jsonObject.get("api")).getString("inSequence"));
        apiBean.setOutSequence(((JSONObject) jsonObject.get("api")).getString("outSequence"));
        apiBean.setAvailableTiers(((JSONObject) jsonObject.get("api")).getString("availableTiersDisplayNames"));
        //-----------Here are some of unused properties, if we need to use them add params to APIBean class
        //((JSONObject) jsonObject.get("api")).getString("name");
        //((JSONObject) jsonObject.get("api")).getString("endpoint");
        //((JSONObject) jsonObject.get("api")).getString("subscriptionAvailability");
        //((JSONObject) jsonObject.get("api")).getString("subscriptionTenants");
        //((JSONObject) jsonObject.get("api")).getString("endpointConfig");
        //((JSONObject) jsonObject.get("api")).getString("responseCache");
        //(((JSONObject) jsonObject.get("api")).getString("cacheTimeout");
        //((JSONObject) jsonObject.get("api")).getString("endpointConfig");
        //((JSONObject) jsonObject.get("api")).getString("version");
        //((JSONObject) jsonObject.get("api")).getString("apiStores");
        // ((JSONObject) jsonObject.get("api")).getString("provider");
        //)((JSONObject) jsonObject.get("api")).getString("tierDescs");
        //((JSONObject) jsonObject.get("api")).getString("subs");
        //((JSONObject) jsonObject.get("api")).getString("context");
        // apiBean.setLastUpdated(Date.parse((JSONObject); jsonObject.get("api")).getString("lastUpdated")));
        // apiBean.setUriTemplates((JSONObject) jsonObject.get("api")).getString("templates"));
    } catch (JSONException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }
    return apiBean;
}

From source file:org.talend.commons.utils.network.NetworkUtil.java

public static void loadAuthenticator() {
    // get parameter from System.properties.
    if (Boolean.getBoolean("http.proxySet")) {//$NON-NLS-1$
        // authentification for the url by using username and password
        Authenticator.setDefault(new Authenticator() {

            @Override// w ww  . ja  v  a 2  s.c o m
            protected PasswordAuthentication getPasswordAuthentication() {
                String httpProxyUser = System.getProperty("http.proxyUser"); //$NON-NLS-1$
                String httpProxyPassword = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
                String httpsProxyUser = System.getProperty("https.proxyUser"); //$NON-NLS-1$
                String httpsProxyPassword = System.getProperty("https.proxyPassword"); //$NON-NLS-1$
                String proxyUser = null;
                char[] proxyPassword = new char[0];
                if (StringUtils.isNotEmpty(httpProxyUser)) {
                    proxyUser = httpProxyUser;
                    if (StringUtils.isNotEmpty(httpProxyPassword)) {
                        proxyPassword = httpProxyPassword.toCharArray();
                    }
                } else if (StringUtils.isNotEmpty(httpsProxyUser)) {
                    proxyUser = httpsProxyUser;
                    if (StringUtils.isNotEmpty(httpsProxyPassword)) {
                        proxyPassword = httpsProxyPassword.toCharArray();
                    }
                }
                return new PasswordAuthentication(proxyUser, proxyPassword);
            }

        });
    } else {
        Authenticator.setDefault(null);
    }
}