package de.iftm.dcm4che.services;
import java.io.IOException;
import java.io.PrintStream;
import java.io.StringWriter;
import java.net.ConnectException;
import java.net.Socket;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.text.ParseException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import javax.net.SocketFactory;
import org.apache.log4j.Logger;
import org.dcm4che.data.Command;
import org.dcm4che.data.Dataset;
import org.dcm4che.data.DcmObjectFactory;
import org.dcm4che.data.DcmParserFactory;
import org.dcm4che.dict.DictionaryFactory;
import org.dcm4che.dict.Tags;
import org.dcm4che.dict.UIDDictionary;
import org.dcm4che.dict.UIDs;
import org.dcm4che.net.AAssociateAC;
import org.dcm4che.net.AAssociateRQ;
import org.dcm4che.net.ActiveAssociation;
import org.dcm4che.net.Association;
import org.dcm4che.net.AssociationFactory;
import org.dcm4che.net.Dimse;
import org.dcm4che.net.FutureRSP;
import org.dcm4che.net.PDU;
import org.dcm4che.net.PresContext;
import org.dcm4che.util.DcmURL;
import org.dcm4che.util.SSLContextAdapter;
public class CDimseService
{
static final Logger log = Logger.getLogger("CDimseService");
static final boolean DEBUG = log.isDebugEnabled();
private static final UIDDictionary uidDict = DictionaryFactory.getInstance().getDefaultUIDDictionary();
private static final AssociationFactory aFact = AssociationFactory.getInstance();
private static final DcmObjectFactory oFact = DcmObjectFactory.getInstance();
private static final DcmParserFactory pFact = DcmParserFactory.getInstance();
private static final DcmObjectFactory dof = DcmObjectFactory.getInstance();
private static final String DEFAULT_CALLING_AET = "OVIYAM";
public static final int PATIENT_LEVEL = 0;
public static final int STUDY_LEVEL = 1;
public static final int SERIES_LEVEL = 2;
public static final int IMAGE_LEVEL = 3;
PresContext pc;
private DcmURL url = null;
private int priority = 0;
private int acTimeout = 5000;
private int dimseTimeout = 0;
private int soCloseDelay = 500;
private AAssociateRQ assocRQ = aFact.newAAssociateRQ();
private Association assoc = null;
private ActiveAssociation aassoc = null;
private boolean packPDVs = false;
private SSLContextAdapter tls = null;
private String[] cipherSuites = null;
private Dataset keys = dof.newDataset();
private String dest;
public CDimseService(ConfigProperties cfg, DcmURL url)
throws ParseException
{
this.url = url;
this.priority = Integer.parseInt(cfg.getProperty("prior", "0"));
this.packPDVs = "true".equalsIgnoreCase(cfg.getProperty("pack-pdvs", "false"));
initAssocParam(cfg, url);
initTLS(cfg);
initKeys(cfg);
this.dest = cfg.getProperty("dest");
}
private final void initAssocParam(ConfigProperties cfg, DcmURL url)
{
String callingAET = null;
this.acTimeout = Integer.parseInt(cfg.getProperty("ac-timeout", "5000"));
this.dimseTimeout = Integer.parseInt(cfg.getProperty("dimse-timeout", "0"));
this.soCloseDelay = Integer.parseInt(cfg.getProperty("so-close-delay", "500"));
this.assocRQ.setCalledAET(url.getCalledAET());
if (url.getCallingAET() != null)
callingAET = url.getCallingAET();
else
callingAET = "OVIYAM";
this.assocRQ.setCallingAET(callingAET);
this.assocRQ.setMaxPDULength(Integer.parseInt(cfg.getProperty("max-pdu-len", "16352")));
this.assocRQ.setAsyncOpsWindow(aFact.newAsyncOpsWindow(Integer.parseInt(cfg.getProperty("max-op-invoked", "0")), 1));
for (Enumeration it = cfg.keys(); it.hasMoreElements(); ) {
String key = (String)it.nextElement();
if (key.startsWith("pc."))
initPresContext(Integer.parseInt(key.substring(3)), cfg.tokenize(cfg.getProperty(key), new LinkedList()));
}
}
private final void initPresContext(int pcid, List val)
{
Iterator it = val.iterator();
String as = UIDs.forName((String)it.next());
String[] tsUIDs = new String[val.size() - 1];
for (int i = 0; i < tsUIDs.length; ++i) {
tsUIDs[i] = UIDs.forName((String)it.next());
}
this.assocRQ.addPresContext(aFact.newPresContext(pcid, as, tsUIDs));
}
private void initTLS(ConfigProperties cfg)
throws ParseException
{
try
{
String value;
this.cipherSuites = this.url.getCipherSuites();
if (this.cipherSuites == null) {
return;
}
this.tls = SSLContextAdapter.getInstance();
char[] keystorepasswd = cfg.getProperty("tls-keystore-passwd", "secret").toCharArray();
char[] keypasswd = cfg.getProperty("tls-key-passwd", "secret").toCharArray();
URL keyURL = CDimseService.class.getResource("/resources/identityJava.jks");
if ((value = cfg.getProperty("tls-key")) != null) {
try
{
keyURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
} catch (Exception e) {
log.warn("Wrong value for tls-key: " + value + ". tls-key was set to default value.");
}
}
this.tls.setKey(this.tls.loadKeyStore(keyURL, keystorepasswd), keypasswd);
char[] cacertspasswd = cfg.getProperty("tls-cacerts-passwd", "secret").toCharArray();
URL cacertURL = CDimseService.class.getResource("/resources/identityJava.jks");
if ((value = cfg.getProperty("tls-cacerts")) != null) {
try
{
cacertURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
} catch (Exception e) {
log.warn("Wrong value for tls-cacerts: " + value + ". tls-cacerts was set to default value.");
}
}
this.tls.setTrust(this.tls.loadKeyStore(cacertURL, cacertspasswd));
this.tls.init();
}
catch (Exception ex) {
throw new ParseException("Could not initalize TLS configuration.", 0);
}
}
private void initKeys(ConfigProperties cfg)
throws ParseException
{
this.keys = dof.newDataset();
this.keys.putCS(524370, getQueryRetrieveLevel(1));
this.keys.putUI(2097165);
this.keys.putDA(524320);
this.keys.putPN(1048592);
this.keys.putLO(1048608);
this.keys.putUS(2101766);
this.keys.putUS(2101768);
addQueryKeys(cfg);
}
private void addQueryKeys(ConfigProperties cfg)
throws ParseException
{
for (Enumeration it = cfg.keys(); it.hasMoreElements(); ) {
String key = (String)it.nextElement();
if (key.startsWith("key."))
try {
this.keys.putXX(Tags.forName(key.substring(4)), cfg.getProperty(key));
} catch (Exception e) {
throw new ParseException("Illegal entry in configuration filr: " + key + "=" + cfg.getProperty(key), 0);
}
}
}
public void setQueryKeys(Dataset ds)
{
this.keys = ds;
}
public void setQueryKeys(ConfigProperties cfg)
throws ParseException
{
this.keys = dof.newDataset();
addQueryKeys(cfg);
}
public boolean aASSOCIATE()
throws ConnectException, IOException, GeneralSecurityException
{
if (this.assoc != null) {
throw new ConnectException("Association already established");
}
this.assoc = aFact.newRequestor(newSocket(this.url.getHost(), this.url.getPort()));
this.assoc.setAcTimeout(this.acTimeout);
this.assoc.setDimseTimeout(this.dimseTimeout);
this.assoc.setSoCloseDelay(this.soCloseDelay);
this.assoc.setPackPDVs(this.packPDVs);
PDU assocAC = this.assoc.connect(this.assocRQ);
if (!(assocAC instanceof AAssociateAC))
{
this.assoc = null;
return false;
}
this.aassoc = aFact.newActiveAssociation(this.assoc, null);
this.aassoc.st
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
基于DEM4CHE和Web的开源DICOM浏览器(oviyam0.9) (305个子文件)
KeyTool_genkey_identityJava_20years.bat 325B
KeyTool_genkey_identityJava_20years.bat 325B
Study.cfg 11KB
Study.cfg 11KB
Image.cfg 11KB
Image.cfg 11KB
CDimseService.cfg 11KB
CDimseService.cfg 11KB
Series.cfg 11KB
Series.cfg 11KB
EchoService.cfg 10KB
EchoService.cfg 10KB
StorageService.cfg 8KB
StorageService.cfg 8KB
SaveFilesystem.cfg 3KB
SaveFilesystem.cfg 3KB
CDimseService.class 16KB
StorageService.class 11KB
StorageServiceAdapter.class 9KB
ServerXmlConfiguration.class 8KB
PatientInfoHandler.class 6KB
ImageInfo.class 6KB
SeriesInfo.class 5KB
PatientInfo.class 5KB
DcmWindowLevel.class 4KB
MultiFrames.class 4KB
SeriesHandler.class 4KB
ConfigProperties.class 4KB
ImageHandler.class 3KB
DcmImage.class 3KB
Validator.class 3KB
SeriesDetailsHandler.class 3KB
EchoService.class 3KB
StudyInfoHandler.class 3KB
DICOMDataset.class 3KB
PatientModel.class 2KB
StudyModel.class 2KB
UpdateServerConfig.class 2KB
ServerConfig.class 2KB
AE.class 2KB
ServerConfiguration.class 1KB
SeriesModel.class 1KB
SeriesDetailsHandler$1.class 1KB
SeriesHandler$1.class 1KB
InstanceModel.class 1KB
StorageServiceEvent.class 1KB
StorageServiceEventListener.class 279B
.classpath 1KB
oviyam7.css 18KB
Study.css 17KB
dcm-style.css 3KB
login.css 796B
Thumbs.db 51KB
Thumbs.db 8KB
Thumbs.db 6KB
.directory 60B
icn_video.gif 10KB
loading_spinner.gif 7KB
overlay_spinner.gif 7KB
hide_tools.gif 3KB
show_tools.gif 2KB
hide_tools1.gif 2KB
search.gif 2KB
cancel.gif 2KB
buttonbg1.gif 2KB
darkest.gif 1KB
panelbg1.gif 1KB
header.gif 1KB
login.gif 841B
loginbg.gif 746B
patient-temp1.gif 606B
pic1.gif 604B
tableheader.gif 208B
icn_zoom_in.gif 176B
icn_zoom_out.gif 173B
icn_mosaic_0.gif 159B
icn_mosaic_1.gif 159B
icn_grid_1.gif 155B
icn_grid_0.gif 155B
chb.gif 154B
icn_list_1.gif 146B
icn_list_0.gif 146B
TopPlus1.gif 134B
TopMinus1.gif 127B
plus.gif 100B
fullscreen.gif 97B
moins.gif 97B
icn_grip0.gif 73B
icn_grip1.gif 73B
icn_grip1.gif 73B
index.html 169B
favicon.ico 1KB
dcm4che.jar 739KB
dcm4chee.jar 523KB
log4j-1.2.13.jar 350KB
standard.jar 287KB
clibwrapper_jiio.jar 68KB
commons-cli-1.0.jar 29KB
jstl.jar 17KB
slf4j-api-1.5.0.jar 16KB
共 305 条
- 1
- 2
- 3
- 4
CloneIQ
- 粉丝: 5
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SRS-CentOS7-x86-64-5.0-r1.zip
- 全文检索使用ElasticSearch实现全文检索的详细说明和实践探索
- 基于matlab主成分分析图像压缩重建系统代码14
- C语言《基于AT89C52单片机搭建的PID直流电机控制程序,主要用于Proteus电路仿真》+源代码
- C++《基于规划和汽车动力学的自动驾驶项目仿真(基于ROS的自动驾驶项目仿真,使用DWA路径规划算法和双PID控制器)》+源代码
- vos3000客户端2.1.7.03、2.1.8.05、2.1.9.07
- c++《用于船舶控制方法研究的3D船舶运动仿真软件》+源代码
- globalmapper24
- Python 小游戏 (贪吃蛇、五子棋、扫雷、俄罗斯方块)源码.zip
- Map data that can be used for 2D raster map path planning
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论14