public boolean isMatchingAddress(KeyAddress address) { for (KeyAddress addr: unsAddresses) if (addr.isMatchingKeyAddress(address)) return true; return false; }
@Override public final boolean isMatchingKeyAddress(KeyAddress other) { return other.isLong() ? getLongAddress().isMatchingKeyAddress(other) : getShortAddress().isMatchingKeyAddress(other); }
@Override public boolean isMatchingKey(AbstractKey key) { return getShortAddress().isMatchingKeyAddress(key.getShortAddress()); }
/** * Check that the address matches role. * * @param keyAddress address for matching with role * @return true if match or false * @deprecated the only usable check allowance method is isAllowedForKeys */ @Deprecated public boolean isMatchingKeyAddress(KeyAddress keyAddress) { for (KeyAddress ka : this.getKeyAddresses()) { if (keyAddress.isMatchingKeyAddress(ka)) return true; } for (PublicKey pk : this.getKeys()) { if (keyAddress.isMatchingKey(pk)) return true; } return false; } /**
private void testMatch(boolean use384) throws KeyAddress.IllegalAddressException { KeyAddress a = key1.address(use384, 7); KeyAddress b = new KeyAddress(a.toString()); assertEquals(7, b.getTypeMark()); assertEquals(7, a.getTypeMark()); assertTrue(b.isMatchingKey(key1)); assertTrue(a.isMatchingKeyAddress(b)); assertTrue(b.isMatchingKeyAddress(a)); assertTrue(key1.isMatchingKey(key1)); assertTrue(key1.isMatchingKeyAddress(a)); assertTrue(key1.isMatchingKeyAddress(b)); byte[] pack = a.getPacked(); pack[7] ^= 71; try { new KeyAddress(pack); fail("must throw error on spoiled address"); } catch(KeyAddress.IllegalAddressException e) { } }
@Test public void serialize() throws IOException { KeyAddress a = key1.address(true, 8); KeyAddress b = key1.address(false, 9); Boss.Reader r = new Boss.Reader(Boss.dump(a,b).toArray()); KeyAddress x = r.read(); KeyAddress y = r.read(); assertEquals(8, x.getTypeMark()); assertEquals(9, y.getTypeMark()); assertTrue(x.isMatchingKey(key1)); assertTrue(y.isMatchingKeyAddress(b)); } }