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


TypeScript OPCUAServer.initialize方法代码示例

本文整理汇总了TypeScript中node-opcua-server.OPCUAServer.initialize方法的典型用法代码示例。如果您正苦于以下问题:TypeScript OPCUAServer.initialize方法的具体用法?TypeScript OPCUAServer.initialize怎么用?TypeScript OPCUAServer.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node-opcua-server.OPCUAServer的用法示例。


在下文中一共展示了OPCUAServer.initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it("SCT-1 should modify a server to support push certificate management", async () => {

        const server = new OPCUAServer({
            port: 20000,
            serverCertificateManager: certificateManager,
            userCertificateManager: certificateManager
        });

        await server.initialize();

        await installPushCertificateManagementOnServer(server);

        const privateKey1PEM = await promisify(fs.readFile)(server.serverCertificateManager.privateKey, "utf8");
        const privateKey1 = convertPEMtoDER(privateKey1PEM);
        const privateKey2 = convertPEMtoDER(server.getPrivateKey());
        privateKey1.toString("base64").should.eql(privateKey2.toString("base64"));

        // now start the server
        await server.start();

        // now stop the server
        await server.shutdown();
    });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:23,代码来源:test_server_with_push_certificate_management.ts

示例2: constructServerWithPushCertificate

    async function constructServerWithPushCertificate(): Promise<OPCUAServer> {

        // given that the server user manager is able to identify a  system administrator
        const mockUserManager = {

            isValidUser: (userName: string, password: string) => {

                if (userName === "admin" && password === "secret") {
                    return true;
                }
                return false;
            },

            // see OPCUA 1.04 part 3 4.8.2 Well know role
            // Anonymous          The Role has very limited access for use when a Session has anonymous credentials.
            // AuthenticatedUser  The Role has limited access for use when a Session has valid non-anonymous credentials
            //                    but has not been explicitly granted access to a Role.
            // Observer           The Role is allowed to browse, read live data, read historical data/events or subscribe to
            //                    data/events.
            // Operator           The Role is allowed to browse, read live data, read historical data/events or subscribe to
            //                    data/events.
            //                    In addition, the Session is allowed to write some live data and call some Methods.
            // Engineer           The Role is allowed to browse, read/write configuration data, read historical data/events,
            //                    call Methods or subscribe to data/events.
            // Supervisor         The Role is allowed to browse, read live data, read historical data/events, call Methods
            //                    or subscribe to data/events.
            // ConfigureAdmin     The Role is allowed to change the non-security related configuration settings.
            // SecurityAdmin      The Role is allowed to change security related settings.

            getUserRole(username: string): string {
                if (username === "anonymous") {
                    return "Anonymous";
                }
                if (username === "admin") {
                    return "AuthenticatedUser;SecurityAdmin";
                }
                return "None";
            }

        };

        const server = new OPCUAServer({

            port: 2010,

            nodeset_filename: nodesets.standard,
            userManager: mockUserManager,

            serverCertificateManager: certificateManager,
            userCertificateManager: certificateManager
        });
        await server.initialize();

        verifyServer(server);

        await installPushCertificateManagementOnServer(server);
        debugLog("private key location =  ", server.serverCertificateManager.privateKey);

        verifyServer(server);

        // Given that the server is configured to trust client certificate
        const clientCertificatePEM = await promisify(fs.readFile)(clientCertificateFile, "utf8");
        const clientCertificateDER = convertPEMtoDER(clientCertificatePEM);
        await server.serverCertificateManager.trustCertificate(clientCertificateDER);

        // also trusted newest certificate

        return server;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:69,代码来源:test_server_with_push_certificate_management.ts


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