Search in sources :

Example 1 with InMemorySecurityStore

use of org.eclipse.leshan.server.impl.InMemorySecurityStore in project leshan by eclipse.

the class LeshanServerBuilderTest method create_server_with_securityStore.

@Test
public void create_server_with_securityStore() {
    builder.setSecurityStore(new InMemorySecurityStore());
    server = builder.build();
    assertNotNull(server.getSecuredAddress());
    assertNotNull(server.getUnsecuredAddress());
    assertNotNull(server.getSecurityStore());
}
Also used : InMemorySecurityStore(org.eclipse.leshan.server.impl.InMemorySecurityStore) Test(org.junit.Test)

Example 2 with InMemorySecurityStore

use of org.eclipse.leshan.server.impl.InMemorySecurityStore in project leshan by eclipse.

the class RedisIntegrationTestHelper method createServer.

@Override
public void createServer() {
    LeshanServerBuilder builder = new LeshanServerBuilder();
    StaticModelProvider modelProvider = new StaticModelProvider(createObjectModels());
    builder.setObjectModelProvider(modelProvider);
    DefaultLwM2mNodeDecoder decoder = new DefaultLwM2mNodeDecoder();
    builder.setDecoder(decoder);
    builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setSecurityStore(new InMemorySecurityStore());
    // Create redis store
    String redisURI = System.getenv("REDIS_URI");
    if (redisURI == null)
        redisURI = "";
    Pool<Jedis> jedis = new JedisPool(redisURI);
    builder.setRegistrationStore(new RedisRegistrationStore(jedis));
    // Build server !
    server = builder.build();
    // monitor client registration
    resetLatch();
    server.getRegistrationService().addListener(new RegistrationListener() {

        @Override
        public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) {
            if (updatedRegistration.getEndpoint().equals(getCurrentEndpoint())) {
                updateLatch.countDown();
            }
        }

        @Override
        public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) {
            if (registration.getEndpoint().equals(getCurrentEndpoint())) {
                deregisterLatch.countDown();
            }
        }

        @Override
        public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) {
            if (registration.getEndpoint().equals(getCurrentEndpoint())) {
                last_registration = registration;
                registerLatch.countDown();
            }
        }
    });
}
Also used : StaticModelProvider(org.eclipse.leshan.server.model.StaticModelProvider) RegistrationListener(org.eclipse.leshan.server.registration.RegistrationListener) InetSocketAddress(java.net.InetSocketAddress) Jedis(redis.clients.jedis.Jedis) LeshanServerBuilder(org.eclipse.leshan.server.californium.LeshanServerBuilder) InMemorySecurityStore(org.eclipse.leshan.server.impl.InMemorySecurityStore) DefaultLwM2mNodeDecoder(org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder) Registration(org.eclipse.leshan.server.registration.Registration) RedisRegistrationStore(org.eclipse.leshan.server.cluster.RedisRegistrationStore) Observation(org.eclipse.leshan.core.observation.Observation) JedisPool(redis.clients.jedis.JedisPool) RegistrationUpdate(org.eclipse.leshan.server.registration.RegistrationUpdate)

Example 3 with InMemorySecurityStore

use of org.eclipse.leshan.server.impl.InMemorySecurityStore in project leshan by eclipse.

the class SecureIntegrationTestHelper method createServerWithRPK.

public void createServerWithRPK() {
    LeshanServerBuilder builder = new LeshanServerBuilder();
    builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setPublicKey(serverPublicKey);
    builder.setPrivateKey(serverPrivateKey);
    builder.setSecurityStore(new InMemorySecurityStore());
    server = builder.build();
    // monitor client registration
    setupRegistrationMonitoring();
}
Also used : LeshanServerBuilder(org.eclipse.leshan.server.californium.LeshanServerBuilder) InMemorySecurityStore(org.eclipse.leshan.server.impl.InMemorySecurityStore) InetSocketAddress(java.net.InetSocketAddress)

Example 4 with InMemorySecurityStore

use of org.eclipse.leshan.server.impl.InMemorySecurityStore in project leshan by eclipse.

the class IntegrationTestHelper method createServerBuilder.

protected LeshanServerBuilder createServerBuilder() {
    LeshanServerBuilder builder = new LeshanServerBuilder();
    builder.setObjectModelProvider(new StaticModelProvider(createObjectModels()));
    builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setSecurityStore(new InMemorySecurityStore());
    return builder;
}
Also used : StaticModelProvider(org.eclipse.leshan.server.model.StaticModelProvider) LeshanServerBuilder(org.eclipse.leshan.server.californium.LeshanServerBuilder) InMemorySecurityStore(org.eclipse.leshan.server.impl.InMemorySecurityStore) InetSocketAddress(java.net.InetSocketAddress)

Example 5 with InMemorySecurityStore

use of org.eclipse.leshan.server.impl.InMemorySecurityStore in project leshan by eclipse.

the class SecureIntegrationTestHelper method createServerWithX509Cert.

public void createServerWithX509Cert(Certificate[] trustedCertificates) {
    LeshanServerBuilder builder = new LeshanServerBuilder();
    builder.setLocalAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setLocalSecureAddress(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
    builder.setPrivateKey(serverPrivateKeyFromCert);
    builder.setCertificateChain(serverX509CertChain);
    builder.setTrustedCertificates(trustedCertificates);
    builder.setSecurityStore(new InMemorySecurityStore());
    server = builder.build();
    // monitor client registration
    setupRegistrationMonitoring();
}
Also used : LeshanServerBuilder(org.eclipse.leshan.server.californium.LeshanServerBuilder) InMemorySecurityStore(org.eclipse.leshan.server.impl.InMemorySecurityStore) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

InMemorySecurityStore (org.eclipse.leshan.server.impl.InMemorySecurityStore)7 InetSocketAddress (java.net.InetSocketAddress)4 LeshanServerBuilder (org.eclipse.leshan.server.californium.LeshanServerBuilder)4 Test (org.junit.Test)3 StaticModelProvider (org.eclipse.leshan.server.model.StaticModelProvider)2 DefaultLwM2mNodeDecoder (org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder)1 Observation (org.eclipse.leshan.core.observation.Observation)1 RedisRegistrationStore (org.eclipse.leshan.server.cluster.RedisRegistrationStore)1 Registration (org.eclipse.leshan.server.registration.Registration)1 RegistrationListener (org.eclipse.leshan.server.registration.RegistrationListener)1 RegistrationUpdate (org.eclipse.leshan.server.registration.RegistrationUpdate)1 Jedis (redis.clients.jedis.Jedis)1 JedisPool (redis.clients.jedis.JedisPool)1