Example usage for org.apache.commons.codec.binary Hex encodeHex

List of usage examples for org.apache.commons.codec.binary Hex encodeHex

Introduction

In this page you can find the example usage for org.apache.commons.codec.binary Hex encodeHex.

Prototype

public static char[] encodeHex(byte[] data) 

Source Link

Document

Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.

Usage

From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java

@Override
public void onCacheWordOpened() {
    if (mDoLock) {
        completeShutdown();/* w w w. j  a  v  a 2 s. c o  m*/
        return;
    }

    byte[] encryptionKey = mCacheWord.getEncryptionKey();
    openEncryptedStores(encryptionKey, true);

    // this is no longer configurable
    //  int defaultTimeout = 60 * Integer.parseInt(mPrefs.getString("pref_cacheword_timeout",ImApp.DEFAULT_TIMEOUT_CACHEWORD));
    //  mCacheWord.setTimeoutSeconds(defaultTimeout);
    IocVfs.init(this, new String(Hex.encodeHex(mCacheWord.getEncryptionKey())));
}

From source file:com.krawler.common.util.ByteUtil.java

/**
 * Reads the given <tt>InputStream</tt> in its entirety, closes the
 * stream, and returns the SHA1 digest of the read data.
 * //  w ww  .  jav  a 2  s  .c  om
 * @param in
 *            data to digest
 * @param base64
 *            if <tt>true</tt>, returns as base64 String, otherwise
 *            return as hex string.
 * @return
 */
public static String getSHA1Digest(InputStream in, boolean base64) throws IOException {
    try {
        MessageDigest md = MessageDigest.getInstance("SHA1");
        byte[] buffer = new byte[1024];
        int numBytes;
        while ((numBytes = in.read(buffer)) >= 0) {
            md.update(buffer, 0, numBytes);
        }
        byte[] digest = md.digest();
        in.close();
        if (base64)
            return encodeFSSafeBase64(digest);
        else
            return new String(Hex.encodeHex(digest));
    } catch (NoSuchAlgorithmException e) {
        // this should never happen unless the JDK is foobar
        // e.printStackTrace();
        throw new RuntimeException(e);
    }
}

From source file:ble.AndroidBle.java

@Override
public boolean writeCharacteristic(String address, BleGattCharacteristic characteristic) {
    BluetoothGatt gatt = mBluetoothGatts.get(address);
    if (gatt == null) {
        return false;
    }/*from  w ww. ja va2s .  co  m*/

    Log.d("blelib", new String(Hex.encodeHex(characteristic.getGattCharacteristicA().getValue())));
    return gatt.writeCharacteristic(characteristic.getGattCharacteristicA());
}

From source file:com.xqdev.jam.MLJAM.java

private static String hexEncode(byte[] bytes) {
    return new String(Hex.encodeHex(bytes));
}

From source file:com.aoppp.gatewaysdk.internal.hw.DigestUtils2.java

/**
 * Calculates the SHA-256 digest and returns the value as a hex string.
 * <p>/*  w  w  w.ja v  a2s  . c om*/
 * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0.
 * </p>
 *
 * @param data
 *            Data to digest
 * @return SHA-256 digest as a hex string
 * @since 1.4
 */
public static String sha256Hex(final String data) {
    return new String(Hex.encodeHex(sha256(data)));
}

From source file:com.zimbra.cs.servlet.util.CsrfUtil.java

public static String generateCsrfTokenTest(String accountId, long authTokenExpiration, int tokenSalt,
        String sessionId) throws AuthTokenException {

    StringBuilder encodedBuff = new StringBuilder(64);
    BlobMetaData.encodeMetaData(C_ID, accountId, encodedBuff);
    BlobMetaData.encodeMetaData(C_EXP, Long.toString(authTokenExpiration), encodedBuff);
    BlobMetaData.encodeMetaData(C_SALT_ID, tokenSalt, encodedBuff);

    String data = new String(Hex.encodeHex(encodedBuff.toString().getBytes()));
    CsrfTokenKey key = getCurrentKey();/*from   w ww .  j  a v a 2  s  . c o  m*/
    String hmac = TokenUtil.getHmac(data, key.getKey());
    String encoded = key.getVersion() + "_" + hmac + "_" + data;
    return encoded;

}

From source file:com.krawler.common.util.ByteUtil.java

/**
 * return the MD5 digest of the supplied data.
 * //from  www.j a v  a2  s  . c  o  m
 * @param data
 *            data to digest
 * @param base64
 *            if true, return as base64 String, otherwise return as hex
 *            string.
 * @return
 */
public static String getMD5Digest(byte[] data, boolean base64) {
    try {
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] digest = md.digest(data);
        if (base64)
            return encodeFSSafeBase64(digest);
        else
            return new String(Hex.encodeHex(digest));
    } catch (NoSuchAlgorithmException e) {
        // this should never happen unless the JDK is foobar
        // e.printStackTrace();
        throw new RuntimeException(e);
    }
}

From source file:com.doculibre.constellio.wicket.panels.results.DefaultSearchResultPanel.java

public DefaultSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);//from   w  w  w.  ja va  2 s . c  o m

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
            .getSearchInterfaceConfigServices();

    String collectionName = dataProvider.getSimpleSearch().getCollectionName();

    RecordCollection collection = collectionServices.get(collectionName);
    Record record = recordServices.get(doc);
    if (record != null) {
        SearchInterfaceConfig searchInterfaceConfig = searchInterfaceConfigServices.get();

        IndexField uniqueKeyField = collection.getUniqueKeyIndexField();
        IndexField defaultSearchField = collection.getDefaultSearchIndexField();
        IndexField urlField = collection.getUrlIndexField();
        IndexField titleField = collection.getTitleIndexField();

        if (urlField == null) {
            urlField = uniqueKeyField;
        }
        if (titleField == null) {
            titleField = urlField;
        }

        final String recordURL = record.getUrl();
        final String displayURL;

        if (record.getDisplayUrl().startsWith("/get?file=")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            displayURL = ContextUrlUtils.getContextUrl(req) + record.getDisplayUrl();

        } else {
            displayURL = record.getDisplayUrl();
        }

        String title = record.getDisplayTitle();

        final String protocol = StringUtils.substringBefore(displayURL, ":");
        boolean linkEnabled = isLinkEnabled(protocol);

        // rcupration des champs highlight  partir de la cl unique
        // du document, dans le cas de Nutch c'est l'URL
        QueryResponse response = dataProvider.getQueryResponse();
        Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
        Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

        String titleHighlight = getTitleFromHighlight(titleField.getName(), fieldsHighlighting);
        if (titleHighlight != null) {
            title = titleHighlight;
        }

        String excerpt = null;
        String description = getDescription(record);
        String summary = getSummary(record);

        if (StringUtils.isNotBlank(description) && searchInterfaceConfig.isDescriptionAsExcerpt()) {
            excerpt = description;
        } else {
            excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);
            if (excerpt == null) {
                excerpt = description;
            }
        }

        toggleSummaryLink = new WebMarkupContainer("toggleSummaryLink");
        add(toggleSummaryLink);
        toggleSummaryLink.setVisible(StringUtils.isNotBlank(summary));
        toggleSummaryLink.add(new AttributeModifier("onclick", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                return "toggleSearchResultSummary('" + summaryLabel.getMarkupId() + "')";
            }
        }));

        summaryLabel = new Label("summary", summary);
        add(summaryLabel);
        summaryLabel.setOutputMarkupId(true);
        summaryLabel.setVisible(StringUtils.isNotBlank(summary));

        ExternalLink titleLink;
        if (displayURL.startsWith("file://")) {
            HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
            String newDisplayURL = ContextUrlUtils.getContextUrl(req) + "app/getSmbFile?"
                    + SmbServletPage.RECORD_ID + "=" + record.getId() + "&" + SmbServletPage.COLLECTION + "="
                    + collectionName;
            titleLink = new ExternalLink("titleLink", newDisplayURL);
        } else {
            titleLink = new ExternalLink("titleLink", displayURL);
        }

        final RecordModel recordModel = new RecordModel(record);
        AttributeModifier computeClickAttributeModifier = new AttributeModifier("onmousedown", true,
                new LoadableDetachableModel() {
                    @Override
                    protected Object load() {
                        Record record = recordModel.getObject();
                        SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                        WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                        HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                        return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch,
                                record);
                    }
                });
        titleLink.add(computeClickAttributeModifier);
        titleLink.setEnabled(linkEnabled);

        boolean resultsInNewWindow;
        PageParameters params = RequestCycle.get().getPageParameters();
        if (params != null && params.getString(POPUP_LINK) != null) {
            resultsInNewWindow = params.getBoolean(POPUP_LINK);
        } else {
            resultsInNewWindow = searchInterfaceConfig.isResultsInNewWindow();
        }
        titleLink.add(new SimpleAttributeModifier("target", resultsInNewWindow ? "_blank" : "_self"));

        // Add title
        title = StringUtils.remove(title, "\n");
        title = StringUtils.remove(title, "\r");
        if (StringUtils.isEmpty(title)) {
            title = StringUtils.defaultString(displayURL);
            title = StringUtils.substringAfterLast(title, "/");
            title = StringUtils.substringBefore(title, "?");
            try {
                title = URLDecoder.decode(title, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (title.length() > 120) {
                title = title.substring(0, 120) + " ...";
            }
        }

        Label titleLabel = new Label("title", title);
        titleLink.add(titleLabel.setEscapeModelStrings(false));
        add(titleLink);

        Label excerptLabel = new Label("excerpt", excerpt);
        add(excerptLabel.setEscapeModelStrings(false));
        // add(new ExternalLink("url", url,
        // url).add(computeClickAttributeModifier).setEnabled(linkEnabled));
        if (displayURL.startsWith("file://")) {
            // Creates a Windows path for file URLs
            String urlLabel = StringUtils.substringAfter(displayURL, "file:");
            urlLabel = StringUtils.stripStart(urlLabel, "/");
            urlLabel = "\\\\" + StringUtils.replace(urlLabel, "/", "\\");
            try {
                urlLabel = URLDecoder.decode(urlLabel, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            add(new Label("url", urlLabel));
        } else {
            add(new Label("url", displayURL));
        }

        final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>(
                collection);
        add(new ListView("searchResultFields", new LoadableDetachableModel() {
            @Override
            protected Object load() {
                RecordCollection collection = collectionModel.getObject();
                return collection.getSearchResultFields();
            }

            /**
             * Detaches from the current request. Implement this method with
             * custom behavior, such as setting the model object to null.
             */
            protected void onDetach() {
                recordModel.detach();
                collectionModel.detach();
            }
        }) {
            @Override
            protected void populateItem(ListItem item) {
                SearchResultField searchResultField = (SearchResultField) item.getModelObject();
                IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                Record record = recordModel.getObject();
                IndexField indexField = searchResultField.getIndexField();
                Locale locale = getLocale();
                String indexFieldTitle = indexField.getTitle(locale);
                if (StringUtils.isBlank(indexFieldTitle)) {
                    indexFieldTitle = indexField.getName();
                }
                StringBuffer fieldValueSb = new StringBuffer();
                List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
                Map<String, String> defaultLabelledValues = indexFieldServices
                        .getDefaultLabelledValues(indexField, locale);
                for (Object fieldValue : fieldValues) {
                    if (fieldValueSb.length() > 0) {
                        fieldValueSb.append("\n");
                    }
                    String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale);
                    if (fieldValueLabel == null) {
                        fieldValueLabel = defaultLabelledValues.get("" + fieldValue);
                    }
                    if (fieldValueLabel == null) {
                        fieldValueLabel = "" + fieldValue;
                    }
                    fieldValueSb.append(fieldValueLabel);
                }

                item.add(new Label("indexField", indexFieldTitle));
                item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString()));
                item.setVisible(fieldValueSb.length() > 0);
            }

            @SuppressWarnings("unchecked")
            @Override
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject();
                    visible = !searchResultFields.isEmpty();
                }
                return visible;
            }
        });

        // md5
        ConstellioSession session = ConstellioSession.get();
        ConstellioUser user = session.getUser();
        // TODO Provide access to unauthenticated users ?
        String md5 = "";
        if (user != null) {
            IntelliGIDServiceInfo intelligidServiceInfo = ConstellioSpringUtils.getIntelliGIDServiceInfo();
            if (intelligidServiceInfo != null) {
                Collection<Object> md5Coll = doc.getFieldValues(IndexField.MD5);
                if (md5Coll != null) {
                    for (Object md5Obj : md5Coll) {
                        try {
                            String md5Str = new String(Hex.encodeHex(Base64.decodeBase64(md5Obj.toString())));
                            InputStream is = HttpClientHelper
                                    .get(intelligidServiceInfo.getIntelligidUrl() + "/connector/checksum",
                                            "md5=" + URLEncoder.encode(md5Str, "ISO-8859-1"),
                                            "username=" + URLEncoder.encode(user.getUsername(), "ISO-8859-1"),
                                            "password=" + URLEncoder.encode(Base64.encodeBase64String(
                                                    ConstellioSession.get().getPassword().getBytes())),
                                            "ISO-8859-1");
                            try {
                                Document xmlDocument = new SAXReader().read(is);
                                Element root = xmlDocument.getRootElement();
                                for (Iterator<Element> it = root.elementIterator("fichier"); it.hasNext();) {
                                    Element fichier = it.next();
                                    String url = fichier.attributeValue("url");
                                    md5 += "<a href=\"" + url + "\">" + url + "</a> ";
                                }
                            } finally {
                                IOUtils.closeQuietly(is);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        Label md5Label = new Label("md5", md5) {
            public boolean isVisible() {
                boolean visible = super.isVisible();
                if (visible) {
                    visible = StringUtils.isNotBlank(this.getModelObjectAsString());
                }
                return visible;
            }
        };
        md5Label.setEscapeModelStrings(false);
        add(md5Label);

        add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
    } else {
        setVisible(false);
    }
}

From source file:ca.sqlpower.architect.swingui.enterprise.SecurityPanel.java

private User createUserFromPrompter() {
    JTextField nameField = new JTextField(15);
    JTextField passField = new JPasswordField(15);
    JTextField confirmField = new JPasswordField(15);

    JPanel namePanel = new JPanel(new BorderLayout());
    namePanel.add(new JLabel("User Name"), BorderLayout.WEST);
    namePanel.add(nameField, BorderLayout.EAST);

    JPanel passPanel = new JPanel(new BorderLayout());
    passPanel.add(new JLabel("Password"), BorderLayout.WEST);
    passPanel.add(passField, BorderLayout.EAST);

    JPanel confirmPanel = new JPanel(new BorderLayout());
    confirmPanel.add(new JLabel("Confirm Password"), BorderLayout.WEST);
    confirmPanel.add(confirmField, BorderLayout.EAST);

    Object[] messages = new Object[] { "Specify the User's Name and Password.", namePanel, passPanel,
            confirmPanel };//from w w w . j a  v a  2s. c o  m

    String[] options = { "OK", "Cancel", };
    int option = JOptionPane.showOptionDialog(getPanel(), messages, "Specify the User's Name and Password",
            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);

    if (nameField.getText().equals("") || nameField.getText() == null || passField.getText().equals("")
            || passField.getText() == null) {
        return null;
    }

    if (!passField.getText().equals(confirmField.getText())) {
        JOptionPane.showMessageDialog(getPanel(), "The passwords you entered do not match.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }

    User user = null;
    if (option == 0) {
        String password;
        try {
            password = new String(Hex.encodeHex(digester.digest(passField.getText().getBytes("UTF-8"))));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Unable to encode password", e);
        }
        user = new User(nameField.getText(), password);
    }

    return user;
}

From source file:com.konakart.bl.modules.payment.cyberpac.Cyberpac.java

/**
 * Return a payment details object for Cyberpac
 * /*w  w  w  . ja  v a  2 s  .c  o  m*/
 * @param order
 * @param info
 * @return Returns information in a PaymentDetails object
 * @throws Exception
 */
public PaymentDetails getPaymentDetails(Order order, PaymentInfo info) throws Exception {
    StaticData sd = staticDataHM.get(getStoreId());
    /*
     * The CyberpacZone zone, if greater than zero, should reference a GeoZone. If the
     * DeliveryAddress of the order isn't within that GeoZone, then we throw an exception
     */
    if (sd.getZone() > 0) {
        checkZone(info, sd.getZone());
    }

    // Get the scale for currency calculations
    int scale = new Integer(order.getCurrency().getDecimalPlaces()).intValue();

    // Get the resource bundle
    ResourceBundle rb = getResourceBundle(mutex, bundleName, resourceBundleMap, info.getLocale());
    if (rb == null) {
        throw new KKException(
                "A resource file cannot be found for the country " + info.getLocale().getCountry());
    }

    PaymentDetails pDetails = new PaymentDetails();
    pDetails.setCode(code);
    pDetails.setSortOrder(sd.getSortOrder());
    pDetails.setPaymentType(PaymentDetails.BROWSER_PAYMENT_GATEWAY);
    pDetails.setDescription(rb.getString(MODULE_PAYMENT_CYBERPAC_TEXT_DESCRIPTION));
    pDetails.setTitle(rb.getString(MODULE_PAYMENT_CYBERPAC_TEXT_TITLE));

    // Return now if the full payment details aren't required. This happens when the manager
    // just wants a list of payment gateways to display in the UI.
    if (info.isReturnDetails() == false) {
        return pDetails;
    }

    pDetails.setPostOrGet("post");
    pDetails.setRequestUrl(sd.getRequestUrl());

    List<NameValue> parmList = new ArrayList<NameValue>();

    /*
     * Parameters posted to gateway
     */

    // Total
    BigDecimal total = null;
    for (int i = 0; i < order.getOrderTotals().length; i++) {
        OrderTotal ot = (OrderTotal) order.getOrderTotals()[i];
        if (ot.getClassName().equals(OrderTotalMgr.ot_total)) {
            total = ot.getValue().setScale(scale, BigDecimal.ROUND_HALF_UP);
        }
    }
    if (total == null) {
        throw new KKException("An Order Total was not found in the order id = " + order.getId());
    }
    parmList.add(new NameValue("Ds_Merchant_Amount", total.toString()));

    // Currency
    String currCode = null;
    if (order.getCurrency().getCode().equalsIgnoreCase("EUR")) {
        currCode = "978";
    } else if (order.getCurrency().getCode().equalsIgnoreCase("USD")) {
        currCode = "840";
    } else if (order.getCurrency().getCode().equalsIgnoreCase("GBP")) {
        currCode = "826";
    } else if (order.getCurrency().getCode().equalsIgnoreCase("JPY")) {
        currCode = "392";
    } else {
        throw new KKException("The currency with code = " + order.getCurrency().getCode()
                + " is not supported by the Cyberpac payment gateway.");
    }
    String ds_Merchant_Currency = currCode;
    parmList.add(new NameValue("Ds_Merchant_Currency", ds_Merchant_Currency));

    // Various
    String ds_Merchant_Order = Integer.toString(order.getId());
    parmList.add(new NameValue("Ds_Merchant_Order", ds_Merchant_Order));
    parmList.add(new NameValue("Ds_Merchant_ProductDescription",
            rb.getString(MODULE_PAYMENT_CYBERPAC_CUSTOMER_MSG) + " " + order.getId()));
    parmList.add(new NameValue("Ds_Merchant_Cardholder", order.getBillingName()));
    String ds_Merchant_MerchantCode = sd.getMerchantCode();
    parmList.add(new NameValue("Ds_Merchant_MerchantCode", ds_Merchant_MerchantCode));
    parmList.add(new NameValue("Ds_Merchant_MerchantURL", sd.getCallbackUrl()));
    if (sd.getRedirectKOUrl() != null && sd.getRedirectKOUrl().length() > 0) {
        parmList.add(new NameValue("Ds_Merchant_UrlKO", sd.getRedirectKOUrl()));
    }
    if (sd.getRedirectOKUrl() != null && sd.getRedirectOKUrl().length() > 0) {
        parmList.add(new NameValue("Ds_Merchant_UrlOK", sd.getRedirectOKUrl()));
    }

    String lang = "001"; // Default Spanish Castellano
    String langCode = order.getLocale().substring(0, 2);
    if (order.getLocale().equalsIgnoreCase("ca_ES")) {
        lang = "003";
    } else if (langCode.equalsIgnoreCase("en")) {
        lang = "002";
    } else if (langCode.equalsIgnoreCase("fr")) {
        lang = "004";
    } else if (langCode.equalsIgnoreCase("de")) {
        lang = "005";
    } else if (langCode.equalsIgnoreCase("it")) {
        lang = "007";
    } else if (langCode.equalsIgnoreCase("pt")) {
        lang = "009";
    } else if (order.getLocale().equalsIgnoreCase("eu_ES")) {
        lang = "013";
    } else if (langCode.equalsIgnoreCase("ru")) {
        lang = "014";
    }
    parmList.add(new NameValue("Ds_Merchant_ConsumerLanguage", lang));

    parmList.add(new NameValue("Ds_Merchant_Terminal", sd.getTerminalNumber()));

    if (sd.getTransactionType() != null && sd.getTransactionType().length() > 0) {
        parmList.add(new NameValue("Ds_Merchant_TransactionType", sd.getTransactionType()));
    } else {
        parmList.add(new NameValue("Ds_Merchant_TransactionType", "2"));
    }

    // Data passed to us in callback. Need to create a session
    SSOTokenIf ssoToken = new SSOToken();
    String sessionId = getEng().login(sd.getCallbackUsername(), sd.getCallbackPassword());
    if (sessionId == null) {
        throw new KKException(
                "Unable to log into the engine using the Cyberpac Callback Username and Password");
    }
    ssoToken.setSessionId(sessionId);
    ssoToken.setCustom1(String.valueOf(order.getId()));
    // Save the SSOToken with a valid sessionId and the order id in custom1
    String uuid = getEng().saveSSOToken(ssoToken);
    parmList.add(new NameValue("Ds_Merchant_MerchantData", uuid));

    // Sign the data
    // Digest=SHA-1(Ds_Merchant_Amount + Ds_Merchant_Order +Ds_Merchant_MerchantCode
    // + DS_Merchant_Currency + SECRET CODE)
    String ds_Merchant_Amount = (total.multiply(new BigDecimal(100))).toString();
    String stringToSign = ds_Merchant_Amount + ds_Merchant_Order + ds_Merchant_MerchantCode
            + ds_Merchant_Currency + sd.getSecretSigningCode();
    MessageDigest md = MessageDigest.getInstance("SHA-1");
    byte[] digest = md.digest(stringToSign.getBytes("UTF8"));
    String hexEncodedDigest = (Hex.encodeHex(digest)).toString();
    parmList.add(new NameValue("Ds_Merchant_MerchantSignature", hexEncodedDigest));
    if (log.isDebugEnabled()) {
        StringBuffer str = new StringBuffer();
        str.append("Parameters to sign:").append("\n");
        str.append("Ds_Merchant_Amount        = ").append(ds_Merchant_Amount).append("\n");
        str.append("Ds_Merchant_Order         = ").append(ds_Merchant_Order).append("\n");
        str.append("Ds_Merchant_MerchantCode  = ").append(ds_Merchant_MerchantCode).append("\n");
        str.append("Ds_Merchant_Currency      = ").append(ds_Merchant_Currency).append("\n");
        str.append("Secret Code               = ").append(sd.getSecretSigningCode()).append("\n");
        str.append("String to sign            = ").append(stringToSign).append("\n");
        str.append("SHA-1 result              = ").append(hexEncodedDigest).append("\n");
        log.debug(str);
    }

    // Put the parameters into an array
    NameValue[] nvArray = new NameValue[parmList.size()];
    parmList.toArray(nvArray);
    pDetails.setParameters(nvArray);

    if (log.isDebugEnabled()) {
        log.debug(pDetails.toString());
    }

    return pDetails;
}