Search in sources :

Example 21 with AttributeId

use of org.eclipse.milo.opcua.stack.core.AttributeId in project milo by eclipse.

the class SessionSecurityDiagnosticsVariable method onStartup.

@Override
protected void onStartup() {
    ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
    diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());
    attributeObserver = (node, attributeId, value) -> {
        if (attributeId == AttributeId.Value) {
            DataValue dataValue = (DataValue) value;
            Object o = dataValue.getValue().getValue();
            if (o instanceof Boolean) {
                diagnosticsEnabled.set((Boolean) o);
            }
        }
    };
    diagnosticsNode.getEnabledFlagNode().addAttributeObserver(attributeObserver);
    node.getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        ExtensionObject xo = ExtensionObject.encode(server.getSerializationContext(), session.getSessionSecurityDiagnostics().getSessionSecurityDiagnosticsDataType());
        return new DataValue(new Variant(xo));
    }));
    node.getSessionIdNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        NodeId value = session.getSessionSecurityDiagnostics().getSessionId();
        return new DataValue(new Variant(value));
    }));
    node.getClientUserIdOfSessionNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String value = session.getSessionSecurityDiagnostics().getClientUserIdOfSession();
        return new DataValue(new Variant(value));
    }));
    node.getClientUserIdHistoryNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String[] value = session.getSessionSecurityDiagnostics().getClientUserIdHistory();
        return new DataValue(new Variant(value));
    }));
    node.getAuthenticationMechanismNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String value = session.getSessionSecurityDiagnostics().getAuthenticationMechanism();
        return new DataValue(new Variant(value));
    }));
    node.getEncodingNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String value = session.getSessionSecurityDiagnostics().getEncoding();
        return new DataValue(new Variant(value));
    }));
    node.getTransportProtocolNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String value = session.getSessionSecurityDiagnostics().getTransportProtocol();
        return new DataValue(new Variant(value));
    }));
    node.getSecurityModeNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        MessageSecurityMode value = session.getSessionSecurityDiagnostics().getSecurityMode();
        return new DataValue(new Variant(value));
    }));
    node.getSecurityPolicyUriNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        String value = session.getSessionSecurityDiagnostics().getSecurityPolicyUri();
        return new DataValue(new Variant(value));
    }));
    node.getClientCertificateNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
        ByteString value = session.getSessionSecurityDiagnostics().getClientCertificate();
        return new DataValue(new Variant(value));
    }));
}
Also used : NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) SessionSecurityDiagnosticsTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.SessionSecurityDiagnosticsTypeNode) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) Util.diagnosticValueFilter(org.eclipse.milo.opcua.sdk.server.diagnostics.variables.Util.diagnosticValueFilter) AbstractLifecycle(org.eclipse.milo.opcua.sdk.server.AbstractLifecycle) Session(org.eclipse.milo.opcua.sdk.server.Session) AttributeObserver(org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) ServerDiagnosticsTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerDiagnosticsTypeNode) MessageSecurityMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode) AttributeId(org.eclipse.milo.opcua.stack.core.AttributeId) NoSuchElementException(java.util.NoSuchElementException) Identifiers(org.eclipse.milo.opcua.stack.core.Identifiers) Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) MessageSecurityMode(org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode) ServerDiagnosticsTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerDiagnosticsTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject) ByteString(org.eclipse.milo.opcua.stack.core.types.builtin.ByteString) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

AttributeId (org.eclipse.milo.opcua.stack.core.AttributeId)21 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)19 ArrayList (java.util.ArrayList)14 UaException (org.eclipse.milo.opcua.stack.core.UaException)14 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)14 Identifiers (org.eclipse.milo.opcua.stack.core.Identifiers)11 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)10 ExtensionObject (org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)10 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)10 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)9 ReadResponse (org.eclipse.milo.opcua.stack.core.types.structured.ReadResponse)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)7 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)7 List (java.util.List)6 NoSuchElementException (java.util.NoSuchElementException)6 Reference (org.eclipse.milo.opcua.sdk.core.Reference)6 AbstractLifecycle (org.eclipse.milo.opcua.sdk.server.AbstractLifecycle)6 Session (org.eclipse.milo.opcua.sdk.server.Session)6 Util.diagnosticValueFilter (org.eclipse.milo.opcua.sdk.server.diagnostics.variables.Util.diagnosticValueFilter)6