Beispiel #1
0
 public Association connect(ApplicationEntity remote, AAssociateRQ rq)
     throws IOException, InterruptedException, IncompatibleConnectionException,
         GeneralSecurityException {
   CompatibleConnection cc = findCompatibelConnection(remote);
   if (rq.getCalledAET() == null) rq.setCalledAET(remote.getAETitle());
   return connect(cc.getLocalConnection(), cc.getRemoteConnection(), rq);
 }
Beispiel #2
0
 public final void setInformationModel(InformationModel model, String[] tss, boolean relational) {
   this.model = model;
   rq.addPresentationContext(new PresentationContext(1, model.cuid, tss));
   if (relational)
     rq.addExtendedNegotiation(
         new ExtendedNegotiation(
             model.cuid,
             QueryOption.toExtendedNegotiationInformation(EnumSet.of(QueryOption.RELATIONAL))));
   if (model.level != null) addLevel(model.level);
 }
Beispiel #3
0
  private TransferCapability roleSelection(AAssociateRQ rq, AAssociateAC ac, String asuid) {
    RoleSelection rqrs = rq.getRoleSelectionFor(asuid);
    if (rqrs == null) return getTC(scpTCs, asuid, rq);

    RoleSelection acrs = ac.getRoleSelectionFor(asuid);
    if (acrs != null) return getTC(acrs.isSCU() ? scpTCs : scuTCs, asuid, rq);

    TransferCapability tcscu = null;
    TransferCapability tcscp = null;
    boolean scu = rqrs.isSCU() && (tcscp = getTC(scpTCs, asuid, rq)) != null;
    boolean scp = rqrs.isSCP() && (tcscu = getTC(scuTCs, asuid, rq)) != null;
    ac.addRoleSelection(new RoleSelection(asuid, scu, scp));
    return scu ? tcscp : tcscu;
  }
Beispiel #4
0
  public Association connect(Connection local, Connection remote, AAssociateRQ rq)
      throws IOException, InterruptedException, IncompatibleConnectionException,
          GeneralSecurityException {
    checkDevice();
    checkInstalled();
    if (rq.getCallingAET() == null) rq.setCallingAET(AETitle);
    rq.setMaxOpsInvoked(local.getMaxOpsInvoked());
    rq.setMaxOpsPerformed(local.getMaxOpsPerformed());
    rq.setMaxPDULength(local.getReceivePDULength());

    final Socket sock =
        local.connect(remote); // automatically closes the socket in case an exception is thrown

    Association as;
    try {
      as = new Association(this, local, sock);
    } catch (final IOException e) {
      LOG.warn("Failed to open new association, will close underlying socket");
      local.close(sock);
      throw e;
    }
    try {
      as.write(rq);
      as.waitForLeaving(State.Sta5);
    } catch (final IOException e) {
      LOG.warn("{}: Failed to write A-ASSOCIATE-RQ, will abort association", as.toString());
      as.abort();
      throw e;
    } catch (final InterruptedException e) {
      LOG.warn(
          "{}: Interrupted while waiting to leave state Sta 5, will abort association",
          as.toString());
      as.abort();
      throw e;
    }
    return as;
  }
Beispiel #5
0
  private TransferCapability getTC(
      Map<String, TransferCapability> tcs, String asuid, AAssociateRQ rq) {
    TransferCapability tc = tcs.get(asuid);
    if (tc != null) return tc;

    CommonExtendedNegotiation commonExtNeg = rq.getCommonExtendedNegotiationFor(asuid);
    if (commonExtNeg != null) {
      for (String cuid : commonExtNeg.getRelatedGeneralSOPClassUIDs()) {
        tc = tcs.get(cuid);
        if (tc != null) return tc;
      }
      tc = tcs.get(commonExtNeg.getServiceClassUID());
      if (tc != null) return tc;
    }

    return tcs.get("*");
  }
Beispiel #6
0
  protected PresentationContext negotiate(
      AAssociateRQ rq, AAssociateAC ac, PresentationContext rqpc) {
    String as = rqpc.getAbstractSyntax();
    TransferCapability tc = roleSelection(rq, ac, as);
    int pcid = rqpc.getPCID();
    if (tc == null)
      return new PresentationContext(
          pcid, PresentationContext.ABSTRACT_SYNTAX_NOT_SUPPORTED, rqpc.getTransferSyntax());

    for (String ts : rqpc.getTransferSyntaxes())
      if (tc.containsTransferSyntax(ts)) {
        byte[] info = negotiate(rq.getExtNegotiationFor(as), tc);
        if (info != null) ac.addExtendedNegotiation(new ExtendedNegotiation(as, info));
        return new PresentationContext(pcid, PresentationContext.ACCEPTANCE, ts);
      }

    return new PresentationContext(
        pcid, PresentationContext.TRANSFER_SYNTAX_NOT_SUPPORTED, rqpc.getTransferSyntax());
  }
 private AAssociateRQ createAARQ(Association as) {
   AAssociateRQ aarq = new AAssociateRQ();
   for (PresentationContext pc : as.getAAssociateRQ().getPresentationContexts())
     aarq.addPresentationContext(pc);
   return aarq;
 }