当前位置: 首页>>代码示例>>Java>>正文


Java CoapEndpoint.start方法代码示例

本文整理汇总了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;
	}
 
开发者ID:erwah,项目名称:acetest,代码行数:25,代码来源:DTLSUtils.java

示例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();
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:23,代码来源:RegistrationTest.java

示例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;
	}
 
开发者ID:erwah,项目名称:acetest,代码行数:43,代码来源:DTLSUtils.java


注:本文中的org.eclipse.californium.core.network.CoapEndpoint.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。