Projects tigase _server server-core Commits e228e1ec
ctrl k
  • src/main/java/tigase/cluster/S2SConnectionClustered.java
    ■ ■ ■ ■ ■ ■
    skipped 78 lines
    79 79   
    80 80   private ClusterControllerIfc clusterController = null;
    81 81   private List<JID> cl_nodes_array = new CopyOnWriteArrayList<JID>();
    82  - @Deprecated
    83  - private CommandListener checkDBKeyResult = new CheckDBKeyResult(
    84  - CHECK_DB_KEY_RESULT_CMD);
    85  - @Deprecated
    86  - private CommandListener checkDBKey = new CheckDBKey(CHECK_DB_KEY_CMD);
    87 82   
    88 83   //~--- methods --------------------------------------------------------------
    89 84   
    skipped 37 lines
    127 122   return super.getDiscoDescription() + " clustered";
    128 123   }
    129 124   
    130  - /**
    131  - * Method description
    132  - *
    133  - *
    134  - * @param connectionCid
    135  - * @param keyCid
    136  - * @param key
    137  - * @param key_sessionId
    138  - * @param asking_sessionId
    139  - *
    140  - *
    141  - *
    142  - * @return a value of <code>String</code>
    143  - */
    144  - @Override
    145  - @Deprecated
    146  - public String getLocalDBKey(CID connectionCid, CID keyCid, String key,
    147  - String key_sessionId, String asking_sessionId) {
    148  - String local_key = super.getLocalDBKey(connectionCid, keyCid, key, key_sessionId,
    149  - asking_sessionId);
    150  - 
    151  - if (local_key != null) {
    152  - return local_key;
    153  - }
    154  - 
    155  - JID toNode = getFirstClusterNode();
    156  - 
    157  - if (toNode != null) {
    158  - Map<String, String> params = new LinkedHashMap<String, String>(6, 0.25f);
    159  - 
    160  - params.put(CONN_CID, connectionCid.toString());
    161  - params.put(KEY_CID, keyCid.toString());
    162  - params.put(KEY_P, key);
    163  - params.put(FORKEY_SESSION_ID, key_sessionId);
    164  - params.put(ASKING_SESSION_ID, asking_sessionId);
    165  - clusterController.sendToNodes(CHECK_DB_KEY_CMD, params, getComponentId(), toNode);
    166  - 
    167  - // If null is returned then the underlying API waits for the key to be
    168  - // delivered
    169  - // at later time
    170  - return null;
    171  - } else {
    172  - 
    173  - // If there is no cluster node available to ask for the db key then we
    174  - // just return something here to generate invalid key result.
    175  - return "invalid-key";
    176  - }
    177  - }
    178  - 
    179 125   //~--- set methods ----------------------------------------------------------
    180 126   
    181 127   /**
    skipped 5 lines
    187 133   @Override
    188 134   public void setClusterController(ClusterControllerIfc cl_controller) {
    189 135   clusterController = cl_controller;
    190  - clusterController.removeCommandListener(checkDBKey);
    191  - clusterController.removeCommandListener(checkDBKeyResult);
    192  - clusterController.setCommandListener(checkDBKey);
    193  - clusterController.setCommandListener(checkDBKeyResult);
    194 136   }
    195 137   
    196 138   //~--- get methods ----------------------------------------------------------
    skipped 20 lines
    217 159   return cluster_node;
    218 160   }
    219 161   
    220  - //~--- inner classes --------------------------------------------------------
    221  - @Deprecated
    222  - private class CheckDBKey
    223  - extends CommandListenerAbstract {
    224  - private CheckDBKey(String name) {
    225  - super(name);
    226  - }
    227  - 
    228  - //~--- methods ------------------------------------------------------------
    229  - 
    230  - /**
    231  - * Method description
    232  - *
    233  - *
    234  - * @param fromNode
    235  - * @param visitedNodes
    236  - * @param data
    237  - * @param packets
    238  - *
    239  - * @throws ClusterCommandException
    240  - */
    241  - @Override
    242  - public void executeCommand(JID fromNode, Set<JID> visitedNodes, Map<String,
    243  - String> data, Queue<Element> packets)
    244  - throws ClusterCommandException {
    245  - if (log.isLoggable(Level.FINEST)) {
    246  - log.log(Level.FINEST,
    247  - "Called fromNode: {0}, visitedNodes: {1}, data: {2}, packets: {3}",
    248  - new Object[] { fromNode,
    249  - visitedNodes, data, packets });
    250  - }
    251  - 
    252  - CID connCid = new CID(data.get(CONN_CID));
    253  - CID keyCid = new CID(data.get(KEY_CID));
    254  - String key = data.get(KEY_P);
    255  - String forkey_sessionId = data.get(FORKEY_SESSION_ID);
    256  - String asking_sessionId = data.get(ASKING_SESSION_ID);
    257  - 
    258  - if (fromNode.equals(getComponentId())) {
    259  - 
    260  - // If the request came back to the first sending node then no one had a
    261  - // valid key for this connection, therefore we are sending invalid back
    262  - if (log.isLoggable(Level.FINEST)) {
    263  - log.log(Level.FINEST,
    264  - "the request came back to the first sending node then no one had a " +
    265  - "valid key for this connection, therefore we are sending invalid back. " +
    266  - "fromNode: {0}, compId: {1}, connCid: {2}, keyCid: {3}, " +
    267  - "forkey_sessionId: {4}, asking_sessionId: {5}", new Object[] {
    268  - fromNode, getComponentId(), connCid, keyCid, forkey_sessionId,
    269  - asking_sessionId
    270  - });
    271  - }
    272  - sendVerifyResult(DB_VERIFY_EL_NAME, connCid, keyCid, false, forkey_sessionId,
    273  - asking_sessionId, null, false);
    274  - 
    275  - return;
    276  - }
    277  - 
    278  - String local_key = S2SConnectionClustered.super.getLocalDBKey(connCid, keyCid, key,
    279  - forkey_sessionId, asking_sessionId);
    280  - 
    281  - if (log.isLoggable(Level.FINEST)) {
    282  - log.log(Level.FINEST, "LocalDBKey: {0}", local_key);
    283  - }
    284  - 
    285  - boolean valid = false;
    286  - 
    287  - if (local_key == null) {
    288  - 
    289  - // Forward the request to the next node
    290  - JID nextNode = getNextNode(fromNode, visitedNodes);
    291  - 
    292  - if (log.isLoggable(Level.FINEST)) {
    293  - log.log(Level.FINEST, "No local db key, sending to next node: {0}", nextNode);
    294  - }
    295  - clusterController.sendToNodes(CHECK_DB_KEY_CMD, data, fromNode, visitedNodes,
    296  - nextNode);
    297  - 
    298  - return;
    299  - }
    300  - valid = local_key.equals(key);
    301  - data.put(VALID, "" + valid);
    302  - clusterController.sendToNodes(CHECK_DB_KEY_RESULT_CMD, data, getComponentId(),
    303  - fromNode);
    304  - }
    305  - 
    306  - //~--- get methods --------------------------------------------------------
    307  - 
    308  - private JID getNextNode(JID fromNode, Set<JID> visitedNodes) {
    309  - JID result = fromNode;
    310  - 
    311  - for (JID jid : cl_nodes_array) {
    312  - if (!fromNode.equals(jid) &&!visitedNodes.contains(jid)) {
    313  - result = jid;
    314  - 
    315  - break;
    316  - }
    317  - }
    318  - 
    319  - return result;
    320  - }
    321  - }
    322  - 
    323  - @Deprecated
    324  - private class CheckDBKeyResult
    325  - extends CommandListenerAbstract {
    326  - private CheckDBKeyResult(String name) {
    327  - super(name);
    328  - }
    329  - 
    330  - //~--- methods ------------------------------------------------------------
    331  - 
    332  - /**
    333  - * Method description
    334  - *
    335  - *
    336  - * @param fromNode
    337  - * @param visitedNodes
    338  - * @param data
    339  - * @param packets
    340  - *
    341  - * @throws ClusterCommandException
    342  - */
    343  - @Override
    344  - public void executeCommand(JID fromNode, Set<JID> visitedNodes, Map<String,
    345  - String> data, Queue<Element> packets)
    346  - throws ClusterCommandException {
    347  - if (log.isLoggable(Level.FINEST)) {
    348  - log.log(Level.FINEST,
    349  - "Called fromNode: {0}, visitedNodes: {1}, data: {2}, packets: {3}",
    350  - new Object[] { fromNode,
    351  - visitedNodes, data, packets });
    352  - }
    353  - 
    354  - CID connCid = new CID(data.get(CONN_CID));
    355  - CID keyCid = new CID(data.get(KEY_CID));
    356  - String forkey_sessionId = data.get(FORKEY_SESSION_ID);
    357  - String asking_sessionId = data.get(ASKING_SESSION_ID);
    358  - boolean valid = "true".equals(data.get(VALID));
    359  - 
    360  - // String key = data.get(KEY_P);
    361  - // String from = connCid.getLocalHost();
    362  - // String to = connCid.getRemoteHost();
    363  - sendVerifyResult(DB_VERIFY_EL_NAME, connCid, keyCid, valid, forkey_sessionId,
    364  - asking_sessionId, null, false);
    365  - }
    366  - }
    367 162  }
    368 163   
    369 164   
    skipped 2 lines
  • src/main/java/tigase/server/xmppserver/S2SConnectionHandlerIfc.java
    ■ ■ ■ ■ ■ ■
    skipped 78 lines
    79 79  
    80 80   String getSecretForDomain(String domain) throws NotLocalhostException;
    81 81  
    82  - @Deprecated
    83  - String getLocalDBKey(CID cid, CID keyCid, String remote_key, String stanzaId, String sessionId);
    84  - 
    85 82   //~--- methods --------------------------------------------------------------
    86 83   
    87 84   void initNewConnection(Map<String, Object> port_props);
    skipped 19 lines
  • src/main/java/tigase/server/xmppserver/S2SConnectionManager.java
    ■ ■ ■ ■ ■ ■
    skipped 742 lines
    743 743   }
    744 744   
    745 745   /**
    746  - *
    747  - * @param connectionCid
    748  - * @param keyCid
    749  - * @param key
    750  - * @param key_sessionId
    751  - * @param asking_sessionId
    752  - *
    753  - *
    754  - * @return a value of <code>String</code>
    755  - */
    756  - @Override
    757  - @Deprecated
    758  - public String getLocalDBKey(CID connectionCid, CID keyCid, String key,
    759  - String key_sessionId, String asking_sessionId) {
    760  - CIDConnections cid_conns = getCIDConnections(keyCid);
    761  - String result = (cid_conns == null)
    762  - ? null
    763  - : cid_conns.getDBKey(key_sessionId);
    764  - 
    765  - if (result == null) {
    766  - 
    767  - // In piggybacking mode the DB key can be available in the connectionCID
    768  - // rather then
    769  - // keyCID
    770  - cid_conns = getCIDConnections(connectionCid);
    771  - result = (cid_conns == null)
    772  - ? null
    773  - : cid_conns.getDBKey(key_sessionId);
    774  - }
    775  - 
    776  - return result;
    777  - }
    778  - 
    779  - /**
    780 746   * Method returns secret used for domain for generation of dialback key
    781 747   *
    782 748   * @param domain
    skipped 328 lines
  • src/main/java/tigase/server/xmppserver/proc/Dialback.java
    ■ ■ ■ ■ ■ ■
    skipped 287 lines
    288 288   private void initDialback(S2SIOService serv, String remote_id) {
    289 289   try {
    290 290   CID cid = (CID) serv.getSessionData().get("cid");
    291  - CIDConnections cid_conns = handler.getCIDConnections(cid, false);
    292 291   
    293 292   String secret = handler.getSecretForDomain(cid.getLocalHost());
    294 293   String key = Algorithms.generateDialbackKey(cid.getLocalHost(), cid.getRemoteHost(),
    skipped 11 lines
    306 305   serv.getS2SConnection().sendAllControlPackets();
    307 306   } catch (NotLocalhostException ex) {
    308 307   generateStreamError(false, "host-unknown", serv);
    309  - } catch (LocalhostException ex) {
    310  - generateStreamError(false, "invalid-from", serv);
    311 308   }
    312 309   }
    313 310   
    skipped 223 lines
Please wait...
Page is in error, reload to recover