Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsPanel.java

@Override
public void actionPerformed(ActionEvent e) {

    /*//from   w  w w.jav  a  2  s .  co m
     * if Plot Chart JButton is clicked, we check which attributes are
     * checked by the user and store their names in a String array and then
     * generate a chart of the checked attributes using a class
     * GenerateChart.
     */
    checkedAttributes = new ArrayList<String>();
    edgeCheckedAttributes = new ArrayList<String>();
    if (e.getSource() == plotChartButton) {
        for (int i = 0; i < attributesTable.getRowCount(); i++) {

            if (attributesTable.getValueAt(i, 1).equals(new Boolean(true))) {
                checkedAttributes.add(attributesTable.getValueAt(i, 0).toString());
            }

        }
        for (int i = 0; i < edgeAttributesTable.getRowCount(); i++) {

            if (edgeAttributesTable.getValueAt(i, 1).equals(new Boolean(true))) {
                edgeCheckedAttributes.add(edgeAttributesTable.getValueAt(i, 0).toString());
            }

        }
        List<CyNode> selectedNodes = CyTableUtil.getNodesInState(dynamicNetwork.getNetwork(), "selected", true);
        List<CyEdge> selectedEdges = CyTableUtil.getEdgesInState(dynamicNetwork.getNetwork(), "selected", true);

        if (checkedAttributes.isEmpty() && edgeCheckedAttributes.isEmpty())
            JOptionPane.showMessageDialog(null,
                    "Please select a node/edge attribute from the table and then try to plot!");
        else if (selectedNodes.isEmpty() && !checkedAttributes.isEmpty())
            JOptionPane.showMessageDialog(null,
                    "You checked a node attribute. Please select a node to get the plot!");
        else if (selectedEdges.isEmpty() && !edgeCheckedAttributes.isEmpty())
            JOptionPane.showMessageDialog(null,
                    "You checked an edge attribute. Please select an edge to get the plot!");

        else {
            GenerateChart<T> chartGenerator = new GenerateChart<T>(this.dynamicNetwork, checkedAttributes,
                    edgeCheckedAttributes, selectedNodes, selectedEdges);
            JFreeChart timeSeries = chartGenerator.generateTimeSeries();
            XYSeriesCollection dataset = chartGenerator.getDataset();
            GraphMetricsResultsPanel<T, C> resultsPanel = new GraphMetricsResultsPanel<T, C>(timeSeries,
                    cyactivator, dataset, dynamicNetwork);
            cyactivator.getCyServiceRegistrar().registerService(resultsPanel, CytoPanelComponent.class,
                    new Properties());

            cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).setState(CytoPanelState.DOCK);
            cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).setSelectedIndex(cyactivator
                    .getCySwingAppication().getCytoPanel(CytoPanelName.EAST).indexOfComponent(resultsPanel));
        }
    }

    if (e.getSource() == closeTab) {

        cyactivator.getCyServiceRegistrar().unregisterService(
                /*cyactivator.getCySwingAppication().getCytoPanel(CytoPanelName.EAST).getSelectedComponent()*/this,
                CytoPanelComponent.class);
    }
}

From source file:com.google.gsa.valve.rootAuth.RootAuthenticationProcess.java

/**
 * This is the main method that drives the whole authentication 
 * process. It launches each individual authentication method declared in 
 * the configuration files. Those that includes the tag "checkauthN" set to 
 * false are not processed.//from   w  ww .  j  a  v a  2 s.  c  om
 * <p>
 * The name of the authentication classes that need to be processed are included 
 * in a vector that is reused multiple times. Whenever a new authentication 
 * process needs to be relaunched, all these classes are processed and the 
 * individual authentication process is treated.
 * <p>
 * It returns the HTTP error code associated to the process result. If it was 
 * OK, this methods returns a 200 and 401 (unauthorized) otherwise.
 * <p>
 * There is a special repository named "root" that is treatly in a special way. 
 * If any repository is named as "root", it means this is the main authentication 
 * mechanim and that's why it's trated first. If it fails, the authentication 
 * process stops here and the return result is an error. If not, the whole 
 * processing continues.
 * <p>
 * If there is a "root" repository and the authentication process for this 
 * repository is OK, although any other repository would fail, the overall 
 * authentication method returns an OK. If there is not such a "root" 
 * repository, any authentication error will cause the authentication process 
 * to fail.
 * 
 * @param request HTTP request
 * @param response HTTP response
 * @param authCookies vector that contains the authentication cookies
 * @param url the document url
 * @param creds an array of credentials for all external sources
 * @param id the default credential id to be retrieved from creds
        
 * @return the HTTP error code
        
 * @throws HttpException
 * @throws IOException
 */
public int authenticate(HttpServletRequest request, HttpServletResponse response, Vector<Cookie> authCookies,
        String url, Credentials creds, String id) throws HttpException, IOException {

    // Initialize status code
    int rootStatusCode = HttpServletResponse.SC_UNAUTHORIZED;
    int repositoryAuthStatusCode = HttpServletResponse.SC_UNAUTHORIZED;
    //Check if authn is Ok in multiple repository
    boolean repositoryOKAuthN = false;

    //clear authCookies
    authCookies.clear();

    boolean rootAuthNDefined = false;
    logger.debug("AuthN authenticate [" + url + "]");

    //Read vars
    if (valveConf != null) {
        isKerberos = new Boolean(valveConf.getKrbConfig().isKerberos()).booleanValue();
        if (isKerberos) {
            isNegotiate = new Boolean(valveConf.getKrbConfig().isNegotiate()).booleanValue();
        }
        loginUrl = valveConf.getLoginUrl();
    } else {
        logger.error("Configuration error: Config file is not present");
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "Configuration error - Kerberos is not set properly");
        return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }

    //ValveHost: it's the same URL as the login page, without 
    String valveHost = loginUrl.substring(0, loginUrl.lastIndexOf("/") + 1);

    RE internal = new RE(valveHost, RE.MATCH_CASEINDEPENDENT);

    // The host and URL of the GSA for the search
    //TODO add support for multiple GSA's
    RE query = new RE("/search", RE.MATCH_CASEINDEPENDENT);

    //Request has come from the same host as the valve, so must be the login authenticate
    if (internal.match(url)) {

        //Authentication vars
        String repositoryID = null;
        AuthenticationProcessImpl authProcess = null;
        ValveRepositoryConfiguration repositoryConfig = null;

        int order = 1;
        int size = authenticationImplementationsOrder.size();
        if (authenticationImplementationsOrder == null) {
            order = 0;
            logger.error(
                    "No Authentication module has been defined. Please check and add those needed at config file");
        }

        while ((1 <= order) && (order <= size)) {

            //Get the repository ID
            logger.debug("###Processing repository # " + order + " ###");
            Integer orderInt = new Integer(order);
            if (authenticationImplementationsOrder.containsKey(orderInt)) {
                repositoryID = authenticationImplementationsOrder.get(orderInt);
            } else {
                logger.error("Error during processing authentication methods. Order is not valid");
                break;
            }

            //Get the Repository config and authentication class                                                    
            authProcess = authenticationImplementations.get(repositoryID);
            repositoryConfig = valveConf.getRepository(repositoryID);

            logger.debug("Authenticating ID: " + repositoryConfig.getId());
            if (repositoryConfig.getId().equals("root")) {
                //Root should be used for main authentication against an identity repository (LDAP, DB, ..)
                //and should not be used as a content repository that contains documents
                try {
                    //add support to cookie array
                    rootAuthCookies.clear();
                    rootStatusCode = authProcess.authenticate(request, response, rootAuthCookies, url, creds,
                            "root");
                    logger.info("Repository authentication - " + repositoryConfig.getId()
                            + " completed. Response was " + rootStatusCode);
                    if (rootStatusCode == HttpServletResponse.SC_UNAUTHORIZED) {
                        logger.error("Root AuthN failed");
                    } else {
                        //Support to cookie array
                        if (rootStatusCode == HttpServletResponse.SC_OK) {
                            logger.debug("Root AuthN is SC_OK (200)");
                            if (!rootAuthCookies.isEmpty()) {
                                logger.debug("Root AuthN returns cookies");
                                for (int j = 0; j < rootAuthCookies.size(); j++) {
                                    logger.debug("Root Cookie found: " + rootAuthCookies.elementAt(j).getName()
                                            + ":" + rootAuthCookies.elementAt(j).getValue());
                                    authCookies.add(rootAuthCookies.elementAt(j));
                                }
                            } else {
                                logger.debug("Root AuthN does NOT return cookies");
                            }
                        }
                    }

                    //If no repository is defined called root then rootStatusCode must be set to OK
                    // This flag is used to indicate that a root repository has been defined.
                    rootAuthNDefined = true;
                    //
                } catch (Exception e) {
                    logger.debug("Exception with authentication for ID: " + repositoryConfig.getId() + " - "
                            + e.getMessage());
                    rootAuthNDefined = true;
                }
            } else {
                try {

                    //add support to cookie array
                    repositoryAuthCookies.clear();

                    logger.debug("Let's do the authentication");

                    repositoryAuthStatusCode = authProcess.authenticate(request, response,
                            repositoryAuthCookies, url, creds, repositoryConfig.getId());

                    //add support to cookie array
                    if (repositoryAuthStatusCode == HttpServletResponse.SC_OK) {
                        logger.debug("Repository AuthN [" + repositoryConfig.getId() + "] is SC_OK (200)");
                        //check if multiple repository is set to valid
                        if (repositoryOKAuthN == false) {
                            repositoryOKAuthN = true;
                        }
                        //check if cookie array is not empty and consume it
                        if (!repositoryAuthCookies.isEmpty()) {
                            logger.debug("Repository AuthN [" + repositoryConfig.getId() + "] returns "
                                    + repositoryAuthCookies.size() + " cookies");
                            for (int j = 0; j < repositoryAuthCookies.size(); j++) {
                                logger.debug("Repository Cookie found: "
                                        + repositoryAuthCookies.elementAt(j).getName() + ":"
                                        + repositoryAuthCookies.elementAt(j).getValue());
                                authCookies.add(repositoryAuthCookies.elementAt(j));
                            }
                        } else {
                            logger.debug("Repository AuthN [" + repositoryConfig.getId()
                                    + "] does NOT return cookies");
                        }
                    }

                    //end Krb support
                    logger.info("Repository authentication - " + repositoryConfig.getId()
                            + " completed. Response was " + repositoryAuthStatusCode);
                } catch (Exception e) {
                    logger.debug("Exception with authentication for ID: " + repositoryConfig.getId() + " - "
                            + e.getMessage());
                }
            }

            //increase order
            order++;
        }
    } else if (query.match(url)) {

        logger.debug("Query pattern [" + url + "]");

        // Don't do anything in here
        rootStatusCode = HttpServletResponse.SC_OK;

    } else {

        logger.error("No pattern defined for URL: " + url + ". It should not have been possible to get here!");

        // Protection
        rootStatusCode = HttpServletResponse.SC_UNAUTHORIZED;

    }

    //add support to multiple repositories
    if ((!rootAuthNDefined) && (repositoryOKAuthN)) {
        //If no root repository has been defined then rootStatusCode has to be set valid, to OK
        rootStatusCode = HttpServletResponse.SC_OK;
    }

    // Return status code
    logger.debug("RootAuthN Complete - Status Code: " + rootStatusCode);

    return rootStatusCode;

}

From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.Cipherer.java

/**
 * Decodes the given content if the booleanValue is "true" (case insensitive). 
 * (Utility Function) /*w  w w  .  ja  v a 2  s  .c  om*/
 * @param content string to be decoded
 * @param booleanValue specifies whether content needs to be decoded
 * @return the decoded content if the booleanValue is "true" (case insensitive). Otherwise it just returns content.
 */
public String decode(String content, Object booleanValue) {
    if ((booleanValue == null) || !(booleanValue instanceof String) || (content == null))
        return content;
    boolean isEncrypted = new Boolean((String) booleanValue).booleanValue();
    if (isEncrypted)
        return decode(content);
    return content;
}

From source file:com.sshtools.common.configuration.SshToolsConnectionProfile.java

/**
 *
 *
 * @param name/*from   w ww  .ja v  a  2 s.c om*/
 * @param defaultValue
 *
 * @return
 */
public boolean getApplicationPropertyBoolean(String name, boolean defaultValue) {
    try {
        return new Boolean(getApplicationProperty(name, String.valueOf(defaultValue))).booleanValue();
    } catch (NumberFormatException nfe) {
        return defaultValue;
    }
}

From source file:net.sf.dynamicreports.adhoc.transformation.XmlToAdhocTransform.java

protected Object propertyStringToValue(String value, String valueClass) {
    if (value == null || StringUtils.isBlank(value) && valueClass == null) {
        return null;
    }//from   ww  w  .  ja  va 2  s. co  m
    if (valueClass == null || valueClass.equals(String.class.getName())) {
        return value;
    }
    if (valueClass.equals(Boolean.class.getName())) {
        return new Boolean(value);
    }
    if (valueClass.equals(Integer.class.getName())) {
        return new Integer(value);
    }
    if (valueClass.equals(AdhocTimePeriod.class.getName())) {
        return AdhocTimePeriod.valueOf(value);
    }
    throw new AdhocException("Property value type " + valueClass + " not supported");
}

From source file:de.ifgi.fmt.web.filter.auth.Authorization.java

/**
 * /*from  w  w w  .j  a v a 2 s. c  om*/
 * @param cr
 * @param sr
 */
public static void deauth(ContainerRequest cr, HttpServletRequest sr) {
    if (sr != null) {
        sr.removeAttribute(USER_SESSION_ATTRIBUTE);
        sr.setAttribute(REMOVE_COOKIE_SESSION_ATTRIBUTE, new Boolean(true));
    }
    if (cr != null) {
        cr.setSecurityContext(new FmtSecurityContext(null));
    }
}

From source file:com.evolveum.midpoint.repo.sql.testing.TestSqlRepositoryFactory.java

private void updateConfigurationBooleanProperty(Configuration configuration, Properties properties,
        String propertyName) {/*from w  w w  .j a va2 s.  c o  m*/
    String value = properties != null ? properties.getProperty(propertyName) : System.getProperty(propertyName);
    if (value == null) {
        return;
    }
    boolean val = new Boolean(value).booleanValue();
    LOGGER.info("Overriding loaded configuration with value read from system properties: {}={}", propertyName,
            val);
    configuration.setProperty(propertyName, val);
}

From source file:com.cloud.consoleproxy.ConsoleProxy.java

public static ConsoleProxyAuthenticationResult authenticateConsoleAccess(ConsoleProxyClientParam param,
        boolean reauthentication) {

    ConsoleProxyAuthenticationResult authResult = new ConsoleProxyAuthenticationResult();
    authResult.setSuccess(true);//from  w  w  w .ja va  2s . co  m
    authResult.setReauthentication(reauthentication);
    authResult.setHost(param.getClientHostAddress());
    authResult.setPort(param.getClientHostPort());

    if (standaloneStart) {
        return authResult;
    }

    if (authMethod != null) {
        Object result;
        try {
            result = authMethod.invoke(ConsoleProxy.context, param.getClientHostAddress(),
                    String.valueOf(param.getClientHostPort()), param.getClientTag(),
                    param.getClientHostPassword(), param.getTicket(), new Boolean(reauthentication));
        } catch (IllegalAccessException e) {
            s_logger.error("Unable to invoke authenticateConsoleAccess due to IllegalAccessException"
                    + " for vm: " + param.getClientTag(), e);
            authResult.setSuccess(false);
            return authResult;
        } catch (InvocationTargetException e) {
            s_logger.error("Unable to invoke authenticateConsoleAccess due to InvocationTargetException "
                    + " for vm: " + param.getClientTag(), e);
            authResult.setSuccess(false);
            return authResult;
        }

        if (result != null && result instanceof String) {
            authResult = new Gson().fromJson((String) result, ConsoleProxyAuthenticationResult.class);
        } else {
            s_logger.error("Invalid authentication return object " + result + " for vm: " + param.getClientTag()
                    + ", decline the access");
            authResult.setSuccess(false);
        }
    } else {
        s_logger.warn(
                "Private channel towards management server is not setup. Switch to offline mode and allow access to vm: "
                        + param.getClientTag());
    }

    return authResult;
}

From source file:com.alkacon.opencms.comments.CmsCommentFormHandler.java

/**
 * Special form output for the comments.<p>
 * /*from   w  ww  .j  a  va2s  .  c o  m*/
 * @see com.alkacon.opencms.formgenerator.CmsFormHandler#createForm()
 */
@Override
public void createForm() throws IOException {

    // the output writer
    Writer out = getJspContext().getOut();

    // check the template group syntax and show eventual errors
    out.write(buildTemplateGroupCheckHtml());

    boolean showForm = showForm();
    if (!showForm) {
        // form has been submitted with correct values
        // try to send a notification email with the submitted form field values
        if (sendData()) {
            // successfully submitted
            if (getFormConfirmationText().equals("")) {
                // and no confirmation required
                out.write("ok");
                return;
            }
            // confirmation output
            StringTemplate sTemplate = getOutputTemplate("confirmationoutput");
            sTemplate.setAttribute("formconfig", getCommentFormConfiguration());
            sTemplate.setAttribute("closebutton", getMessages().key("form.button.close"));
            out.write(sTemplate.toString());
        } else {
            // problem while submitting
            StringTemplate sTemplate = getOutputTemplate("emailerror");
            sTemplate.setAttribute("headline", getMessages().key("form.error.mail.headline"));
            sTemplate.setAttribute("text", getMessages().key("form.error.mail.text"));
            sTemplate.setAttribute("error", getErrors().get("sendmail"));
            out.write(sTemplate.toString());
        }
        return;
    }

    // create the form
    out.write(buildFormHtml());

    // add additional JS
    StringTemplate sTemplate = getOutputTemplate("formscript");
    sTemplate.setAttribute("formlink",
            link("/system/modules/com.alkacon.opencms.comments/elements/comment_form.jsp"));
    sTemplate.setAttribute("isguest", new Boolean(getRequestContext().currentUser().isGuestUser()));
    sTemplate.setAttribute("username", ("" + getRequestContext().currentUser().getFirstname() + " "
            + getRequestContext().currentUser().getLastname()).trim());
    sTemplate.setAttribute("useremail", getRequestContext().currentUser().getEmail());
    sTemplate.setAttribute("namefield", getCommentFormConfiguration().getFieldByDbLabel("name"));
    sTemplate.setAttribute("emailfield", getCommentFormConfiguration().getFieldByDbLabel("email"));
    sTemplate.setAttribute("commentfield", getCommentFormConfiguration().getFieldByDbLabel("comment"));
    sTemplate.setAttribute("charleft", getMessages().key("form.comment.char.left"));
    out.write(sTemplate.toString());
}

From source file:dbseer.gui.user.DBSeerDataSet.java

public DBSeerDataSet() {
    live = new Boolean(false);
    Boolean[] trueFalse = { Boolean.TRUE, Boolean.FALSE };
    JComboBox trueFalseBox = new JComboBox(trueFalse);
    final DefaultCellEditor dce = new DefaultCellEditor(trueFalseBox);

    uniqueVariableName = "dataset_" + UUID.randomUUID().toString().replace('-', '_');
    uniqueModelVariableName = "mv_" + UUID.randomUUID().toString().replace('-', '_');
    name = "Unnamed dataset";
    tableModel = new DBSeerDataSetTableModel(null, new String[] { "Name", "Value" }, true);
    tableModel.addTableModelListener(this);
    table = new JTable(tableModel) {
        @Override//from  w  w w  . j  ava 2 s  .  c  o  m
        public TableCellEditor getCellEditor(int row, int col) {
            if ((row == DBSeerDataSet.TYPE_USE_ENTIRE_DATASET
                    || row > TYPE_NUM_TRANSACTION_TYPE + numTransactionTypes) && col == 1)
                return dce;
            return super.getCellEditor(row, col);
        }
    };
    DefaultTableCellRenderer customRenderder = new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable jTable, Object o, boolean b, boolean b2, int row,
                int col) {
            Component cell = super.getTableCellRendererComponent(jTable, o, b, b2, row, col);
            if (row == DBSeerDataSet.TYPE_START_INDEX || row == DBSeerDataSet.TYPE_END_INDEX) {
                if (((Boolean) table.getValueAt(DBSeerDataSet.TYPE_USE_ENTIRE_DATASET, 1))
                        .booleanValue() == true) {
                    cell.setForeground(Color.LIGHT_GRAY);
                } else {
                    cell.setForeground(Color.BLACK);
                }
            } else if (row == DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE) {
                cell.setForeground(Color.LIGHT_GRAY);
            } else {
                cell.setForeground(Color.BLACK);
            }
            return cell;
        }
    };
    table.getColumnModel().getColumn(0).setCellRenderer(customRenderder);
    table.getColumnModel().getColumn(1).setCellRenderer(customRenderder);

    table.setFillsViewportHeight(true);
    table.getColumnModel().getColumn(0).setMaxWidth(400);
    table.getColumnModel().getColumn(0).setPreferredWidth(300);
    table.getColumnModel().getColumn(1).setPreferredWidth(600);
    table.setRowHeight(20);

    this.useEntireDataSet = true;
    for (String header : tableHeaders) {
        if (header.equalsIgnoreCase("Use Entire DataSet"))
            tableModel.addRow(new Object[] { header, Boolean.TRUE });
        else
            tableModel.addRow(new Object[] { header, "" });
    }

    for (int i = 0; i < numTransactionTypes; ++i) {
        tableModel.addRow(new Object[] { "Name of Transaction Type " + (i + 1), "Type " + (i + 1) });
        DBSeerTransactionType type = new DBSeerTransactionType("Type " + (i + 1), true);
        transactionTypes.add(type);
    }

    for (int i = 0; i < transactionTypes.size(); ++i) {
        DBSeerTransactionType txType = transactionTypes.get(i);
        if (txType.isEnabled()) {
            tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.TRUE });
        } else {
            tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.FALSE });
        }
    }

    this.updateTable();
    dataSetLoaded = false;
    isCurrent = false;

    tableModel.setUseEntireDataSet(this.useEntireDataSet.booleanValue());
}