Example usage for java.lang String equalsIgnoreCase

List of usage examples for java.lang String equalsIgnoreCase

Introduction

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

Prototype

public boolean equalsIgnoreCase(String anotherString) 

Source Link

Document

Compares this String to another String , ignoring case considerations.

Usage

From source file:org.rivetlogic.utils.IntegrationUtils.java

public static Boolean parseBoolean(String pBoolStr) {
    String[] vTrueStrs = new String[] { "1", "t", "y", "true", "yes" };

    Boolean rResult = false;/*from   w w  w.  ja v a 2s  .co  m*/

    for (String vTStr : vTrueStrs) {
        if (vTStr.equalsIgnoreCase(pBoolStr)) {
            rResult = true;
            break;
        }
    }

    return rResult;
}

From source file:com.iaspec.rda.plugins.rfid.license.LicenseReader.java

public static void verifyChallengeCode(String challenge, String expect, Device device) throws RdaException {
    ChallengeVerifier verifier = ChallengeVerifier.getInstance();
    byte[] pkcs7 = Base64.decode(challenge);
    SignatureVerificationResultHolder resultHolder = null;
    try {/*from w  ww .  jav  a 2  s.c  om*/
        resultHolder = verifier.verifySignature(pkcs7);
    } catch (SignatureInvalidException se) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_DECRYPTED_CHALLENGE);
    } catch (CryptoException se) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_DECRYPTED_CHALLENGE);
    }
    CertificateDnInfoDTO certSubjectDn = CertUtil.getCertificateSubjectInfo(resultHolder.signingCertChain[0]);
    // Handle CN checks
    String cn = certSubjectDn.getCn().get(0).toString();

    if (!cn.equalsIgnoreCase(device.getId())) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_LICENSE);
    }

    logger.debug("Signature Verification success: certSubject=["
            + resultHolder.signingCertChain[0].getSubjectDN().toString() + "], orignialContent=["
            + new String(resultHolder.originalData) + "]");

    if (!new String(resultHolder.originalData).equalsIgnoreCase(expect)) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_DECRYPTED_CHALLENGE);
    }

    try {
        KeyStore trustedStore = KeyStore.getInstance("JKS");
        trustedStore.load(null, null);
        // byte[] certBytes = IOUtils.toByteArray(new
        // FileInputStream("RDA_RFID_CA_2.cer")); //false CA certificate

        // byte[] certBytes = IOUtils.toByteArray(new
        // FileInputStream("RDA_RFID_CA.cer"));
        byte[] certBytes = IOUtils.toByteArray(ResourceHelper.readResource("RDA_RFID_CA.cer"));

        // valid CA certificate
        X509Certificate cert = CertUtil.getX509Certificate(certBytes);
        // may add any trusted certificate (CA or Self-signed) to the
        // keystore...
        trustedStore.setCertificateEntry(cert.getSubjectDN().getName().toString(), cert);

        verifier.isCertificateTrust(resultHolder.signingCertChain[0], trustedStore, null);

        // if trusted, do CRL verification if crl can supplied
        /*
         * if
        * (!CertUtil.verifyRevoked(ResourceHelper.readResource("crl.crl"),
        * cert)) { throw new
        * RdaException(ExceptionMessages.EXCEPTION_CERTIFICATE_IS_REVOKED);
        * }
        */

    } catch (com.iaspec.rda.rfid.server.crypto.exception.CertificateNotValidException se) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_LICENSE);
    } catch (CertificateException ce) {
        throw new RdaException(ExceptionMessages.EXCEPTION_INVALID_DECRYPTED_CHALLENGE);
    } catch (RdaException e) {
        throw new RdaException(e.getMessage());
    } catch (Exception e) {
        throw new RdaException(ExceptionMessages.EXCEPTION_SYSTEM);
    }

    logger.debug("The certificate is trusted");
}

From source file:Main.java

public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;/*from www.ja va 2  s  .  c om*/
    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    }
    if (manufacturer.equalsIgnoreCase("HTC")) {
        return "HTC " + model;
    }
    return capitalize(manufacturer) + " " + model;
}

From source file:Main.java

private static boolean checkNameAndNamespace(XMLEvent event, String tagName, String namespace) {
    if (event.isStartElement()) {
        StartElement element = (StartElement) event;
        QName name = element.getName();
        return tagName.equalsIgnoreCase(name.getLocalPart())
                && namespace.equalsIgnoreCase(name.getNamespaceURI());
    } else if (event.isEndElement()) {
        EndElement element = (EndElement) event;
        QName name = element.getName();
        return tagName.equalsIgnoreCase(name.getLocalPart())
                && namespace.equalsIgnoreCase(name.getNamespaceURI());
    }/*from w w  w.  j av  a2 s . c o  m*/

    return false;
}

From source file:Main.java

/**
 * Extract a named node from a list of nodes.
 * Note that if more than one instance of the named node
 * exists, then the returned node will be undefined and could
 * be any of the nodes that match.//  ww w . jav  a 2s.  co m
 *
 * @param nodeList a list of nodes
 * @param nodeName name of the node to extract from the list
 * @return found node or null if not found
 */
public static Node getNodeFromList(final NodeList nodeList, final String nodeName) {

    Node node = null;

    if (nodeList != null) {
        for (int i = 0; i < nodeList.getLength(); i++) {
            if (nodeName.equalsIgnoreCase(nodeList.item(i).getNodeName())) {
                node = nodeList.item(i);
            }
        }
    }

    return node;
}

From source file:com.claresco.tinman.servlet.XapiServletUtility.java

protected static boolean checkAPI(String theAPI, String theSupposedAPI) {
    return theAPI.equalsIgnoreCase(theSupposedAPI);
}

From source file:Main.java

public static String getUriSafeString(Uri uri) {
    final String scheme = uri.getScheme();
    final String ssp = uri.getSchemeSpecificPart();

    if (scheme != null) {
        if (scheme.equalsIgnoreCase("tel") || scheme.equalsIgnoreCase("sip") || scheme.equalsIgnoreCase("sms")
                || scheme.equalsIgnoreCase("smsto") || scheme.equalsIgnoreCase("mailto")) {
            StringBuilder builder = new StringBuilder(64);
            builder.append(scheme);//from w  w w  .  j  a  va2 s . c om
            builder.append(':');

            if (ssp != null) {
                for (int i = 0; i < ssp.length(); i++) {
                    char c = ssp.charAt(i);

                    if (c == '-' || c == '@' || c == '.') {
                        builder.append(c);
                    } else {
                        builder.append('x');
                    }
                }
            }
            return builder.toString();
        }
    }

    StringBuilder builder = new StringBuilder(64);
    if (scheme != null) {
        builder.append(scheme);
        builder.append(':');
    }

    if (ssp != null) {
        builder.append(ssp);
    }
    return builder.toString();
}

From source file:com.omertron.themoviedbapi.tools.MethodBase.java

/**
 * Convert a string into an Enum type//from w w w .j  a v a  2s. co m
 *
 * @param value
 * @return
 */
public static MethodBase fromString(String value) {
    if (StringUtils.isNotBlank(value)) {
        for (final MethodBase method : EnumSet.allOf(MethodBase.class)) {
            if (value.equalsIgnoreCase(method.value)) {
                return method;
            }
        }
    }

    // We've not found the type!
    throw new IllegalArgumentException("Method '" + value + "' not recognised");
}

From source file:com.wso2telco.workflow.utils.WorkflowProperties.java

public static Map<String, String> loadWorkflowPropertiesFromXML() {
    if (propertiesMap == null) {
        try {//  ww  w  .  java2 s.  c o m
            propertiesMap = new HashMap<String, String>();

            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

            String carbonHome = System.getProperty("carbon.home");
            String workflowPropertiesFile = carbonHome + "/repository/conf/"
                    + Constants.WORKFLOW_PROPERTIES_XML_FILE;

            Document document = builder.parse(new File(workflowPropertiesFile));
            Element rootElement = document.getDocumentElement();

            NodeList nodeList = rootElement.getElementsByTagName("Property");
            if (nodeList != null && nodeList.getLength() > 0) {
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    String nodeName = node.getAttributes().getNamedItem("name").getNodeValue();
                    if (nodeName.equalsIgnoreCase(Constants.SERVICE_HOST)
                            || nodeName.equalsIgnoreCase(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_HOST)
                            || nodeName.equalsIgnoreCase(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_ADDRESS)
                            || nodeName
                                    .equalsIgnoreCase(Constants.KEY_WORKFLOW_EMAIL_NOTIFICATION_FROM_PASSWORD)
                            || nodeName.equalsIgnoreCase(Constants.PUBLISHER_ROLE_START_WITH)
                            || nodeName.equalsIgnoreCase(Constants.PUBLISHER_ROLE_END_WITH)
                            || nodeName.equalsIgnoreCase(Constants.MANDATE_SERVICE_HOST)) {
                        String value = ((Element) node).getTextContent();
                        propertiesMap.put(nodeName, value);
                    } else {
                        //Not a matching property
                    }
                }
            }
        } catch (Exception e) {
            String errorMessage = "Error in WorkflowProperties.loadWorkflowPropertiesFromXML";
            log.error(errorMessage, e);
        }
    } else {
        //Return already loaded propertiesMap
    }
    return propertiesMap;
}

From source file:com.moviejukebox.model.enumerations.VideoType.java

/**
 * Convert a string into an Enum type/*from  w  w w . j  ava  2 s  .  co  m*/
 *
 * @param sType
 * @return
 */
public static VideoType fromString(String sType) {
    if (StringUtils.isNotBlank(sType)) {
        for (final VideoType extension : EnumSet.allOf(VideoType.class)) {
            if (sType.equalsIgnoreCase(extension.type)) {
                return extension;
            }
        }
    }
    // We've not found the type, so return both
    return ALL;
}