List of usage examples for org.apache.commons.codec.digest DigestUtils sha1Hex
public static String sha1Hex(String data)
From source file:com.jiusit.onePurchase.pay.Pay.java
/** * ??//from w w w .j av a 2 s .co m * @param timestamp * @param noncestr * @param openid * @param issubscribe * @param appsignature * @return * @throws UnsupportedEncodingException */ public static boolean verifySign(long timestamp, String noncestr, String openid, int issubscribe, String appsignature) throws UnsupportedEncodingException { Map<String, String> paras = new HashMap<String, String>(); paras.put("appid", PropKit.get("appId")); paras.put("appkey", PropKit.get("paySignKey")); paras.put("timestamp", String.valueOf(timestamp)); paras.put("noncestr", noncestr); paras.put("openid", openid); paras.put("issubscribe", String.valueOf(issubscribe)); // appid?appkey?productid?timestamp?noncestr?openid?issubscribe String string1 = createSign(paras, false); String paySign = DigestUtils.sha1Hex(string1); return paySign.equalsIgnoreCase(appsignature); }
From source file:com.kibana.multitenancy.plugin.KibanaUserReindexFilter.java
public static String getUsernameHash(String username) { return DigestUtils.sha1Hex(username); }
From source file:com.axelor.apps.account.ebics.web.EbicsController.java
private void confirmCertificates(EbicsUser user, X509Certificate[] certificates, ActionResponse response) { try {//from w w w. j av a2 s . co m EbicsBank bank = user.getEbicsPartner().getEbicsBank(); response.setView(ActionView.define("Confirm certificates") .model("com.axelor.apps.account.db.EbicsCertificate") .add("form", "ebics-certificate-confirmation-form").param("show-toolbar", "false") .param("show-confirm", "false").param("popup-save", "false").param("popup", "true") .context("ebicsBank", bank).context("url", bank.getUrl()).context("hostId", bank.getHostId()) .context("e002Hash", DigestUtils.sha1Hex(certificates[0].getEncoded()).toUpperCase()) .context("x002Hash", DigestUtils.sha1Hex(certificates[1].getEncoded()).toUpperCase()) .context("certificateE002", convertToPEMString(certificates[0])) .context("certificateX002", convertToPEMString(certificates[1])).map()); } catch (Exception e) { response.setFlash("Error in certificate confirmation "); } }
From source file:models.sos.ObservationDescription.java
/** * standard ObservationDescription, to be tested if still valid, is of type * http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement, * sampledFeatureURI http://sweet.nasa.jpl/2.2/Climate empty codeSpace for * feature//from ww w. j a va2s . c o m * * @param phenTime * @param offeringURI * @param sensorURI * @param phenomenonURI * @param uomCode * @param value * @param featureURI * @param position * @return */ public String createTemplatedMeasurementObservation(Date phenTime, String offeringURI, String sensorURI, String phenomenonURI, String uomCode, Double value, String featureURI, Double[] position) { StringBuilder sosOMGenerator = new StringBuilder(); sosOMGenerator.append("<sos:offering>" + offeringURI + "</sos:offering>"); // FIXME generate better? String sampledFeatureURI = "http://sweet.nasa.jpl/2.2/Climate"; String ssfGmlID = "ssf_" + DigestUtils.sha1Hex(featureURI).toUpperCase(); SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZ"); String pointGmlID = "poi_" + DigestUtils.sha1Hex(featureURI).toUpperCase(); sosOMGenerator.append("<sos:observation>\n" + "<om:OM_Observation gml:id=\"o1\">\n" + "<om:type xlink:href=\"http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement\"/>\n" + "<om:phenomenonTime>\n" + "<gml:TimeInstant gml:id=\"phenomenonTime\">\n" + "<gml:timePosition>" + fmt.format(phenTime) + "</gml:timePosition>\n" + "</gml:TimeInstant>\n" + "</om:phenomenonTime>\n" + "<om:resultTime xlink:href=\"#phenomenonTime\"/>\n" + "<om:procedure xlink:href=\"" + sensorURI + "\"/>\n" + "<om:observedProperty xlink:href=\"" + phenomenonURI + "\"/>\n"); // if position null, assume feature exists and just past URI if (position == null) { sosOMGenerator.append(" <om:featureOfInterest xlink:href=\"" + featureURI + "\"/>\n"); } else { sosOMGenerator.append(" <om:featureOfInterest>\n" + "<sams:SF_SpatialSamplingFeature gml:id=\"" + ssfGmlID + "\">\n" + "<gml:identifier codeSpace=\"\">" + featureURI + "</gml:identifier>\n" + "<sf:type xlink:href=\"http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint\"/>\n" + "<sf:sampledFeature xlink:href=\"" + sampledFeatureURI + "\"/>\n" + "<sams:shape>\n" + "<gml:Point gml:id=\"" + pointGmlID + "\">\n" + "<gml:pos srsName=\"http://www.opengis.net/def/crs/EPSG/0/4326\">" + position[0] + " " + position[1] + "</gml:pos>\n" + "</gml:Point>\n" + "</sams:shape>\n" + "</sams:SF_SpatialSamplingFeature>\n" + "</om:featureOfInterest>\n"); } sosOMGenerator.append("<om:result xsi:type=\"gml:MeasureType\" uom=\"" + uomCode + "\">" + value + "</om:result>\n" + "</om:OM_Observation>\n" + "</sos:observation>\n"); return sosOMGenerator.toString(); }
From source file:debrepo.teamcity.archive.DebFileReader.java
protected String getSha1Hash(File debFile) throws IOException { FileInputStream fis = new FileInputStream(debFile); return DigestUtils.sha1Hex(fis); }
From source file:be.fedict.hsm.model.admin.ApplicationManagerBean.java
public void addApplicationCredential(ApplicationEntity application, byte[] credential) throws ExistingCredentialException { LOG.debug("addApplicationCredential"); ApplicationEntity applicationEntity = this.entityManager.find(ApplicationEntity.class, application.getId()); String hash = DigestUtils.sha1Hex(credential); CredentialEntity existingCredentialEntity = this.entityManager.find(CredentialEntity.class, hash); if (null != existingCredentialEntity) { throw new ExistingCredentialException(); }/*ww w .j a v a 2s . co m*/ CredentialEntity credentialEntity = new CredentialEntity(hash, credential, applicationEntity); this.entityManager.persist(credentialEntity); }
From source file:com.jiusit.onePurchase.pay.Pay.java
/** * ???/*w w w. jav a 2 s . c om*/ * @param paras * @return * @throws UnsupportedEncodingException * * @? appid?appkey?openid?transid?out_trade_no?deliver_timestamp?deliver_status?deliver_msg */ private static String deliverSign(Map<String, String> paras) throws UnsupportedEncodingException { paras.put("appkey", PropKit.get("paySignKey")); String string1 = createSign(paras, false); String paySign = DigestUtils.sha1Hex(string1); return paySign; }
From source file:media_organizer.MediaInspector.java
public String getChecksum(File f, Boolean useSha) { FileInputStream is = null;/*from www. j a va 2 s.co m*/ String checksumValue = null; try { is = new FileInputStream(f); if (useSha) { checksumValue = DigestUtils.sha1Hex(is); } else { checksumValue = DigestUtils.md5Hex(is); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return checksumValue; }
From source file:bobs.mcapisignature.CertUtils.java
public static String getThumbprint(CERT_CONTEXT pcert) { return DigestUtils.sha1Hex(certToBytes(pcert)).toUpperCase(); }
From source file:com.mygdx.java.MyGdxJava.java
private void start() throws Exception { client = new ForClientImpl(new InetSocketAddress("192.168.2.100", 7577)); // client.getIoConnector().setConnectTimeoutMillis(1000 * 2); DefaultIoFilterChainBuilder chain = client.getIoConnector().getFilterChain(); // IoFilterChainBuilderUtils.addClientSslFilter(chain); IoFilterChainBuilderUtils.addObjectSerializationCodec(chain); // IoFilterChainBuilderUtils.addCodec(chain); client.getIoConnector().setHandler(new IoHandlerAdapter() { @Override//w ww . java 2s . com public void messageReceived(IoSession session, Object message) throws Exception { if (message instanceof Message) { Message data = (Message) message; System.out.println("---->" + data); String sha1Message = JsonUtils.getValuse(message.toString(), "sha1"); String sha1 = new String(DigestUtils.sha1Hex(data.getData())); if (sha1 == null || sha1Message == null || !sha1.equals(sha1Message.replace("\"", ""))) { System.out.println("sha1 not same:" + sha1 + " <---> " + sha1Message); return; } ImageUtils.setScreenTextureRegionInThread(region, data.getData()); // image = region.getTexture(); } } }); client.getIoConnector().getSessionConfig().setReadBufferSize(1024 * 128); client.getIoConnector().getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 2); client.start(); }