数据通信源代码(牧云水务数据信息传输管理系统).docx_第1页
数据通信源代码(牧云水务数据信息传输管理系统).docx_第2页
数据通信源代码(牧云水务数据信息传输管理系统).docx_第3页
数据通信源代码(牧云水务数据信息传输管理系统).docx_第4页
数据通信源代码(牧云水务数据信息传输管理系统).docx_第5页
已阅读5页,还剩55页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

牧云水务数据信息传输管理系统V1.0 60package erceptor;import java.lang.annotation.Documented;import java.lang.annotation.ElementType;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;/* * api不需要验证登录 * * author share */Target( ElementType.METHOD, ElementType.TYPE )Retention(RetentionPolicy.RUNTIME)Documentedpublic interface AnonApi package com.movingdt.util;public class ApiResult public static final String CODE_FAIL = -1;public static final String CODE_SUCCESS = 1;public String message;public String code;public Object data;public ApiResult() this(success, ApiResult.CODE_SUCCESS);public ApiResult(String message, String code) this.message = message;this.code = code;public ApiResult(String message, String code,Object data) this.message = message;this.code = code;this.data = data;public String getMessage() return this.message;public void setMessage(String message) this.message = message;public String getCode() return this.code;public void setCode(String code) this.code = code;public Object getData() return data;public void setData(Object data) this.data = data;package com.movingdt.util;import java.io.UnsupportedEncodingException;import java.math.BigInteger;/* * Created with IntelliJ IDEA. User: noah Date: 8/2/13 Time: 10:36 AM To change * this template use File | Settings | File Templates. */public class Base58 public static final char ALPHABET = 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz.toCharArray();private static final int INDEXES = new int128;static for (int i = 0; i INDEXES.length; i+) INDEXESi = -1;for (int i = 0; i ALPHABET.length; i+) INDEXESALPHABETi = i;/* * Encodes the given bytes in base58. No checksum is appended. */public static String encode(byte input) if (input.length = 0) return ;input = copyOfRange(input, 0, input.length);/ Count leading zeroCount = 0;while (zeroCount input.length & inputzeroCount = 0) +zeroCount;/ The actual encoding.byte temp = new byteinput.length * 2;int j = temp.length;int startAt = zeroCount;while (startAt input.length) byte mod = divmod58(input, startAt);if (inputstartAt = 0) +startAt;temp-j = (byte) ALPHABETmod;/ Strip extra 1 if there are some after decoding.while (j = 0) temp-j = (byte) ALPHABET0;byte output = copyOfRange(temp, j, temp.length);try return new String(output, US-ASCII); catch (UnsupportedEncodingException e) throw new RuntimeException(e); / Cannot happen.public static byte decode(String input) throws IllegalArgumentException if (input.length() = 0) return new byte0;byte input58 = new byteinput.length();/ Transform the String to a base58 byte sequencefor (int i = 0; i = 0 & c 128) digit58 = INDEXESc;if (digit58 0) throw new IllegalArgumentException(Illegal character + c + at + i);input58i = (byte) digit58;/ Count leading zeroesint zeroCount = 0;while (zeroCount input58.length & input58zeroCount = 0) +zeroCount;/ The encodingbyte temp = new byteinput.length();int j = temp.length;int startAt = zeroCount;while (startAt input58.length) byte mod = divmod256(input58, startAt);if (input58startAt = 0) +startAt;temp-j = mod;/ Do no add extra leading zeroes, move j to first non null byte.while (j number / 58, returns number % 58/private static byte divmod58(byte number, int startAt) int remainder = 0;for (int i = startAt; i number / 256, returns number % 256/private static byte divmod256(byte number58, int startAt) int remainder = 0;for (int i = startAt; i lastTime) lastTime = lastModified;try reload(f); finally if (lock1.getCount() 0)lock1.countDown();public void reload(File f) public void waitFirstRun() throws InterruptedException lock1.await();package com.movingdt.util;public class Constant public static String CookieNameICTK = ICTK;public static String COOKIE_PATH = /;public static String VERSION = v1;public static int COOKIE_ICTK_MAXAGE = 60 * 60 * 24 * 90; / 90天单位s 0删除public static final String LOGIN_USER_KEY = LoginUser;public static final String LOGIN = /login; / 登录地址package com.movingdt.util;import java.security.GeneralSecurityException;import java.security.SecureRandom;import javax.crypto.Cipher;import javax.crypto.KeyGenerator;import javax.crypto.SecretKey;import javax.crypto.spec.IvParameterSpec;import javax.crypto.spec.SecretKeySpec;import mons.codec.binary.Base64;public class CryptUtil private static final String AES = AES;private static final String AES_CBC = AES/CBC/PKCS5Padding;private static final int DEFAULT_AES_KEYSIZE = 128;private static final int DEFAULT_IVSIZE = 16;public static void main(String args) throws Exception byte key128Base64 = Base64.decodeBase64(Ege8HbbmsSz0RlKR/Ynjsw=);byte enc = encryptAES(你123b.getBytes(), key128Base64);byte src = decryptAES(enc, key128Base64);System.out.println(Base64.encodeBase64String(enc);System.out.println(new String(src);public static byte ivBase64 = Base64.decodeBase64(ac80PYOAkewM6OrceBSc7g=);public static byte key128Base64 = Base64.decodeBase64(Ege8HbbmsSz0RlKR/Ynjsw=);public static class AESKeyGen private static SecureRandom random = new SecureRandom();public static void main(String args) System.out.println(ivBase64=Base64.decodeBase64( + new String(Base64.encodeBase64(generateIV()+ ););System.out.println(key128Base64=Base64.decodeBase64(+ new String(Base64.encodeBase64(generateAesKey() + ););public static byte generateAesKey() return generateAesKey(DEFAULT_AES_KEYSIZE);public static byte generateAesKey(int keysize) try KeyGenerator keyGenerator = KeyGenerator.getInstance(AES);keyGenerator.init(keysize);SecretKey secretKey = keyGenerator.generateKey();return secretKey.getEncoded(); catch (GeneralSecurityException e) throw new RuntimeException(e);public static byte generateIV() byte bytes = new byteDEFAULT_IVSIZE;random.nextBytes(bytes);return bytes;/ - AES funciton -/public static byte encryptAES(byte input, byte key) return aes(input, key, Cipher.ENCRYPT_MODE);public static byte encryptAES(byte input, byte key, byte iv) return aes(input, key, iv, Cipher.ENCRYPT_MODE);public static byte decryptAES(byte input, byte key) return aes(input, key, Cipher.DECRYPT_MODE);public static String decryptAESString(byte input, byte key) byte decryptResult = aes(input, key, Cipher.DECRYPT_MODE);return new String(decryptResult);public static String decryptAES(byte input, byte key, byte iv) byte decryptResult = aes(input, key, iv, Cipher.DECRYPT_MODE);return new String(decryptResult);public static byte aes(byte input, byte key, int mode) try SecretKey secretKey = new SecretKeySpec(key, AES);Cipher cipher = Cipher.getInstance(AES);cipher.init(mode, secretKey);return cipher.doFinal(input); catch (GeneralSecurityException e) throw new RuntimeException(e);public static byte aes(byte input, byte key, byte iv, int mode) try SecretKey secretKey = new SecretKeySpec(key, AES);IvParameterSpec ivSpec = new IvParameterSpec(iv);Cipher cipher = Cipher.getInstance(AES_CBC);cipher.init(mode, secretKey, ivSpec);return cipher.doFinal(input); catch (GeneralSecurityException e) throw new RuntimeException(e);package com.movingdt.entity;import java.util.Date;public class DeviceHistoryInfo private Integer id;private Integer deviceId;private String deviceSymbol;private String deviceName;private Integer groupId;private String deviceGroupName;private String deviceGroupDesc;private String deviceValue;private String qualities;private Date createTime;private Date updateTime;public Integer getId() return id;public void setId(Integer id) this.id = id;public Integer getDeviceId() return deviceId;public void setDeviceId(Integer deviceId) this.deviceId = deviceId;public String getDeviceSymbol() return deviceSymbol;public void setDeviceSymbol(String deviceSymbol) this.deviceSymbol = deviceSymbol = null ? null : deviceSymbol.trim();public String getDeviceName() return deviceName;public void setDeviceName(String deviceName) this.deviceName = deviceName = null ? null : deviceName.trim();public Integer getGroupId() return groupId;public void setGroupId(Integer groupId) this.groupId = groupId;public String getDeviceGroupName() return deviceGroupName;public void setDeviceGroupName(String deviceGroupName) this.deviceGroupName = deviceGroupName = null ? null : deviceGroupName.trim();public String getDeviceGroupDesc() return deviceGroupDesc;public void setDeviceGroupDesc(String deviceGroupDesc) this.deviceGroupDesc = deviceGroupDesc = null ? null : deviceGroupDesc.trim();public String getDeviceValue() return deviceValue;public void setDeviceValue(String deviceValue) this.deviceValue = deviceValue = null ? null : deviceValue.trim();public String getQualities() return qualities;public void setQualities(String qualities) this.qualities = qualities;public Date getCreateTime() return createTime;public void setCreateTime(Date createTime) this.createTime = createTime;public Date getUpdateTime() return updateTime;public void setUpdateTime(Date updateTime) this.updateTime = updateTime;Overridepublic String toString() return DeviceHistoryInfo id= + id + , deviceId= + deviceId + , deviceSymbol= + deviceSymbol+ , deviceName= + deviceName + , groupId= + groupId + , deviceGroupName= + deviceGroupName+ , deviceGroupDesc= + deviceGroupDesc + , deviceValue= + deviceValue + , createTime=+ createTime + , updateTime= + updateTime + ;id, device_id, device_symbol, device_name, group_id,device_group_name,device_group_desc,device_value, qualities,create_time, update_timeselectfrom device_history_infowhere id = #id,jdbcType=INTEGERdelete fromdevice_history_infowhere id = #id,jdbcType=INTEGERinsert intodevice_history_info (id, device_id, device_symbol,device_name,group_id, device_group_name,device_group_desc, device_value,qualities, create_time,update_time)values (#id,jdbcType=INTEGER,#deviceId,jdbcType=INTEGER,#deviceSymbol,jdbcType=VARCHAR,#deviceName,jdbcType=VARCHAR, #groupId,jdbcType=INTEGER,#deviceGroupName,jdbcType=VARCHAR,#deviceGroupDesc,jdbcType=VARCHAR, #deviceValue,jdbcType=VARCHAR,#qualities,jdbcType=VARCHAR,#createTime,jdbcType=TIMESTAMP,#updateTime,jdbcType=TIMESTAMP)insert into device_history_infoid,device_id,device_symbol,device_name,group_id,device_group_name,device_group_desc,device_value,qualities,create_time,update_time,#id,jdbcType=INTEGER,#deviceId,jdbcType=INTEGER,#deviceSymbol,jdbcType=VARCHAR,#deviceName,jdbcType=VARCHAR,#groupId,jdbcType=INTEGER,#deviceGroupName,jdbcType=VARCHAR,#deviceGroupDesc,jdbcType=VARCHAR,#deviceValue,jdbcType=VARCHAR,#q

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论