Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

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

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:com.mpower.daktar.android.tasks.DownloadFormsTask.java

private String downloadManifestAndMediaFiles(final String mediaPath, final FormDetails fd, final int count,
        final int total) {
    if (fd.manifestUrl == null)
        return null;

    publishProgress(MIntel.getInstance().getString(R.string.fetching_manifest, fd.formName),
            Integer.valueOf(count).toString(), Integer.valueOf(total).toString());

    final List<MediaFile> files = new ArrayList<MediaFile>();
    // get shared HttpContext so that authentication and cookies are
    // retained./*w w w. j a v a 2  s  . c o m*/
    final HttpContext localContext = MIntel.getInstance().getHttpContext();

    final HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);

    final DocumentFetchResult result = WebUtils.getXmlDocument(fd.manifestUrl, localContext, httpclient, mAuth);

    if (result.errorMessage != null)
        return result.errorMessage;

    String errMessage = MIntel.getInstance().getString(R.string.access_error, fd.manifestUrl);

    if (!result.isOpenRosaResponse) {
        errMessage += MIntel.getInstance().getString(R.string.manifest_server_error);
        Log.e(t, errMessage);
        return errMessage;
    }

    // Attempt OpenRosa 1.0 parsing
    final Element manifestElement = result.doc.getRootElement();
    if (!manifestElement.getName().equals("manifest")) {
        errMessage += MIntel.getInstance().getString(R.string.root_element_error, manifestElement.getName());
        Log.e(t, errMessage);
        return errMessage;
    }
    final String namespace = manifestElement.getNamespace();
    if (!isXformsManifestNamespacedElement(manifestElement)) {
        errMessage += MIntel.getInstance().getString(R.string.root_namespace_error, namespace);
        Log.e(t, errMessage);
        return errMessage;
    }
    final int nElements = manifestElement.getChildCount();
    for (int i = 0; i < nElements; ++i) {
        if (manifestElement.getType(i) != Node.ELEMENT) {
            // e.g., whitespace (text)
            continue;
        }
        final Element mediaFileElement = manifestElement.getElement(i);
        if (!isXformsManifestNamespacedElement(mediaFileElement)) {
            // someone else's extension?
            continue;
        }
        final String name = mediaFileElement.getName();
        if (name.equalsIgnoreCase("mediaFile")) {
            String filename = null;
            String hash = null;
            String downloadUrl = null;
            // don't process descriptionUrl
            final int childCount = mediaFileElement.getChildCount();
            for (int j = 0; j < childCount; ++j) {
                if (mediaFileElement.getType(j) != Node.ELEMENT) {
                    // e.g., whitespace (text)
                    continue;
                }
                final Element child = mediaFileElement.getElement(j);
                if (!isXformsManifestNamespacedElement(child)) {
                    // someone else's extension?
                    continue;
                }
                final String tag = child.getName();
                if (tag.equals("filename")) {
                    filename = XFormParser.getXMLText(child, true);
                    if (filename != null && filename.length() == 0) {
                        filename = null;
                    }
                } else if (tag.equals("hash")) {
                    hash = XFormParser.getXMLText(child, true);
                    if (hash != null && hash.length() == 0) {
                        hash = null;
                    }
                } else if (tag.equals("downloadUrl")) {
                    downloadUrl = XFormParser.getXMLText(child, true);
                    if (downloadUrl != null && downloadUrl.length() == 0) {
                        downloadUrl = null;
                    }
                }
            }
            if (filename == null || downloadUrl == null || hash == null) {
                errMessage += MIntel.getInstance().getString(R.string.manifest_tag_error, Integer.toString(i));
                Log.e(t, errMessage);
                return errMessage;
            }
            files.add(new MediaFile(filename, hash, downloadUrl));
        }
    }

    // OK we now have the full set of files to download...
    Log.i(t, "Downloading " + files.size() + " media files.");
    int mediaCount = 0;
    if (files.size() > 0) {
        FileUtils.createFolder(mediaPath);
        final File mediaDir = new File(mediaPath);
        for (final MediaFile toDownload : files) {
            if (isCancelled())
                return "cancelled";
            ++mediaCount;
            publishProgress(
                    MIntel.getInstance().getString(R.string.form_download_progress, fd.formName, mediaCount,
                            files.size()),
                    Integer.valueOf(count).toString(), Integer.valueOf(total).toString());
            try {
                final File mediaFile = new File(mediaDir, toDownload.filename);

                final String currentFileHash = FileUtils.getMd5Hash(mediaFile);
                final String downloadFileHash = toDownload.hash.substring(MD5_COLON_PREFIX.length());

                if (!mediaFile.exists()) {
                    downloadFile(mediaFile, toDownload.downloadUrl);
                } else {
                    if (!currentFileHash.contentEquals(downloadFileHash)) {
                        // if the hashes match, it's the same file
                        // otherwise delete our current one and replace it
                        // with the new one
                        mediaFile.delete();
                        downloadFile(mediaFile, toDownload.downloadUrl);
                    } else {
                        // exists, and the hash is the same
                        // no need to download it again
                    }
                }
            } catch (final Exception e) {
                return e.getLocalizedMessage();
            }
        }
    }
    return null;
}

From source file:com.consol.citrus.selenium.client.WebClient.java

/**
 * Wait until an item is loaded.//w  ww .  j  av  a2s.  c  o m
 *
 * @param sec Timeout
 * @return true when the element is invisible.
 */
public String openNewWindow() {
    Set<String> windowHandles = webDriver.getWindowHandles();
    String popupWindowHandle = null;
    String mainWindowHandle = webDriver.getWindowHandle();

    logger.info("Main window handle: " + mainWindowHandle);
    //_logger.info("Window handles found: ");
    for (String wh : windowHandles) {
        //_logger.info(wh);
        if (!wh.contentEquals(mainWindowHandle)) {
            popupWindowHandle = wh;
            logger.info("Popup window handle: " + popupWindowHandle);
        }
    }
    if (org.apache.commons.lang.StringUtils.isNotBlank(popupWindowHandle)) {
        webDriver.switchTo().window(popupWindowHandle);
        logger.info("switched to popup window!");
    }
    return popupWindowHandle;
}

From source file:org.esbtools.message.admin.common.EsbMessageAdminServiceImpl.java

@Override
public MetadataResponse getMetadataTree(MetadataType type) {

    MetadataResponse result;/*  ww  w  .j  a va2 s  .  c  o m*/
    if (type == MetadataType.Entities || type == MetadataType.SearchKeys) {
        String hash = getMetadataHash(type);
        if (treeCache.containsKey(type) && hash.contentEquals(treeCache.get(type).getHash())) {
            return treeCache.get(type);
        } else {
            result = refreshCache(type, hash);
        }
    } else {
        result = new MetadataResponse();
        result.setErrorMessage(ILLEGAL_ARGUMENT + type + ", Expected: Entities or SearchKeys");
    }
    return result;
}

From source file:com.kasungunathilaka.sarigama.ui.HomeActivity.java

protected void setFragment(Fragment fragment) {

    String backStateName = fragment.getClass().getName();
    String fragmentTag = backStateName;

    android.support.v4.app.FragmentManager manager = getSupportFragmentManager();

    boolean fragmentPopped = manager.popBackStackImmediate(backStateName, 0);
    if (!fragmentPopped && manager.findFragmentByTag(fragmentTag) == null) { //fragment not in back stack, create it.
        android.support.v4.app.FragmentTransaction ft = manager.beginTransaction();
        if (backStateName.contentEquals(PlayerFragment.class.getName())) {
            ft.setCustomAnimations(R.anim.slide_in_below, R.anim.slide_out_top, R.anim.slide_in_top,
                    R.anim.slide_out_below);
        } else if (backStateName.contentEquals(MainFragment.class.getName())) {
            ft.setCustomAnimations(android.R.anim.fade_in, R.anim.slide_out_right);
        } else if (backStateName.contentEquals(ConnectionFailFragment.class.getName())) {
            ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
        } else {/*from w ww. jav  a 2  s  . c  o m*/
            ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left,
                    R.anim.slide_out_right);
        }
        ft.replace(R.id.fragment_layout, fragment, fragmentTag);
        if (!backStateName.contentEquals(MainFragment.class.getName())) {
            ft.addToBackStack(backStateName);
        }
        ft.commit();
    }
}

From source file:de.enlightened.peris.IntroScreen.java

private void renameServer(final Server server) {

    String oldName = server.serverName;

    if (oldName.contentEquals("0")) {
        oldName = server.getUrlString();
    }// w  ww  . j  a  v a  2  s. c  o m

    final EditText input = new EditText(this);
    input.setText(oldName);

    new AlertDialog.Builder(this).setTitle("Rename Server")
            .setMessage("Choose a new display name for this server.").setView(input)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {

                @SuppressWarnings("checkstyle:requirethis")
                public void onClick(final DialogInterface dialog, final int whichButton) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            final String trimmedName = input.getText().toString().trim();
                            if (trimmedName.length() > 0) {
                                server.serverName = trimmedName;
                                ServerRepository.update(dbHelper.getWritableDatabase(), server);
                                refreshList();
                            }
                        }
                    });
                    dialog.dismiss();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int whichButton) {
                    // Do nothing.
                }
            }).show();
}

From source file:com.cloud.hypervisor.ovm3.resources.helpers.Ovm3HypervisorSupport.java

/**
 * CheckHealthAnwer: Check the health of an agent on the hypervisor.
 * TODO: should elaborate here with checks...
 *
 * @param cmd/*from   www  . j a  v a2  s . c o m*/
 * @return
 */
public CheckHealthAnswer execute(CheckHealthCommand cmd) {
    Common test = new Common(c);
    String ping = "put";
    String pong;
    try {
        pong = test.echo(ping);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("CheckHealth went wrong: " + config.getAgentHostname() + ", " + e.getMessage(), e);
        return new CheckHealthAnswer(cmd, false);
    }
    if (ping.contentEquals(pong)) {
        return new CheckHealthAnswer(cmd, true);
    }
    LOGGER.debug(
            "CheckHealth did not receive " + ping + " but got " + pong + " from " + config.getAgentHostname());
    return new CheckHealthAnswer(cmd, false);
}

From source file:com.radicaldynamic.groupinform.tasks.DownloadFormsTask.java

private String downloadManifestAndMediaFiles(String mediaPath, FormDetails fd, int count, int total) {
    if (fd.manifestUrl == null)
        return null;

    publishProgress(Collect.getInstance().getString(R.string.fetching_manifest, fd.formName),
            Integer.valueOf(count).toString(), Integer.valueOf(total).toString());

    List<MediaFile> files = new ArrayList<MediaFile>();
    // get shared HttpContext so that authentication and cookies are retained.
    HttpContext localContext = Collect.getInstance().getHttpContext();

    HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);

    DocumentFetchResult result = WebUtils.getXmlDocument(fd.manifestUrl, localContext, httpclient, mAuth);

    if (result.errorMessage != null) {
        return result.errorMessage;
    }//w w w .  j a va 2 s. c o  m

    String errMessage = Collect.getInstance().getString(R.string.access_error, fd.manifestUrl);

    if (!result.isOpenRosaResponse) {
        errMessage += Collect.getInstance().getString(R.string.manifest_server_error);
        Log.e(t, errMessage);
        return errMessage;
    }

    // Attempt OpenRosa 1.0 parsing
    Element manifestElement = result.doc.getRootElement();
    if (!manifestElement.getName().equals("manifest")) {
        errMessage += Collect.getInstance().getString(R.string.root_element_error, manifestElement.getName());
        Log.e(t, errMessage);
        return errMessage;
    }
    String namespace = manifestElement.getNamespace();
    if (!isXformsManifestNamespacedElement(manifestElement)) {
        errMessage += Collect.getInstance().getString(R.string.root_namespace_error, namespace);
        Log.e(t, errMessage);
        return errMessage;
    }
    int nElements = manifestElement.getChildCount();
    for (int i = 0; i < nElements; ++i) {
        if (manifestElement.getType(i) != Element.ELEMENT) {
            // e.g., whitespace (text)
            continue;
        }
        Element mediaFileElement = (Element) manifestElement.getElement(i);
        if (!isXformsManifestNamespacedElement(mediaFileElement)) {
            // someone else's extension?
            continue;
        }
        String name = mediaFileElement.getName();
        if (name.equalsIgnoreCase("mediaFile")) {
            String filename = null;
            String hash = null;
            String downloadUrl = null;
            // don't process descriptionUrl
            int childCount = mediaFileElement.getChildCount();
            for (int j = 0; j < childCount; ++j) {
                if (mediaFileElement.getType(j) != Element.ELEMENT) {
                    // e.g., whitespace (text)
                    continue;
                }
                Element child = mediaFileElement.getElement(j);
                if (!isXformsManifestNamespacedElement(child)) {
                    // someone else's extension?
                    continue;
                }
                String tag = child.getName();
                if (tag.equals("filename")) {
                    filename = XFormParser.getXMLText(child, true);
                    if (filename != null && filename.length() == 0) {
                        filename = null;
                    }
                } else if (tag.equals("hash")) {
                    hash = XFormParser.getXMLText(child, true);
                    if (hash != null && hash.length() == 0) {
                        hash = null;
                    }
                } else if (tag.equals("downloadUrl")) {
                    downloadUrl = XFormParser.getXMLText(child, true);
                    if (downloadUrl != null && downloadUrl.length() == 0) {
                        downloadUrl = null;
                    }
                }
            }
            if (filename == null || downloadUrl == null || hash == null) {
                errMessage += Collect.getInstance().getString(R.string.manifest_tag_error, Integer.toString(i));
                Log.e(t, errMessage);
                return errMessage;
            }
            files.add(new MediaFile(filename, hash, downloadUrl));
        }
    }

    // OK we now have the full set of files to download...
    Log.i(t, "Downloading " + files.size() + " media files.");
    int mediaCount = 0;
    if (files.size() > 0) {
        FileUtils.createFolder(mediaPath);
        File mediaDir = new File(mediaPath);
        for (MediaFile toDownload : files) {
            if (isCancelled()) {
                return "cancelled";
            }
            ++mediaCount;
            publishProgress(
                    Collect.getInstance().getString(R.string.form_download_progress, fd.formName, mediaCount,
                            files.size()),
                    Integer.valueOf(count).toString(), Integer.valueOf(total).toString());
            try {
                File mediaFile = new File(mediaDir, toDownload.filename);

                String currentFileHash = FileUtils.getMd5Hash(mediaFile);
                String downloadFileHash = toDownload.hash.substring(MD5_COLON_PREFIX.length());

                if (!mediaFile.exists()) {
                    downloadFile(mediaFile, toDownload.downloadUrl);
                } else {
                    if (!currentFileHash.contentEquals(downloadFileHash)) {
                        // if the hashes match, it's the same file
                        // otherwise delete our current one and replace it with the new one
                        mediaFile.delete();
                        downloadFile(mediaFile, toDownload.downloadUrl);
                    } else {
                        // exists, and the hash is the same
                        // no need to download it again
                    }
                }
            } catch (Exception e) {
                return e.getLocalizedMessage();
            }
        }
    }
    return null;
}

From source file:com.forum.fiend.osp.SettingsFragment.java

private void juiceUpMenu() {
    setupUserCard();/*from w  w  w  .j  av  a 2  s . c om*/

    if (getActivity() == null) {
        return;
    }

    lvMain = (ListView) getActivity().findViewById(R.id.settings_list);
    lvMain.setDivider(null);

    Bundle bundle = getArguments();

    if (bundle.containsKey("background")) {
        background = bundle.getString("background");
    }

    server_address = application.getSession().getServer().serverAddress;

    if (getString(R.string.server_location).contentEquals("0")) {
        storagePrefix = server_address + "_";
    }

    String userid = application.getSession().getServer().serverUserId;

    settingsOptions = new ArrayList<Setting>();

    if (userid.contentEquals("0")) {
        //To be implemented in future!
        //settingsOptions.add("Login");
    } else {

        Setting sInbox = new Setting();
        sInbox.settingName = "Inbox";
        sInbox.settingIcon = R.drawable.drawer_inbox;
        sInbox.counterItem = unreadMail;

        settingsOptions.add(sInbox);

    }

    Setting sIndex = new Setting();
    sIndex.settingName = "Forum Index";
    sIndex.settingIcon = R.drawable.drawer_index;

    settingsOptions.add(sIndex);

    if (userid.contentEquals("0")) {
        //To be implemented in future!
        //settingsOptions.add("Login");
    } else {

        Setting sTimeline = new Setting();
        sTimeline.settingName = "Timeline";
        sTimeline.settingIcon = R.drawable.drawer_timeline;

        Setting sFavs = new Setting();
        sFavs.settingName = "Favorites";
        sFavs.settingIcon = R.drawable.drawer_favorites;

        Setting sUnread = new Setting();
        sUnread.settingName = "Unread Topics";
        sUnread.settingIcon = R.drawable.drawer_unread;

        Setting sParticipated = new Setting();
        sParticipated.settingName = "Participated Topics";
        sParticipated.settingIcon = R.drawable.drawer_participated;

        Setting sSubscribed = new Setting();
        sSubscribed.settingName = "Subscribed Topics";
        sSubscribed.settingIcon = R.drawable.drawer_subscribed;

        settingsOptions.add(sTimeline);
        settingsOptions.add(sFavs);
        settingsOptions.add(sUnread);
        settingsOptions.add(sParticipated);
        settingsOptions.add(sSubscribed);

        //Setting sProfile = new Setting();
        //sProfile.settingName = "My Profile";
        //sProfile.settingIcon = R.drawable.drawer_favorites;

        //settingsOptions.add(sProfile);

    }

    Setting sSettings = new Setting();
    sSettings.settingName = "Settings";
    sSettings.settingIcon = R.drawable.drawer_settings;

    settingsOptions.add(sSettings);

    if (getString(R.string.server_location).contentEquals("0")) {

        Setting sClose = new Setting();
        sClose.settingName = "Close Forum";
        sClose.settingIcon = R.drawable.drawer_close_forum;

        settingsOptions.add(sClose);
    }

    lvMain.setAdapter(new SettingsAdapter(settingsOptions, getActivity()));

    lvMain.setTextFilterEnabled(true);

    lvMain.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (settingsOptions == null) {
                return;
            }

            String the_result = settingsOptions.get(position).settingName;

            if (the_result.contentEquals("Unread Topics")) {
                Category ca = new Category();
                ca.category_name = "Unread Topics";
                ca.subforum_id = "0";
                ca.category_id = "unread";
                ca.category_description = "Review all of the topics with posts you haven't seen yet.";
                ca.categoryType = "S";
                ca.categoryColor = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            }

            if (the_result.contentEquals("Participated Topics")) {
                Category ca = new Category();
                ca.category_name = "Participated Topics";
                ca.subforum_id = "0";
                ca.category_id = "participated";
                ca.category_description = "Check out all of the topics that you have participated in.";
                ca.categoryType = "S";
                ca.categoryColor = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            }

            if (the_result.contentEquals("Subscribed Topics")) {
                Category ca = new Category();
                ca.category_name = "Subscribed Topics";
                ca.subforum_id = "0";
                ca.category_id = "favs";
                ca.category_description = "Check out all of your subcriptions!";
                ca.categoryType = "S";
                ca.categoryColor = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            }

            if (the_result.contentEquals("Favorites")) {
                Category ca = new Category();
                ca.category_name = "Favorites";
                ca.subforum_id = "0";
                ca.category_id = "forum_favs";
                ca.category_description = "Your favorite forums.";
                ca.categoryType = "S";
                ca.categoryColor = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            }

            if (the_result.contentEquals("Timeline")) {
                Category ca = new Category();
                ca.category_name = "Timeline";
                ca.subforum_id = "0";
                ca.category_id = "timeline";
                ca.category_description = "The latest posts forum-wide.";
                ca.categoryType = "S";
                ca.categoryColor = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            }

            if (the_result.contentEquals("Make a Donation")) {
                String url = "http://www.ape-apps.com/donation/";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }

            if (the_result.contentEquals("Inbox")) {
                Intent myIntent = new Intent(getActivity(), Mail.class);
                startActivity(myIntent);
            }

            if (the_result.contentEquals("My Profile")) {
                loadMyWall();
            }

            if (the_result.contentEquals("Edit Signature")) {
                taglineEditor();
            }

            if (the_result.contentEquals("Active Users")) {
                launchUsersList();
            }

            if (the_result.contentEquals("Toggle Theme")) {
                theme_changer();
            }

            if (the_result.contentEquals("Change Theme Color")) {
                setAccentColor();
            }

            if (the_result.contentEquals("License Agreement")) {
                Eula.showDisclaimer(getActivity());
            }

            if (the_result.contentEquals("Clear Cache")) {
                clearCache();
            }

            if (the_result.contentEquals("Logout")) {
                doLogout();
            }

            if (the_result.contentEquals("Text Options")) {
                changeTextSettings();
            }

            if (the_result.contentEquals("Close Forum")) {
                getActivity().finish();
            }

            if (the_result.contentEquals("About")) {
                Intent aboutIntent = new Intent(getActivity(), About.class);
                startActivity(aboutIntent);
            }

            if (the_result.contentEquals("Forum Index")) {
                if (indexRequested != null) {
                    indexRequested.onIndexRequested();
                }
            }

            if (the_result.contentEquals("Settings")) {
                if (settingsRequested != null) {
                    settingsRequested.onSettingsRequested();
                }
            }

            if (the_result.contentEquals("The Wiki")) {
                String url = "http://www.discussions-online.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }

            if (the_result.contentEquals("Ape Apps Blog")) {
                String url = "http://www.ape-apps.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }

            if (the_result.contentEquals("Upgrade (Free)")) {
                String url = "http://market.ape-apps.com/app.php?app=1";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        }
    });
}

From source file:com.asakusafw.runtime.io.csv.CsvParser.java

private boolean isHeader() {
    if (forceConsumeHeader) {
        return true;
    }//from   w ww .j a v  a 2  s.c o  m
    if (headerCellsFormat.isEmpty()) {
        return false;
    }
    if (headerCellsFormat.size() != cellBeginPositions.remaining() - 1) {
        return false;
    }
    for (int i = 0, n = headerCellsFormat.size(); i < n; i++) {
        String fieldName = headerCellsFormat.get(i);
        CharSequence fieldValue = lineBuffer.subSequence(cellBeginPositions.get(i),
                cellBeginPositions.get(i + 1));
        if (fieldName.contentEquals(fieldValue) == false) {
            return false;
        }
    }
    return true;
}

From source file:org.warlock.itk.distributionenvelope.Payload.java

/**
 * Handle signed content after decryption. The content is signed and encrypted
 * separately, and when a payload is decrypted it may or may not be signed. This
 * method checks if the payload has been signed: if not it is returned unchanged.
 * If the content has been signed, the signature is verified before the content
 * that was signed, is returned.//from   ww w.j a v  a 2 s  . c  o m
 * @param decrypted Decrypted 
 * @return
 * @throws Exception If the signature verification fails.
 */
private byte[] checkSignature(byte[] decrypted) throws Exception {
    String tryXml = null;
    try {
        tryXml = new String(decrypted);
    } catch (Exception e) {
        return decrypted;
    }
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(tryXml)));
    Element rootElement = doc.getDocumentElement();
    String rname = rootElement.getLocalName();
    if ((rname == null) || !rname.contentEquals("Signature")) {
        return decrypted;
    }
    String rns = rootElement.getNamespaceURI();
    if ((rns == null) || !rns.contentEquals(CfHNamespaceContext.DSNAMESPACE)) {
        return decrypted;
    }
    // We have a signed payload... Verify as an enveloping signature and return
    // the Object if the signature verifies OK.
    //
    verifySignature(rootElement);
    return getSignatureObject(rootElement);
}