cn.teleinfo.idpointer.sdk.session.Session Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of id-pointer-sdk Show documentation
Show all versions of id-pointer-sdk Show documentation
基于Java语言开发的工业互联网标识解析体系客户端软件开发工具包,应用通过集成 id-pointer-sdk,快速对接标识解析、标识注册、标识维护等功能服务。
The newest version!
package cn.teleinfo.idpointer.sdk.session;
import cn.teleinfo.idpointer.sdk.client.IdUserId;
import cn.teleinfo.idpointer.sdk.security.HdlSecurityProvider;
public class Session {
private int sessionId = -1;
private IdUserId idUserId;
private boolean encryptMessage = false;
private byte sessionKey[];
private int sessionKeyAlgorithmCode;
public Session(int sessionId) {
this.sessionId = sessionId;
}
public void setSessionId(int sessionId) {
this.sessionId = sessionId;
}
public void setIdUserId(IdUserId idUserId) {
this.idUserId = idUserId;
}
public void setEncryptMessage(boolean encryptMessage) {
this.encryptMessage = encryptMessage;
}
public void setSessionKey(byte[] sessionKey) {
this.sessionKey = sessionKey;
}
public void setSessionKeyAlgorithmCode(int sessionKeyAlgorithmCode) {
switch (sessionKeyAlgorithmCode) {
case HdlSecurityProvider.ENCRYPT_ALG_AES:
case HdlSecurityProvider.ENCRYPT_ALG_DES:
case HdlSecurityProvider.ENCRYPT_ALG_DESEDE:
case HdlSecurityProvider.ENCRYPT_ALG_SM4:
// encryptCipher = null;
// decryptCipher = null;
//this.sessionKeyAlgorithmCode = sessionKeyAlgorithmCode;
break;
default:
throw new IllegalArgumentException("Invalid algorithm ID: " + sessionKeyAlgorithmCode);
}
this.sessionKeyAlgorithmCode = sessionKeyAlgorithmCode;
}
public int getSessionId() {
return sessionId;
}
public IdUserId getIdUserId() {
return idUserId;
}
public byte[] getSessionKey() {
return sessionKey;
}
public boolean isEncryptMessage() {
return encryptMessage;
}
public boolean isAuthenticated() {
return idUserId != null;
}
public int getSessionKeyAlgorithmCode() {
return sessionKeyAlgorithmCode;
}
}