|
32 | 32 | import javax.naming.directory.Attributes; |
33 | 33 | import javax.naming.directory.DirContext; |
34 | 34 | import javax.naming.directory.InitialDirContext; |
35 | | -import java.io.Serializable; |
36 | 35 | import java.util.*; |
37 | 36 | import java.util.stream.Collectors; |
38 | 37 |
|
@@ -369,121 +368,4 @@ public static boolean isNameCoveredByPattern( String name, String pattern ) |
369 | 368 | } |
370 | 369 | return false; |
371 | 370 | } |
372 | | - |
373 | | - /** |
374 | | - * Encapsulates a hostname and port. |
375 | | - * |
376 | | - * @deprecated Replaced by {@link SrvRecord} |
377 | | - */ |
378 | | - @Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0 |
379 | | - public static class HostAddress implements Serializable { |
380 | | - |
381 | | - private final SrvRecord delegate; |
382 | | - |
383 | | - public HostAddress(String host, int port, boolean directTLS) { |
384 | | - delegate = new SrvRecord(host, port, directTLS); |
385 | | - } |
386 | | - |
387 | | - public String getHost() { |
388 | | - return delegate.getHostname(); |
389 | | - } |
390 | | - |
391 | | - public int getPort() { |
392 | | - return delegate.getPort(); |
393 | | - } |
394 | | - |
395 | | - public boolean isDirectTLS() { |
396 | | - return delegate.isDirectTLS(); |
397 | | - } |
398 | | - |
399 | | - @Override |
400 | | - public String toString() { |
401 | | - return delegate.getHostname() + ":" + delegate.getHostname(); |
402 | | - } |
403 | | - } |
404 | | - |
405 | | - /** |
406 | | - * @deprecated Replaced by {@link SrvRecord#prioritize(SrvRecord[])} |
407 | | - */ |
408 | | - @Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0 |
409 | | - public static List<WeightedHostAddress> prioritize(WeightedHostAddress[] records) { |
410 | | - final List<WeightedHostAddress> result = new LinkedList<>(); |
411 | | - |
412 | | - // sort by priority (ascending) |
413 | | - final Set<SrvRecord> delegates = Arrays.stream(records).map(WeightedHostAddress::getDelegate).collect(Collectors.toSet()); |
414 | | - final List<Set<SrvRecord>> prioritized = SrvRecord.prioritize(delegates); |
415 | | - for (Set<SrvRecord> set : prioritized) { |
416 | | - final LinkedHashSet<WeightedHostAddress> orderedSet = new LinkedHashSet<>(); // Retain the order in the set! |
417 | | - for (final SrvRecord e : set) { |
418 | | - orderedSet.add(new WeightedHostAddress(e)); |
419 | | - } |
420 | | - result.addAll(orderedSet); |
421 | | - } |
422 | | - return result; |
423 | | - } |
424 | | - |
425 | | - @Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0 |
426 | | - public static class WeightedHostAddress extends HostAddress |
427 | | - { |
428 | | - private final SrvRecord delegate; |
429 | | - |
430 | | - static WeightedHostAddress from(HostAddress address) { |
431 | | - if (address instanceof WeightedHostAddress) { |
432 | | - return (WeightedHostAddress) address; |
433 | | - } |
434 | | - |
435 | | - return new WeightedHostAddress(address.getHost(), address.getPort(), address.isDirectTLS(), 0, 0); |
436 | | - } |
437 | | - |
438 | | - private WeightedHostAddress(@Nonnull final SrvRecord delegate) { |
439 | | - this(delegate.getHostname(), delegate.getPort(), delegate.isDirectTLS(), delegate.getPriority(), delegate.getWeight()); |
440 | | - } |
441 | | - |
442 | | - private WeightedHostAddress(String[] srvRecordEntries, boolean directTLS) { |
443 | | - // Host entries in DNS should end with a ".". |
444 | | - super( |
445 | | - srvRecordEntries[srvRecordEntries.length-1].endsWith(".") ? srvRecordEntries[srvRecordEntries.length-1].substring(0, srvRecordEntries[srvRecordEntries.length-1].length()-1) : srvRecordEntries[srvRecordEntries.length-1], |
446 | | - Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]), |
447 | | - directTLS |
448 | | - ); |
449 | | - delegate = new SrvRecord(super.getHost(), super.getPort(), super.isDirectTLS(), Integer.parseInt(srvRecordEntries[srvRecordEntries.length-3]), Integer.parseInt(srvRecordEntries[srvRecordEntries.length-4])); |
450 | | - } |
451 | | - |
452 | | - WeightedHostAddress(String host, int port, boolean directTLS, int priority, int weight) { |
453 | | - super(host, port, directTLS); |
454 | | - delegate = new SrvRecord(host, port, directTLS, priority, weight); |
455 | | - } |
456 | | - |
457 | | - public int getPriority() { |
458 | | - return delegate.getPriority(); |
459 | | - } |
460 | | - |
461 | | - public int getWeight() { |
462 | | - return delegate.getWeight(); |
463 | | - } |
464 | | - |
465 | | - SrvRecord getDelegate() { |
466 | | - return delegate; |
467 | | - } |
468 | | - |
469 | | - @Override |
470 | | - public boolean equals(Object o) |
471 | | - { |
472 | | - if (this == o) return true; |
473 | | - if (o == null || getClass() != o.getClass()) return false; |
474 | | - WeightedHostAddress that = (WeightedHostAddress) o; |
475 | | - return Objects.equals(delegate, that.delegate); |
476 | | - } |
477 | | - |
478 | | - @Override |
479 | | - public int hashCode() |
480 | | - { |
481 | | - return Objects.hashCode(delegate); |
482 | | - } |
483 | | - |
484 | | - @Override |
485 | | - public String toString() { |
486 | | - return "prio: " + delegate.getPriority() + ", weight: " + delegate.getWeight() + ", port: " + getPort() + ", host: " + getHost() + ", isDirectTLS: " + isDirectTLS(); |
487 | | - } |
488 | | - } |
489 | 371 | } |
0 commit comments