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


Java NonUniqueSecurityInfoException类代码示例

本文整理汇总了Java中org.eclipse.leshan.server.security.NonUniqueSecurityInfoException的典型用法代码示例。如果您正苦于以下问题:Java NonUniqueSecurityInfoException类的具体用法?Java NonUniqueSecurityInfoException怎么用?Java NonUniqueSecurityInfoException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NonUniqueSecurityInfoException类属于org.eclipse.leshan.server.security包,在下文中一共展示了NonUniqueSecurityInfoException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addToRegistry

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
private SecurityInfo addToRegistry(SecurityInfo info) throws NonUniqueSecurityInfoException {
    writeLock.lock();
    try {
        String identity = info.getIdentity();
        if (identity != null) {
            SecurityInfo infoByIdentity = securityByIdentity.get(info.getIdentity());
            if (infoByIdentity != null && !info.getEndpoint().equals(infoByIdentity.getEndpoint())) {
                throw new NonUniqueSecurityInfoException("PSK Identity " + info.getIdentity() + " is already used");
            }

            securityByIdentity.put(info.getIdentity(), info);
        }

        SecurityInfo previous = securityByEp.put(info.getEndpoint(), info);

        return previous;
    } finally {
        writeLock.unlock();
    }
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:21,代码来源:SecurityRegistryImpl.java

示例2: loadFromFile

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
protected void loadFromFile() {
    File file = new File(filename);
    if (!file.exists()) {
        return;
    }

    try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));) {
        SecurityInfo[] infos = (SecurityInfo[]) in.readObject();

        if (infos != null) {
            for (SecurityInfo info : infos) {
                addToRegistry(info);
            }
            if (infos.length > 0) {
                LOG.debug("{} security infos loaded", infos.length);
            }
        }
    } catch (NonUniqueSecurityInfoException | IOException | ClassNotFoundException e) {
        LOG.error("Could not load security infos from file", e);
    }
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:22,代码来源:SecurityRegistryImpl.java

示例3: add

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Override
public SecurityInfo add(SecurityInfo info) throws NonUniqueSecurityInfoException {
    writeLock.lock();
    try {
        String identity = info.getIdentity();
        if (identity != null) {
            SecurityInfo infoByIdentity = securityByIdentity.get(info.getIdentity());
            if (infoByIdentity != null && !info.getEndpoint().equals(infoByIdentity.getEndpoint())) {
                throw new NonUniqueSecurityInfoException("PSK Identity " + info.getIdentity() + " is already used");
            }

            securityByIdentity.put(info.getIdentity(), info);
        }

        SecurityInfo previous = securityByEp.put(info.getEndpoint(), info);
        String previousIdentity = previous == null ? null : previous.getIdentity();
        if (previousIdentity != null && !previousIdentity.equals(identity)) {
            securityByIdentity.remove(previousIdentity);
        }

        return previous;
    } finally {
        writeLock.unlock();
    }
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:26,代码来源:InMemorySecurityStore.java

示例4: loadFromFile

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
protected void loadFromFile() {
    File file = new File(filename);
    if (!file.exists()) {
        return;
    }

    try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));) {
        SecurityInfo[] infos = (SecurityInfo[]) in.readObject();

        if (infos != null) {
            for (SecurityInfo info : infos) {
                addToStore(info);
            }
            if (infos.length > 0) {
                LOG.debug("{} security infos loaded", infos.length);
            }
        }
    } catch (NonUniqueSecurityInfoException | IOException | ClassNotFoundException e) {
        LOG.error("Could not load security infos from file", e);
    }
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:22,代码来源:FileSecurityStore.java

示例5: registered_device_with_psk_to_server_with_psk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Test
public void registered_device_with_psk_to_server_with_psk() throws NonUniqueSecurityInfoException {
    // Create PSK server & start it
    helper.createServer(); // default server support PSK
    helper.server.start();

    // Create PSK Client
    helper.createPSKClient();

    // Add client credentials to the server
    helper.getSecurityStore()
            .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, GOOD_PSK_KEY));

    // Check client is not registered
    helper.assertClientNotRegisterered();

    // Start it and wait for registration
    helper.client.start();
    helper.waitForRegistration(1);

    // Check client is well registered
    helper.assertClientRegisterered();
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:24,代码来源:SecurityTest.java

示例6: registered_device_with_bad_psk_identity_to_server_with_psk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Test
public void registered_device_with_bad_psk_identity_to_server_with_psk() throws NonUniqueSecurityInfoException {
    // Create PSK server & start it
    helper.createServer(); // default server support PSK
    helper.server.start();

    // Create PSK Client
    helper.createPSKClient();

    // Add client credentials with BAD PSK ID to the server
    helper.getSecurityStore()
            .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), BAD_PSK_ID, GOOD_PSK_KEY));

    // Check client can not register
    helper.assertClientNotRegisterered();
    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:19,代码来源:SecurityTest.java

示例7: registered_device_with_bad_psk_key_to_server_with_psk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Test
public void registered_device_with_bad_psk_key_to_server_with_psk() throws NonUniqueSecurityInfoException {
    // Create PSK server & start it
    helper.createServer(); // default server support PSK
    helper.server.start();

    // Create PSK Client
    helper.createPSKClient();

    // Add client credentials with BAD PSK KEY to the server
    helper.getSecurityStore()
            .add(SecurityInfo.newPreSharedKeyInfo(helper.getCurrentEndpoint(), GOOD_PSK_ID, BAD_PSK_KEY));

    // Check client can not register
    helper.assertClientNotRegisterered();
    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:19,代码来源:SecurityTest.java

示例8: registered_device_with_psk_and_bad_endpoint_to_server_with_psk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Test
public void registered_device_with_psk_and_bad_endpoint_to_server_with_psk() throws NonUniqueSecurityInfoException {
    // Create PSK server & start it
    helper.createServer(); // default server support PSK
    helper.server.start();

    // Create PSK Client
    helper.createPSKClient();

    // Add client credentials for another endpoint to the server
    helper.getSecurityStore().add(SecurityInfo.newPreSharedKeyInfo(BAD_ENDPOINT, GOOD_PSK_ID, GOOD_PSK_KEY));

    // Check client can not register
    helper.assertClientNotRegisterered();
    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java

示例9: change_psk_identity_cleanup

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Test
public void change_psk_identity_cleanup() throws NonUniqueSecurityInfoException {
    helper.createServer();
    helper.server.start();

    EditableSecurityStore ess = helper.getSecurityStore();

    ess.add(SecurityInfo.newPreSharedKeyInfo(GOOD_ENDPOINT, BAD_PSK_ID, BAD_PSK_KEY));
    // Change PSK id for endpoint
    ess.add(SecurityInfo.newPreSharedKeyInfo(GOOD_ENDPOINT, GOOD_PSK_ID, GOOD_PSK_KEY));
    // Original/old PSK id should not be reserved any more
    try {
        ess.add(SecurityInfo.newPreSharedKeyInfo(BAD_ENDPOINT, BAD_PSK_ID, BAD_PSK_KEY));
    } catch (NonUniqueSecurityInfoException e) {
        fail("PSK identity change for existing endpoint should have cleaned up old PSK identity");
    }
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java

示例10: registered_device_with_rpk_to_server_with_rpk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement RPK support for client
@Test
public void registered_device_with_rpk_to_server_with_rpk() throws NonUniqueSecurityInfoException {
    helper.createServerWithRPK();
    helper.server.start();

    helper.createRPKClient();

    helper.getSecurityStore()
            .add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(), helper.clientPublicKey));

    helper.assertClientNotRegisterered();
    helper.client.start();
    helper.waitForRegistration(1);

    assertNotNull(helper.getCurrentRegistration());
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:19,代码来源:SecurityTest.java

示例11: registered_device_with_bad_rpk_to_server_with_rpk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement RPK support for client
@Test
public void registered_device_with_bad_rpk_to_server_with_rpk() throws NonUniqueSecurityInfoException {
    helper.createServerWithRPK();
    helper.server.start();

    helper.createRPKClient();

    // as it is complex to create a public key, I use the server one :p as bad client public key
    PublicKey bad_client_public_key = helper.getServerPublicKey();
    helper.getSecurityStore()
            .add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(), bad_client_public_key));

    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java

示例12: registered_device_with_x509cert_to_server_with_x509cert

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement X509 support for client
@Test
public void registered_device_with_x509cert_to_server_with_x509cert() throws NonUniqueSecurityInfoException {
    helper.createServerWithX509Cert(helper.trustedCertificates);
    helper.server.start();

    helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);

    helper.getSecurityStore().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));

    helper.assertClientNotRegisterered();
    helper.client.start();
    helper.waitForRegistration(1);

    assertNotNull(helper.getCurrentRegistration());
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java

示例13: registered_device_with_x509cert_and_bad_private_key_to_server_with_x509cert

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement X509 support for client
@Test
public void registered_device_with_x509cert_and_bad_private_key_to_server_with_x509cert()
        throws NonUniqueSecurityInfoException {
    helper.createServerWithX509Cert(helper.trustedCertificates);
    helper.server.start();

    // we use the server private key as bad key, this key will not be compatible with the client certificate
    PrivateKey badPrivateKey = helper.serverPrivateKey;

    helper.createX509CertClient(badPrivateKey, helper.trustedCertificates);
    helper.getSecurityStore().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));

    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java

示例14: registered_device_with_x509cert_and_untrusted_CA_to_server_with_x509cert

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement X509 support for client
@Test
public void registered_device_with_x509cert_and_untrusted_CA_to_server_with_x509cert()
        throws NonUniqueSecurityInfoException {
    // the server will not trust the client Certificate authority
    helper.createServerWithX509Cert(new Certificate[] { helper.serverCAX509Cert });
    helper.server.start();

    helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);

    helper.getSecurityStore().add(SecurityInfo.newX509CertInfo(helper.getCurrentEndpoint()));

    helper.client.start();
    helper.ensureNoRegistration(1);
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:17,代码来源:SecurityTest.java

示例15: registered_device_with_x509cert_to_server_with_rpk

import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException; //导入依赖的package包/类
@Ignore
// TODO implement X509 support for client
@Test
public void registered_device_with_x509cert_to_server_with_rpk() throws NonUniqueSecurityInfoException {
    helper.createServerWithRPK();
    helper.server.start();

    helper.createX509CertClient(helper.clientPrivateKeyFromCert, helper.trustedCertificates);

    helper.getSecurityStore().add(SecurityInfo.newRawPublicKeyInfo(helper.getCurrentEndpoint(),
            helper.clientX509CertChain[0].getPublicKey()));

    helper.client.start();
    helper.waitForRegistration(1);

    assertNotNull(helper.getCurrentRegistration());
}
 
开发者ID:eclipse,项目名称:leshan,代码行数:18,代码来源:SecurityTest.java


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