本文整理汇总了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();
});
示例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;
}