本文整理汇总了Java中org.eclipse.californium.core.network.CoapEndpoint.start方法的典型用法代码示例。如果您正苦于以下问题:Java CoapEndpoint.start方法的具体用法?Java CoapEndpoint.start怎么用?Java CoapEndpoint.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.californium.core.network.CoapEndpoint
的用法示例。
在下文中一共展示了CoapEndpoint.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dtlsPSKRequest
import org.eclipse.californium.core.network.CoapEndpoint; //导入方法依赖的package包/类
public static Response dtlsPSKRequest(String uri, String method, byte[] payload, int contentFormat, String pskIdentity, byte[] pskKey) throws Exception {
Request request = Utils.newRequest(method);
request.setURI(uri);
request.setPayload(payload);
request.getOptions().setContentFormat(contentFormat);
DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(0));
builder.setPskStore(new StaticPskStore(pskIdentity, pskKey));
builder.setSupportedCipherSuites(new CipherSuite[] {CipherSuite.TLS_PSK_WITH_AES_128_CCM_8});
DTLSConnector dtlsconnector = new DTLSConnector(builder.build(), null);
NetworkConfig nc = NetworkConfig.getStandard().setInt("COAP_SECURE_PORT", 15686);
dtlsEndpoint = new CoapEndpoint(dtlsconnector, nc);
dtlsEndpoint.start();
// execute request
request.send(dtlsEndpoint);
Response response = request.waitForResponse();
return response;
}
示例2: register_with_invalid_request
import org.eclipse.californium.core.network.CoapEndpoint; //导入方法依赖的package包/类
@Test
public void register_with_invalid_request() throws InterruptedException, IOException {
// Check registration
helper.assertClientNotRegisterered();
// create a register request without the list of supported object
Request coapRequest = new Request(Code.POST);
coapRequest.setDestinationContext(new AddressEndpointContext(helper.server.getUnsecuredAddress()));
coapRequest.getOptions().setContentFormat(ContentFormat.LINK.getCode());
coapRequest.getOptions().addUriPath("rd");
coapRequest.getOptions().addUriQuery("ep=" + helper.currentEndpointIdentifier);
// send request
CoapEndpoint coapEndpoint = new CoapEndpoint(new InetSocketAddress(0));
coapEndpoint.start();
coapEndpoint.sendRequest(coapRequest);
// check response
Response response = coapRequest.waitForResponse(1000);
assertEquals(response.getCode(), org.eclipse.californium.core.coap.CoAP.ResponseCode.BAD_REQUEST);
coapEndpoint.stop();
}
示例3: dtlsRPKRequest
import org.eclipse.californium.core.network.CoapEndpoint; //导入方法依赖的package包/类
public static Response dtlsRPKRequest(String uri, String method, byte[] payload, int contentFormat, JsonWebKey popKey, ArrayList<PublicKey> trustedPublicKeys) throws Exception {
Request request = Utils.newRequest(method);
request.setURI(uri);
request.setPayload(payload);
request.getOptions().setContentFormat(contentFormat);
DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(0));
PublicKey publicKey = null;
PrivateKey privateKey = null;
if(popKey.getKeyType().equalsIgnoreCase("ec")) {
EllipticCurveJsonWebKey ecPopKey = (EllipticCurveJsonWebKey) popKey;
privateKey = ecPopKey.getPrivateKey();
publicKey = ecPopKey.getPublicKey();
}
else if(popKey.getKeyType().equalsIgnoreCase("rsa")) {
RsaJsonWebKey rsaPopKey = (RsaJsonWebKey) popKey;
privateKey = rsaPopKey.getPrivateKey();
publicKey = rsaPopKey.getPublicKey();
}
// use the POP key as the requests identity
builder.setIdentity(privateKey, publicKey);
// authenticate the remote part using PSK
builder.setTrustedPublicKeysStore(trustedPublicKeys);
DTLSConnector dtlsconnector = new DTLSConnector(builder.build(), null);
NetworkConfig nc = NetworkConfig.getStandard().setInt("COAP_SECURE_PORT", 15685);
dtlsEndpoint = new CoapEndpoint(dtlsconnector, nc);
dtlsEndpoint.start();
// execute request
request.send(dtlsEndpoint);
Response response = request.waitForResponse();
return response;
}