org.eclipse.californium.scandium.dtls.pskstore.StaticPskStore Java Examples

The following examples show how to use org.eclipse.californium.scandium.dtls.pskstore.StaticPskStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManagerTradfri.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
void connectBridge() {

        DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder();
        builder.setAddress(new InetSocketAddress(0));
        builder.setPskStore(new StaticPskStore(identity, psk.getBytes()));
        DTLSConnector dtlsConnector = new DTLSConnector(builder.build());
        CoapEndpoint.CoapEndpointBuilder coapbuilder = new CoapEndpoint.CoapEndpointBuilder();
        coapbuilder.setConnector(dtlsConnector);
        coapbuilder.setNetworkConfig(NetworkConfig.getStandard());
        coapEndPoint = coapbuilder.build();
    }
 
Example #2
Source File: TradfriGatewayHandler.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private void establishConnection() {
    TradfriGatewayConfig configuration = getConfigAs(TradfriGatewayConfig.class);

    this.gatewayURI = "coaps://" + configuration.host + ":" + configuration.port + "/" + DEVICES;
    this.gatewayInfoURI = "coaps://" + configuration.host + ":" + configuration.port + "/" + GATEWAY + "/"
            + GATEWAY_DETAILS;
    try {
        URI uri = new URI(gatewayURI);
        deviceClient = new TradfriCoapClient(uri);
    } catch (URISyntaxException e) {
        logger.error("Illegal gateway URI '{}': {}", gatewayURI, e.getMessage());
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
        return;
    }

    DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(0));
    builder.setPskStore(new StaticPskStore(configuration.identity, configuration.preSharedKey.getBytes()));
    dtlsConnector = new DTLSConnector(builder.build(), new InMemoryConnectionStore(100, 60));
    endPoint = new TradfriCoapEndpoint(dtlsConnector, NetworkConfig.getStandard());
    deviceClient.setEndpoint(endPoint);
    updateStatus(ThingStatus.UNKNOWN);

    // schedule a new scan every minute
    scanJob = scheduler.scheduleWithFixedDelay(this::startScan, 0, 1, TimeUnit.MINUTES);
}
 
Example #3
Source File: TradfriGateway.java    From ThingML-Tradfri with Apache License 2.0 4 votes vote down vote up
protected void initCoap() {
	DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(); //new InetSocketAddress(0)
	builder.setPskStore(new StaticPskStore("", security_key.getBytes()));
	coap = new CoapEndpoint(new DTLSConnector(builder.build()), NetworkConfig.getStandard());
}
 
Example #4
Source File: CoapTestBase.java    From hono with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates the client to use for uploading data to the secure endpoint
 * of the CoAP adapter.
 *
 * @param deviceId The device to add a shared secret for.
 * @param tenant The tenant that the device belongs to.
 * @param sharedSecret The secret shared with the CoAP server.
 * @return The client.
 */
protected CoapClient getCoapsClient(final String deviceId, final String tenant, final String sharedSecret) {
    return getCoapsClient(new StaticPskStore(
            IntegrationTestSupport.getUsername(deviceId, tenant),
            sharedSecret.getBytes(StandardCharsets.UTF_8)));
}