/** * Gets the client's network socket address. * * @return the source address from the client's most recent CoAP message. */ public InetSocketAddress getSocketAddress() { return identity.getPeerAddress(); }
/** * Gets the client's network port number. * * @return the source port from the client's most recent CoAP message. */ public int getPort() { return identity.getPeerAddress().getPort(); }
/** * Gets the client's network address. * * @return the source address from the client's most recent CoAP message. */ public InetAddress getAddress() { return identity.getPeerAddress().getAddress(); }
public Integer getPort() { return identity.getPeerAddress().getPort(); }
public InetAddress getAddress() { return identity.getPeerAddress().getAddress(); }
public String getUri() { StringBuilder uri = new StringBuilder(); if (identity.isSecure()) uri.append("coaps://"); else uri.append("coap://"); uri.append(identity.getPeerAddress().getAddress().getHostAddress()); uri.append(":"); uri.append(identity.getPeerAddress().getPort()); return uri.toString(); } }
/** * @return <code>true</code> if the given request sender identity is the bootstrap server (same IP address) */ public synchronized boolean isBootstrapServer(Identity identity) { if (bootstrapServerInfo == null) { return false; } return bootstrapServerInfo.getAddress().getAddress() != null && bootstrapServerInfo.getAddress().getAddress().equals(identity.getPeerAddress().getAddress()); } }
public void addListener(String endpoint, CoapMessageListener listener) { Registration registration = registry.getByEndpoint(endpoint); if (registration != null) { listeners.put(toStringAddress(registration.getIdentity().getPeerAddress()), listener); } }
public void removeListener(String endpoint) { Registration registration = registry.getByEndpoint(endpoint); if (registration != null) { listeners.remove(toStringAddress(registration.getIdentity().getPeerAddress())); } }
public static JsonObject serialize(Identity identity) { JsonObject o = Json.object(); o.set(KEY_ADDRESS, identity.getPeerAddress().getHostString()); o.set(KEY_PORT, identity.getPeerAddress().getPort()); if (identity.isPSK()) { o.set(KEY_ID, identity.getPskIdentity()); } else if (identity.isRPK()) { PublicKey publicKey = identity.getRawPublicKey(); o.set(KEY_RPK, Hex.encodeHexString(publicKey.getEncoded())); } else if (identity.isX509()) { o.set(KEY_CN, identity.getX509CommonName()); } return o; }
public static JsonObject serialize(Identity identity) { JsonObject o = Json.object(); o.set(KEY_ADDRESS, identity.getPeerAddress().getHostString()); o.set(KEY_PORT, identity.getPeerAddress().getPort()); if (identity.isPSK()) { o.set(KEY_ID, identity.getPskIdentity()); } else if (identity.isRPK()) { PublicKey publicKey = identity.getRawPublicKey(); o.set(KEY_RPK, Hex.encodeHexString(publicKey.getEncoded())); } else if (identity.isX509()) { o.set(KEY_CN, identity.getX509CommonName()); } return o; }
/** * Create californium endpoint context from leshan identity. * * @param identity leshan identity received on last registration. * @return californium endpoint context for leshan identity */ public static EndpointContext extractContext(Identity identity) { Principal peerIdentity = null; if (identity != null) { if (identity.isPSK()) { peerIdentity = new PreSharedKeyIdentity(identity.getPskIdentity()); } else if (identity.isRPK()) { peerIdentity = new RawPublicKeyIdentity(identity.getRawPublicKey()); } else if (identity.isX509()) { /* simplify distinguished name to CN= part */ peerIdentity = new X500Principal("CN=" + identity.getX509CommonName()); } } return new AddressEndpointContext(identity.getPeerAddress(), peerIdentity); }
DeregisterResponse response = sender.send(server.getIdentity().getPeerAddress(), server.getIdentity().isSecure(), new DeregisterRequest(registrationID), DEREGISTRATION_TIMEOUT); if (response == null) {