├── .gitignore ├── Changelog.txt ├── LICENSE.txt ├── README.md ├── codegen ├── .gitignore ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── opcfoundation │ │ └── ua │ │ └── codegen │ │ ├── BuiltinsMap.java │ │ ├── DOMUtils.java │ │ ├── DictionaryTypes.java │ │ ├── DictionaryTypes2.java │ │ ├── EngineeringUnitsUtil.java │ │ ├── IdentifiersUtil.java │ │ ├── JavaUtils.java │ │ ├── Main2.java │ │ ├── OverrideUtil.java │ │ ├── ResourceFileFixerUtil.java │ │ ├── ServiceSetUtil.java │ │ └── Template.java │ └── resources │ └── codegen_data │ ├── data │ ├── ServiceSets.csv │ ├── StandardTypes.csv │ ├── UA Attributes.xml │ ├── UA Defined Types.xml │ ├── UA Status Codes.csv │ ├── UA Status Codes.xml │ ├── UNECE_rec20_Rev10e_2014_utf16.txt │ └── ext-UA Defined Types.xml │ ├── overrides │ ├── AccessLevel.java │ ├── BrowseDescription.java │ ├── EndpointConfiguration.java │ ├── EndpointDescription.java │ ├── HistoryReadValueId.java │ ├── MessageSecurityMode.java │ ├── ReadAtTimeDetails.java.not │ ├── ReadValueId.java.not │ ├── ServiceFault.java │ ├── UserTokenPolicy.java │ └── WriteValue.java │ └── templates │ ├── ChannelServiceTemplate.java │ ├── ComplexTypeTemplate.java │ ├── IdentifiersTemplate.java │ ├── InternalIdentifiersTemplate.java │ ├── PackedEnumTemplate.java │ ├── RequestTemplate.java │ ├── ResponseTemplate.java │ ├── SerializerTemplate.java │ ├── ServiceSetTemplate.java │ ├── SparseEnumTemplate.java │ ├── StandardEngineeringUnitsTemplate.java │ └── Template.java ├── examples ├── basic │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── assembly │ │ └── assembly.xml │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── opcfoundation │ │ │ └── ua │ │ │ └── examples │ │ │ ├── BigCertificateExample.java │ │ │ ├── ClientExample1.java │ │ │ ├── ClientServerExample.java │ │ │ ├── DiscoveryExample.java │ │ │ ├── GenerateCertificateExample.java │ │ │ ├── NanoServer.java │ │ │ ├── ReverseHelloClientServerExample.java │ │ │ ├── SampleClient.java │ │ │ ├── ServerExample1.java │ │ │ └── certs │ │ │ └── ExampleKeys.java │ │ └── resources │ │ ├── logback.xml │ │ └── org │ │ └── opcfoundation │ │ └── ua │ │ └── examples │ │ ├── certs │ │ └── keystore.p12 │ │ └── my.store └── publisher │ ├── README.md │ ├── pom.xml │ └── src │ └── main │ └── java │ └── samples │ └── com │ └── microsoft │ └── azure │ └── iothub │ └── ClientPublisher.java ├── graveyard ├── README.md ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── opcfoundation │ └── ua │ ├── transport │ └── security │ │ ├── SunJceCertificateProvider.java │ │ └── SunJceCryptoProvider.java │ └── utils │ └── SunJceUtils.java ├── license ├── LICENSE.apache ├── LICENSE.bouncycastle ├── LICENSE.junit └── LICENSE.slf4j ├── pom.xml └── src ├── assembly ├── dependencies.xml └── project.xml ├── main ├── java │ └── org │ │ └── opcfoundation │ │ └── ua │ │ ├── application │ │ ├── AbstractServiceHandler.java │ │ ├── Application.java │ │ ├── Client.java │ │ ├── EndpointDiscoveryService.java │ │ ├── Server.java │ │ ├── ServerDiscoveryService.java │ │ ├── ServiceHandler.java │ │ ├── ServiceHandlerComposition.java │ │ ├── Session.java │ │ ├── SessionChannel.java │ │ └── package-info.java │ │ ├── builtintypes │ │ ├── BuiltinsMap.java │ │ ├── ByteString.java │ │ ├── DataTypes.java │ │ ├── DataValue.java │ │ ├── DateTime.java │ │ ├── DiagnosticInfo.java │ │ ├── Enumeration.java │ │ ├── ExpandedNodeId.java │ │ ├── ExtensionObject.java │ │ ├── LocalizedText.java │ │ ├── NodeId.java │ │ ├── NodeReference.java │ │ ├── QualifiedName.java │ │ ├── ServiceRequest.java │ │ ├── ServiceResponse.java │ │ ├── ServiceResult.java │ │ ├── StatusCode.java │ │ ├── Structure.java │ │ ├── UnsignedByte.java │ │ ├── UnsignedInteger.java │ │ ├── UnsignedLong.java │ │ ├── UnsignedShort.java │ │ ├── Variant.java │ │ ├── XmlElement.java │ │ └── package-info.java │ │ ├── cert │ │ ├── CertificateCheck.java │ │ ├── CertificateStore.java │ │ ├── DefaultCertificateStoreListener.java │ │ ├── DefaultCertificateValidator.java │ │ ├── DefaultCertificateValidatorListener.java │ │ ├── PkiDirectoryCertificateStore.java │ │ └── ValidationResult.java │ │ ├── common │ │ ├── DebugLogger.java │ │ ├── IdentifierDescriptions.java │ │ ├── NamespaceTable.java │ │ ├── RuntimeServiceResultException.java │ │ ├── ServerTable.java │ │ ├── ServiceFaultException.java │ │ ├── ServiceResultException.java │ │ ├── StatusCodeDescriptions.java │ │ ├── UriTable.java │ │ └── package-info.java │ │ ├── core │ │ ├── AccessLevel.java │ │ ├── ActivateSessionRequest.java │ │ ├── ActivateSessionResponse.java │ │ ├── AddNodesItem.java │ │ ├── AddNodesRequest.java │ │ ├── AddNodesResponse.java │ │ ├── AddNodesResult.java │ │ ├── AddReferencesItem.java │ │ ├── AddReferencesRequest.java │ │ ├── AddReferencesResponse.java │ │ ├── AggregateConfiguration.java │ │ ├── AggregateFilter.java │ │ ├── AggregateFilterResult.java │ │ ├── Annotation.java │ │ ├── AnonymousIdentityToken.java │ │ ├── ApplicationDescription.java │ │ ├── ApplicationType.java │ │ ├── Argument.java │ │ ├── AttributeOperand.java │ │ ├── AttributeServiceSetHandler.java │ │ ├── AttributeWriteMask.java │ │ ├── Attributes.java │ │ ├── AxisInformation.java │ │ ├── AxisScaleEnumeration.java │ │ ├── BrokerConnectionTransportDataType.java │ │ ├── BrokerDataSetReaderTransportDataType.java │ │ ├── BrokerDataSetWriterTransportDataType.java │ │ ├── BrokerTransportQualityOfService.java │ │ ├── BrokerWriterGroupTransportDataType.java │ │ ├── BrowseDescription.java │ │ ├── BrowseDirection.java │ │ ├── BrowseNextRequest.java │ │ ├── BrowseNextResponse.java │ │ ├── BrowsePath.java │ │ ├── BrowsePathResult.java │ │ ├── BrowsePathTarget.java │ │ ├── BrowseRequest.java │ │ ├── BrowseResponse.java │ │ ├── BrowseResult.java │ │ ├── BrowseResultMask.java │ │ ├── BuildInfo.java │ │ ├── CallMethodRequest.java │ │ ├── CallMethodResult.java │ │ ├── CallRequest.java │ │ ├── CallResponse.java │ │ ├── CancelRequest.java │ │ ├── CancelResponse.java │ │ ├── ChannelSecurityToken.java │ │ ├── CloseSecureChannelRequest.java │ │ ├── CloseSecureChannelResponse.java │ │ ├── CloseSessionRequest.java │ │ ├── CloseSessionResponse.java │ │ ├── ComplexNumberType.java │ │ ├── ConfigurationVersionDataType.java │ │ ├── ConnectionTransportDataType.java │ │ ├── ContentFilter.java │ │ ├── ContentFilterElement.java │ │ ├── ContentFilterElementResult.java │ │ ├── ContentFilterResult.java │ │ ├── CreateMonitoredItemsRequest.java │ │ ├── CreateMonitoredItemsResponse.java │ │ ├── CreateSessionRequest.java │ │ ├── CreateSessionResponse.java │ │ ├── CreateSubscriptionRequest.java │ │ ├── CreateSubscriptionResponse.java │ │ ├── DataChangeFilter.java │ │ ├── DataChangeNotification.java │ │ ├── DataChangeTrigger.java │ │ ├── DataSetMetaDataType.java │ │ ├── DataSetOrderingType.java │ │ ├── DataSetReaderDataType.java │ │ ├── DataSetReaderMessageDataType.java │ │ ├── DataSetReaderTransportDataType.java │ │ ├── DataSetWriterDataType.java │ │ ├── DataSetWriterMessageDataType.java │ │ ├── DataSetWriterTransportDataType.java │ │ ├── DataTypeAttributes.java │ │ ├── DataTypeDefinition.java │ │ ├── DataTypeDescription.java │ │ ├── DataTypeSchemaHeader.java │ │ ├── DatagramConnectionTransportDataType.java │ │ ├── DatagramWriterGroupTransportDataType.java │ │ ├── DeadbandType.java │ │ ├── DeleteAtTimeDetails.java │ │ ├── DeleteEventDetails.java │ │ ├── DeleteMonitoredItemsRequest.java │ │ ├── DeleteMonitoredItemsResponse.java │ │ ├── DeleteNodesItem.java │ │ ├── DeleteNodesRequest.java │ │ ├── DeleteNodesResponse.java │ │ ├── DeleteRawModifiedDetails.java │ │ ├── DeleteReferencesItem.java │ │ ├── DeleteReferencesRequest.java │ │ ├── DeleteReferencesResponse.java │ │ ├── DeleteSubscriptionsRequest.java │ │ ├── DeleteSubscriptionsResponse.java │ │ ├── DiagnosticsLevel.java │ │ ├── DiscoveryConfiguration.java │ │ ├── DiscoveryServiceSetHandler.java │ │ ├── DoubleComplexNumberType.java │ │ ├── EUInformation.java │ │ ├── ElementOperand.java │ │ ├── EncodeableSerializer.java │ │ ├── EndpointConfiguration.java │ │ ├── EndpointDescription.java │ │ ├── EndpointType.java │ │ ├── EndpointUrlListDataType.java │ │ ├── EnumDefinition.java │ │ ├── EnumDescription.java │ │ ├── EnumField.java │ │ ├── EnumValueType.java │ │ ├── EventFieldList.java │ │ ├── EventFilter.java │ │ ├── EventFilterResult.java │ │ ├── EventNotificationList.java │ │ ├── ExceptionDeviationFormat.java │ │ ├── FieldMetaData.java │ │ ├── FieldTargetDataType.java │ │ ├── FilterOperand.java │ │ ├── FilterOperator.java │ │ ├── FindServersOnNetworkRequest.java │ │ ├── FindServersOnNetworkResponse.java │ │ ├── FindServersRequest.java │ │ ├── FindServersResponse.java │ │ ├── GenericAttributeValue.java │ │ ├── GenericAttributes.java │ │ ├── GetEndpointsRequest.java │ │ ├── GetEndpointsResponse.java │ │ ├── HistoryData.java │ │ ├── HistoryEvent.java │ │ ├── HistoryEventFieldList.java │ │ ├── HistoryModifiedData.java │ │ ├── HistoryReadDetails.java │ │ ├── HistoryReadRequest.java │ │ ├── HistoryReadResponse.java │ │ ├── HistoryReadResult.java │ │ ├── HistoryReadValueId.java │ │ ├── HistoryUpdateDetails.java │ │ ├── HistoryUpdateRequest.java │ │ ├── HistoryUpdateResponse.java │ │ ├── HistoryUpdateResult.java │ │ ├── HistoryUpdateType.java │ │ ├── IdType.java │ │ ├── Identifiers.java │ │ ├── IdentityCriteriaType.java │ │ ├── IdentityMappingRuleType.java │ │ ├── InternalIdentifiers0.java │ │ ├── InternalIdentifiers1.java │ │ ├── InternalIdentifiers2.java │ │ ├── IssuedIdentityToken.java │ │ ├── JsonDataSetReaderMessageDataType.java │ │ ├── JsonDataSetWriterMessageDataType.java │ │ ├── JsonWriterGroupMessageDataType.java │ │ ├── KeyValuePair.java │ │ ├── LiteralOperand.java │ │ ├── MdnsDiscoveryConfiguration.java │ │ ├── MessageSecurityMode.java │ │ ├── MethodAttributes.java │ │ ├── MethodServiceSetHandler.java │ │ ├── ModelChangeStructureDataType.java │ │ ├── ModelChangeStructureVerbMask.java │ │ ├── ModificationInfo.java │ │ ├── ModifyMonitoredItemsRequest.java │ │ ├── ModifyMonitoredItemsResponse.java │ │ ├── ModifySubscriptionRequest.java │ │ ├── ModifySubscriptionResponse.java │ │ ├── MonitoredItemCreateRequest.java │ │ ├── MonitoredItemCreateResult.java │ │ ├── MonitoredItemModifyRequest.java │ │ ├── MonitoredItemModifyResult.java │ │ ├── MonitoredItemNotification.java │ │ ├── MonitoredItemServiceSetHandler.java │ │ ├── MonitoringFilter.java │ │ ├── MonitoringFilterResult.java │ │ ├── MonitoringMode.java │ │ ├── MonitoringParameters.java │ │ ├── NamingRuleType.java │ │ ├── NetworkAddressDataType.java │ │ ├── NetworkAddressUrlDataType.java │ │ ├── NetworkGroupDataType.java │ │ ├── NodeAttributes.java │ │ ├── NodeAttributesMask.java │ │ ├── NodeClass.java │ │ ├── NodeManagementServiceSetHandler.java │ │ ├── NodeReference.java │ │ ├── NodeTypeDescription.java │ │ ├── NotificationData.java │ │ ├── NotificationMessage.java │ │ ├── ObjectAttributes.java │ │ ├── ObjectTypeAttributes.java │ │ ├── OpenFileMode.java │ │ ├── OpenSecureChannelRequest.java │ │ ├── OpenSecureChannelResponse.java │ │ ├── OptionSet.java │ │ ├── OverrideValueHandling.java │ │ ├── ParsingResult.java │ │ ├── PerformUpdateType.java │ │ ├── ProgramDiagnostic2DataType.java │ │ ├── ProgramDiagnosticDataType.java │ │ ├── PubSubConfigurationDataType.java │ │ ├── PubSubConnectionDataType.java │ │ ├── PubSubDiagnosticsCounterClassification.java │ │ ├── PubSubGroupDataType.java │ │ ├── PubSubState.java │ │ ├── PublishRequest.java │ │ ├── PublishResponse.java │ │ ├── PublishedDataItemsDataType.java │ │ ├── PublishedDataSetDataType.java │ │ ├── PublishedDataSetSourceDataType.java │ │ ├── PublishedEventsDataType.java │ │ ├── PublishedVariableDataType.java │ │ ├── QueryDataDescription.java │ │ ├── QueryDataSet.java │ │ ├── QueryFirstRequest.java │ │ ├── QueryFirstResponse.java │ │ ├── QueryNextRequest.java │ │ ├── QueryNextResponse.java │ │ ├── Range.java │ │ ├── ReadAtTimeDetails.java │ │ ├── ReadEventDetails.java │ │ ├── ReadProcessedDetails.java │ │ ├── ReadRawModifiedDetails.java │ │ ├── ReadRequest.java │ │ ├── ReadResponse.java │ │ ├── ReadValueId.java │ │ ├── ReaderGroupDataType.java │ │ ├── ReaderGroupMessageDataType.java │ │ ├── ReaderGroupTransportDataType.java │ │ ├── RedundancySupport.java │ │ ├── RedundantServerDataType.java │ │ ├── ReferenceDescription.java │ │ ├── ReferenceNode.java │ │ ├── ReferenceTypeAttributes.java │ │ ├── RegisterNodesRequest.java │ │ ├── RegisterNodesResponse.java │ │ ├── RegisterServer2Request.java │ │ ├── RegisterServer2Response.java │ │ ├── RegisterServerRequest.java │ │ ├── RegisterServerResponse.java │ │ ├── RegisteredServer.java │ │ ├── RelativePath.java │ │ ├── RelativePathElement.java │ │ ├── RepublishRequest.java │ │ ├── RepublishResponse.java │ │ ├── RequestHeader.java │ │ ├── ResponseHeader.java │ │ ├── RolePermissionType.java │ │ ├── SamplingIntervalDiagnosticsDataType.java │ │ ├── SecureChannelServiceSetHandler.java │ │ ├── SecurityTokenRequestType.java │ │ ├── SemanticChangeStructureDataType.java │ │ ├── ServerCapability.java │ │ ├── ServerDiagnosticsSummaryDataType.java │ │ ├── ServerOnNetwork.java │ │ ├── ServerState.java │ │ ├── ServerStatusDataType.java │ │ ├── ServiceCounterDataType.java │ │ ├── ServiceFault.java │ │ ├── SessionDiagnosticsDataType.java │ │ ├── SessionSecurityDiagnosticsDataType.java │ │ ├── SessionServiceSetHandler.java │ │ ├── SessionlessInvokeRequestType.java │ │ ├── SessionlessInvokeResponseType.java │ │ ├── SetMonitoringModeRequest.java │ │ ├── SetMonitoringModeResponse.java │ │ ├── SetPublishingModeRequest.java │ │ ├── SetPublishingModeResponse.java │ │ ├── SetTriggeringRequest.java │ │ ├── SetTriggeringResponse.java │ │ ├── SignatureData.java │ │ ├── SignedSoftwareCertificate.java │ │ ├── SimpleAttributeOperand.java │ │ ├── SimpleTypeDescription.java │ │ ├── StandardEngineeringUnits.java │ │ ├── StatusChangeNotification.java │ │ ├── StatusCodes.java │ │ ├── StatusResult.java │ │ ├── StructureDefinition.java │ │ ├── StructureDescription.java │ │ ├── StructureField.java │ │ ├── StructureType.java │ │ ├── SubscribedDataSetDataType.java │ │ ├── SubscribedDataSetMirrorDataType.java │ │ ├── SubscriptionAcknowledgement.java │ │ ├── SubscriptionDiagnosticsDataType.java │ │ ├── SubscriptionServiceSetHandler.java │ │ ├── TargetVariablesDataType.java │ │ ├── TimeZoneDataType.java │ │ ├── TimestampsToReturn.java │ │ ├── TransferResult.java │ │ ├── TransferSubscriptionsRequest.java │ │ ├── TransferSubscriptionsResponse.java │ │ ├── TranslateBrowsePathsToNodeIdsRequest.java │ │ ├── TranslateBrowsePathsToNodeIdsResponse.java │ │ ├── TrustListDataType.java │ │ ├── TrustListMasks.java │ │ ├── UABinaryFileDataType.java │ │ ├── UadpDataSetReaderMessageDataType.java │ │ ├── UadpDataSetWriterMessageDataType.java │ │ ├── UadpWriterGroupMessageDataType.java │ │ ├── Union.java │ │ ├── UnregisterNodesRequest.java │ │ ├── UnregisterNodesResponse.java │ │ ├── UpdateDataDetails.java │ │ ├── UpdateEventDetails.java │ │ ├── UpdateStructureDataDetails.java │ │ ├── UserIdentityToken.java │ │ ├── UserNameIdentityToken.java │ │ ├── UserTokenPolicy.java │ │ ├── UserTokenType.java │ │ ├── VariableAttributes.java │ │ ├── VariableTypeAttributes.java │ │ ├── ViewAttributes.java │ │ ├── ViewDescription.java │ │ ├── WriteRequest.java │ │ ├── WriteResponse.java │ │ ├── WriteValue.java │ │ ├── WriterGroupDataType.java │ │ ├── WriterGroupMessageDataType.java │ │ ├── WriterGroupTransportDataType.java │ │ ├── X509IdentityToken.java │ │ ├── XVType.java │ │ └── package-info.java │ │ ├── encoding │ │ ├── DecodingException.java │ │ ├── EncodeType.java │ │ ├── EncoderContext.java │ │ ├── EncoderMode.java │ │ ├── EncodingException.java │ │ ├── IDecoder.java │ │ ├── IEncodeable.java │ │ ├── IEncoder.java │ │ ├── binary │ │ │ ├── BinaryDecoder.java │ │ │ ├── BinaryEncoder.java │ │ │ ├── ByteUtils.java │ │ │ ├── DecoderUtils.java │ │ │ ├── EncodeableReflectionSerializer.java │ │ │ ├── EncoderUtils.java │ │ │ ├── IEncodeableSerializer.java │ │ │ ├── NodeIdEncoding.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── utils │ │ │ ├── AbstractSerializer.java │ │ │ ├── EncodeableDesc.java │ │ │ ├── EncodeableDescTable.java │ │ │ ├── EncodeableDiscovery.java │ │ │ ├── SerializerComposition.java │ │ │ └── package-info.java │ │ └── xml │ │ │ ├── XmlDecoder.java │ │ │ ├── XmlEncoder.java │ │ │ └── package-info.java │ │ ├── transport │ │ ├── AsyncRead.java │ │ ├── AsyncResult.java │ │ ├── AsyncWrite.java │ │ ├── ChannelService.java │ │ ├── ClientServiceRequestState.java │ │ ├── CloseableObject.java │ │ ├── CloseableObjectState.java │ │ ├── ConnectionMonitor.java │ │ ├── Endpoint.java │ │ ├── EndpointBinding.java │ │ ├── EndpointServer.java │ │ ├── EndpointServerCollection.java │ │ ├── IConnectionListener.java │ │ ├── ReadState.java │ │ ├── RequestChannel.java │ │ ├── ResultListener.java │ │ ├── ReverseTransportChannelSettings.java │ │ ├── SecureChannel.java │ │ ├── ServerConnection.java │ │ ├── ServerSecureChannel.java │ │ ├── ServiceChannel.java │ │ ├── TransportChannelSettings.java │ │ ├── TransportConstants.java │ │ ├── UriUtil.java │ │ ├── WriteState.java │ │ ├── endpoint │ │ │ ├── AbstractServerSecureChannel.java │ │ │ ├── EndpointBindingCollection.java │ │ │ ├── EndpointCollection.java │ │ │ ├── EndpointServiceRequest.java │ │ │ └── package-info.java │ │ ├── https │ │ │ ├── HttpsClient.java │ │ │ ├── HttpsClientPendingRequest.java │ │ │ ├── HttpsClientSecureChannel.java │ │ │ ├── HttpsServer.java │ │ │ ├── HttpsServerConnection.java │ │ │ ├── HttpsServerEndpointHandler.java │ │ │ ├── HttpsServerPendingRequest.java │ │ │ ├── HttpsServerSecureChannel.java │ │ │ ├── HttpsSettings.java │ │ │ └── package-info.java │ │ ├── impl │ │ │ ├── AsyncResultImpl.java │ │ │ ├── ConnectionCollection.java │ │ │ ├── SecureChannelFactory.java │ │ │ ├── SecureChannelRepository.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── security │ │ │ ├── AllowAllCertificatesValidator.java │ │ │ ├── BcCertificateProvider.java │ │ │ ├── BcCryptoProvider.java │ │ │ ├── BcJceCryptoProvider.java │ │ │ ├── Cert.java │ │ │ ├── CertValidatorTrustManager.java │ │ │ ├── CertificateProvider.java │ │ │ ├── CertificateValidator.java │ │ │ ├── CertificateValidatorImpl.java │ │ │ ├── CipherParams.java │ │ │ ├── CryptoProvider.java │ │ │ ├── HttpsSecurityPolicy.java │ │ │ ├── JceCryptoProvider.java │ │ │ ├── KeyPair.java │ │ │ ├── KeyPairsKeyManager.java │ │ │ ├── PrivKey.java │ │ │ ├── ScCertificateProvider.java │ │ │ ├── ScCryptoProvider.java │ │ │ ├── ScJceCryptoProvider.java │ │ │ ├── SecurityAlgorithm.java │ │ │ ├── SecurityConfiguration.java │ │ │ ├── SecurityConstants.java │ │ │ ├── SecurityMode.java │ │ │ ├── SecurityPolicy.java │ │ │ ├── SecurityPolicyUri.java │ │ │ └── package-info.java │ │ └── tcp │ │ │ ├── impl │ │ │ ├── Acknowledge.java │ │ │ ├── ChunkAsymmDecryptVerifier.java │ │ │ ├── ChunkAsymmEncryptSigner.java │ │ │ ├── ChunkFactory.java │ │ │ ├── ChunkSymmDecryptVerifier.java │ │ │ ├── ChunkSymmEncryptSigner.java │ │ │ ├── ChunkUtils.java │ │ │ ├── ErrorMessage.java │ │ │ ├── Hello.java │ │ │ ├── ReverseHello.java │ │ │ ├── SecurityToken.java │ │ │ ├── TcpConnectionParameters.java │ │ │ └── TcpMessageType.java │ │ │ ├── io │ │ │ ├── IConnection.java │ │ │ ├── ITransportChannel.java │ │ │ ├── OpcTcpSettings.java │ │ │ ├── SecureChannelTcp.java │ │ │ ├── SequenceNumber.java │ │ │ ├── TcpConnection.java │ │ │ ├── TcpConnectionLimits.java │ │ │ ├── TcpMessageLimits.java │ │ │ └── TcpQuotas.java │ │ │ ├── nio │ │ │ ├── AbstractServerConnection.java │ │ │ ├── Channel.java │ │ │ ├── ChunksToMessage.java │ │ │ ├── InputMessage.java │ │ │ ├── MessageToChunks.java │ │ │ ├── MessageType.java │ │ │ ├── MessageWriteState.java │ │ │ ├── OpcTcpServer.java │ │ │ ├── OpcTcpServerConnection.java │ │ │ ├── OpcTcpServerSecureChannel.java │ │ │ ├── PendingRequest.java │ │ │ └── SecureInputMessageBuilder.java │ │ │ └── package-info.java │ │ └── utils │ │ ├── AbstractState.java │ │ ├── AbstractStructure.java │ │ ├── AttributesUtil.java │ │ ├── BijectionMap.java │ │ ├── BouncyCastleUtils.java │ │ ├── CertificateUtils.java │ │ ├── ConcurrentBijectionMap.java │ │ ├── CryptoUtil.java │ │ ├── CurrentThreadExecutor.java │ │ ├── Description.java │ │ ├── EncodingLimitsExceededIoException.java │ │ ├── EndpointUtil.java │ │ ├── FileUtil.java │ │ ├── IStatefulObject.java │ │ ├── IncubationQueue.java │ │ ├── LimitedByteArrayOutputStream.java │ │ ├── MultiDimensionArrayUtils.java │ │ ├── NumericRange.java │ │ ├── ObjectUtils.java │ │ ├── ReflectionUtils.java │ │ ├── SizeCalculationOutputStream.java │ │ ├── SnapshotArray.java │ │ ├── SpongyCastleUtils.java │ │ ├── StackUtils.java │ │ ├── State.java │ │ ├── StateListener.java │ │ ├── StreamUtil.java │ │ ├── StringUtils.java │ │ ├── TimerUtil.java │ │ ├── XMLFactoryCache.java │ │ ├── asyncsocket │ │ ├── AsyncInputStream.java │ │ ├── AsyncOutputStream.java │ │ ├── AsyncSelector.java │ │ ├── AsyncServerSocket.java │ │ ├── AsyncSocket.java │ │ ├── AsyncSocketImpl.java │ │ ├── BufferMonitor.java │ │ ├── BufferMonitorState.java │ │ ├── ListenableServerSocketChannel.java │ │ ├── ListenableSocketChannel.java │ │ ├── MonitorListener.java │ │ ├── ServerSocketState.java │ │ ├── SocketState.java │ │ └── package-info.java │ │ ├── bytebuffer │ │ ├── ByteBufferArrayReadable.java │ │ ├── ByteBufferArrayWriteable.java │ │ ├── ByteBufferArrayWriteable2.java │ │ ├── ByteBufferFactory.java │ │ ├── ByteBufferReadable.java │ │ ├── ByteBufferUtils.java │ │ ├── ByteBufferWriteable.java │ │ ├── ByteQueue.java │ │ ├── IBinaryReadable.java │ │ ├── IBinaryWriteable.java │ │ ├── IncubationBuffer.java │ │ ├── InputStreamReadable.java │ │ ├── OrderedByteBufferInputStream.java │ │ ├── OutputStreamWriteable.java │ │ └── package-info.java │ │ └── package-info.java └── resources │ └── .gitignore └── test ├── java └── org │ └── opcfoundation │ └── ua │ ├── BuildHelper.java │ ├── application │ └── SessionChannelTest.java │ ├── builtintypes │ ├── ByteStringTest.java │ ├── ExpandedNodeIdTest.java │ ├── ExtensionObjectTest.java │ ├── UnsignedByteTest.java │ ├── UnsignedIntegerTest.java │ ├── UnsignedLongTest.java │ ├── UnsignedShortTest.java │ └── VariantTest.java │ ├── cert │ └── CertificateStoreTest.java │ ├── common │ └── NamespaceTableTest.java │ ├── core │ ├── ServerCapabilityTest.java │ └── StandardEngineeringUnitsTest.java │ ├── encoding │ └── binary │ │ ├── BinaryDecoderTest.java │ │ ├── BinaryEncoderTest.java │ │ ├── ByteUtilsTest.java │ │ └── XmlDecoderTest.java │ ├── transport │ ├── security │ │ ├── BcCryptoProviderTest.java │ │ ├── CertTest.java │ │ └── SecurityModeTest.java │ └── tcp │ │ └── io │ │ └── TcpConnectionTest.java │ ├── unittests │ ├── EndpointsTestBench.java │ ├── SocketTestBench.java │ ├── TestAsyncSelector.java │ ├── TestAsyncSocket.java │ ├── TestBinaryEncoder.java │ ├── TestByteQueue.java │ ├── TestCertificates.java │ ├── TestCrypto.java │ ├── TestDateTime.java │ ├── TestGetEndpoints.java │ ├── TestIncubationQueue.java │ ├── TestListenableSocketChannel.java │ ├── TestNodeId.java │ ├── TestNumericRange.java │ ├── TestUnsignedLong.java │ ├── TestXmlElement.java │ └── UnitTestKeys.java │ └── utils │ ├── MultiDimensionArrayUtilsTest.java │ └── StringUtilsTest.java └── resources └── org └── opcfoundation └── ua └── unittests ├── ClientCert.der ├── ClientCert.pfx ├── SampleXmlData1.xml ├── SampleXmlData2.xml ├── SampleXmlData3.xml ├── SampleXmlData4.xml ├── ServerCert.der ├── UAServerCert.pfx └── keystore.p12 /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | tmp/ 3 | javadoc/ 4 | bin/ 5 | /test-output 6 | target 7 | /.idea 8 | 9 | *.der 10 | *.pem 11 | .settings 12 | .classpath 13 | .project 14 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The headers for all source code files within this package contain the relevant license information. 2 | 3 | Two forms of license are applied and are shown below. The Java stack core code is a DUAL LICENSE. The sample applications are MIT. An explanation is provided here: 4 | http://opcfoundation.github.io/UA-Java/ 5 | 6 | 7 | 8 | JAVA STACK DUAL LICENSE 9 | ----------------------- 10 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 11 | The source code in this file is covered under a dual-license scenario: 12 | - RCL: for OPC Foundation Corporate Members 13 | - GPL V2: everybody else 14 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 15 | GNU General Public License as published by the Free Software Foundation; 16 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 17 | This source code is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ 20 | 21 | 22 | 23 | 24 | SAMPLE APPLICATIONS MIT LICENSE 25 | ------------------------------- 26 | /* ======================================================================== 27 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 28 | * 29 | * OPC Foundation MIT License 1.00 30 | * 31 | * Permission is hereby granted, free of charge, to any person 32 | * obtaining a copy of this software and associated documentation 33 | * files (the "Software"), to deal in the Software without 34 | * restriction, including without limitation the rights to use, 35 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 36 | * copies of the Software, and to permit persons to whom the 37 | * Software is furnished to do so, subject to the following 38 | * conditions: 39 | * 40 | * The above copyright notice and this permission notice shall be 41 | * included in all copies or substantial portions of the Software. 42 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 43 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 44 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 45 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 46 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 47 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 48 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 49 | * OTHER DEALINGS IN THE SOFTWARE. 50 | * 51 | * The complete license agreement can be found here: 52 | * http://opcfoundation.org/License/MIT/1.00/ 53 | * ======================================================================*/ -------------------------------------------------------------------------------- /codegen/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /codegen/README.md: -------------------------------------------------------------------------------- 1 | # OPC Foundation UA JAVA - codegen 2 | This 'sub' project handles the codegeneration part of the stack. 3 | 4 | The main class to run is codegen/org.opcfoundation.ua.codegen.Main2. 5 | 6 | The generator reads descriptions in src/resources/codegen_data/ and writes the output 7 | source files to main stack project src/main/java/org.opcfoundation.ua.core. 8 | 9 | The input data is located in these folders: 10 | codegen_data/data/ contains data type descriptions and constants from ModelDesigner. 11 | codegen_data/templates/ contains Java source code templates. 12 | codegen_data/overrides/ contains exceptions to templates. 13 | 14 | Note: In eclipse, remember to refresh (F5) the source tree after code generation. -------------------------------------------------------------------------------- /codegen/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | opc-ua-stack-codegen 4 | 1.4.1.1-SNAPSHOT 5 | org.opcfoundation.ua 6 | 7 | 8 | 9 | org.apache.maven.plugins 10 | maven-compiler-plugin 11 | 3.3 12 | 13 | 1.6 14 | 1.6 15 | 16 | 17 | 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | org.apache.commons 25 | commons-csv 26 | 1.4 27 | 28 | 29 | org.apache.commons 30 | commons-lang3 31 | 3.5 32 | 33 | 34 | com.google.guava 35 | guava 36 | 32.0.0-jre 37 | 38 | 39 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/data/ServiceSets.csv: -------------------------------------------------------------------------------- 1 | FindServers,1,DiscoveryServiceSet 2 | GetEndpoints,1,DiscoveryServiceSet 3 | RegisterServer,1,DiscoveryServiceSet 4 | OpenSecureChannel,2,SecureChannelServiceSet 5 | CloseSecureChannel,2,SecureChannelServiceSet 6 | CreateSession,3,SessionServiceSet 7 | ActivateSession,3,SessionServiceSet 8 | CloseSession,3,SessionServiceSet 9 | Cancel,3,SessionServiceSet 10 | AddNodes,4,NodeManagementServiceSet 11 | AddReferences,4,NodeManagementServiceSet 12 | DeleteNodes,4,NodeManagementServiceSet 13 | DeleteReferences,4,NodeManagementServiceSet 14 | Browse,4,NodeManagementServiceSet 15 | BrowseNext,4,NodeManagementServiceSet 16 | TranslateBrowsePathsToNodeIds,4,NodeManagementServiceSet 17 | RegisterNodes,4,NodeManagementServiceSet 18 | UnregisterNodes,4,NodeManagementServiceSet 19 | QueryFirst,4,NodeManagementServiceSet 20 | QueryNext,4,NodeManagementServiceSet 21 | Read,5,AttributeServiceSet 22 | HistoryRead,5,AttributeServiceSet 23 | Write,5,AttributeServiceSet 24 | HistoryUpdate,5,AttributeServiceSet 25 | Call,6,MethodServiceSet 26 | CreateMonitoredItems,6,MonitoredItemServiceSet 27 | ModifyMonitoredItems,6,MonitoredItemServiceSet 28 | SetMonitoringMode,6,MonitoredItemServiceSet 29 | SetTriggering,6,MonitoredItemServiceSet 30 | DeleteMonitoredItems,6,MonitoredItemServiceSet 31 | CreateSubscription,7,SubscriptionServiceSet 32 | ModifySubscription,7,SubscriptionServiceSet 33 | SetPublishingMode,7,SubscriptionServiceSet 34 | Publish,7,SubscriptionServiceSet 35 | Republish,7,SubscriptionServiceSet 36 | TransferSubscriptions,7,SubscriptionServiceSet 37 | DeleteSubscriptions,7,SubscriptionServiceSet 38 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/data/UNECE_rec20_Rev10e_2014_utf16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/codegen/src/main/resources/codegen_data/data/UNECE_rec20_Rev10e_2014_utf16.txt -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/data/ext-UA Defined Types.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://opcfoundation.org/UA/ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/ChannelServiceTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | _imports_ 33 | 34 | /** 35 | * This is a autogenerated class, do not modify this class directly. 36 | * @see ServiceChannel 37 | */ 38 | public class _ClassName_ { 39 | 40 | /** The back-end channel object */ 41 | protected RequestChannel channel; 42 | 43 | public _ClassName_(RequestChannel clientChannel) 44 | { 45 | if (clientChannel==null) 46 | throw new IllegalArgumentException("null arg"); 47 | this.channel = clientChannel; 48 | } 49 | 50 | public _ClassName_() 51 | { 52 | } 53 | 54 | protected void setRequestChannel(RequestChannel channel) 55 | { 56 | if (channel==null) 57 | throw new IllegalArgumentException("null arg"); 58 | this.channel = channel; 59 | } 60 | 61 | _Content_ 62 | 63 | } 64 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/IdentifiersTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | import org.opcfoundation.ua.builtintypes.NodeId; 33 | import org.opcfoundation.ua.builtintypes.UnsignedInteger; 34 | 35 | _imports_ 36 | 37 | @Description("_description_") 38 | public class _ClassName_ { 39 | 40 | _Content_ 41 | 42 | static NodeId init(int value) 43 | { 44 | return new NodeId(0, UnsignedInteger.getFromBits(value)); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/InternalIdentifiersTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | import org.opcfoundation.ua.builtintypes.NodeId; 33 | import org.opcfoundation.ua.builtintypes.UnsignedInteger; 34 | 35 | _imports_ 36 | 37 | @Description("_description_") 38 | class _ClassName_ { 39 | 40 | _Content_ 41 | 42 | static NodeId init(int value) 43 | { 44 | return new NodeId(0, UnsignedInteger.getFromBits(value)); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/RequestTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | import org.opcfoundation.ua.builtintypes.ServiceRequest; 33 | import org.opcfoundation.ua.builtintypes.ExpandedNodeId; 34 | import org.opcfoundation.ua.core.Identifiers; 35 | import org.opcfoundation.ua.utils.ObjectUtils; 36 | _imports_ 37 | @Description("_description_") 38 | public class _ClassName_ extends _SuperType_ implements ServiceRequest { 39 | 40 | public static final ExpandedNodeId ID = new ExpandedNodeId(Identifiers._ClassName_); 41 | public static final ExpandedNodeId BINARY = new ExpandedNodeId(Identifiers._ClassName__Encoding_DefaultBinary); 42 | public static final ExpandedNodeId XML = new ExpandedNodeId(Identifiers._ClassName__Encoding_DefaultXml); 43 | 44 | _Content_ 45 | 46 | public ExpandedNodeId getTypeId() { 47 | return ID; 48 | } 49 | 50 | public ExpandedNodeId getXmlEncodeId() { 51 | return XML; 52 | } 53 | 54 | public ExpandedNodeId getBinaryEncodeId() { 55 | return BINARY; 56 | } 57 | 58 | public String toString() { 59 | return ObjectUtils.printFieldsDeep(this); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/ResponseTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | import org.opcfoundation.ua.builtintypes.ServiceResponse; 33 | import org.opcfoundation.ua.builtintypes.ExpandedNodeId; 34 | import org.opcfoundation.ua.core.Identifiers; 35 | import org.opcfoundation.ua.utils.ObjectUtils; 36 | _imports_ 37 | @Description("_description_") 38 | public class _ClassName_ extends _SuperType_ implements ServiceResponse { 39 | 40 | public static final ExpandedNodeId ID = new ExpandedNodeId(Identifiers._ClassName_); 41 | public static final ExpandedNodeId BINARY = new ExpandedNodeId(Identifiers._ClassName__Encoding_DefaultBinary); 42 | public static final ExpandedNodeId XML = new ExpandedNodeId(Identifiers._ClassName__Encoding_DefaultXml); 43 | 44 | _Content_ 45 | 46 | public ExpandedNodeId getTypeId() { 47 | return ID; 48 | } 49 | 50 | public ExpandedNodeId getXmlEncodeId() { 51 | return XML; 52 | } 53 | 54 | public ExpandedNodeId getBinaryEncodeId() { 55 | return BINARY; 56 | } 57 | 58 | public String toString() { 59 | return ObjectUtils.printFieldsDeep(this); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/ServiceSetTemplate.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | _imports_ 35 | 36 | public interface _ClassName_ { 37 | _Content_ 38 | } 39 | -------------------------------------------------------------------------------- /codegen/src/main/resources/codegen_data/templates/Template.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package _PackageName_; 31 | 32 | _imports_ 33 | 34 | @Description("_description_") 35 | public class _ClassName_ { 36 | 37 | _Content_ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /examples/basic/src/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | project 6 | 7 | zip 8 | 9 | 10 | 11 | ${project.basedir} 12 | 13 | true 14 | 15 | **/*.log 16 | **/${project.build.directory}/** 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/basic/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | %-4r %-5p [%t] %37c - %m%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/basic/src/main/resources/org/opcfoundation/ua/examples/certs/keystore.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/examples/basic/src/main/resources/org/opcfoundation/ua/examples/certs/keystore.p12 -------------------------------------------------------------------------------- /examples/basic/src/main/resources/org/opcfoundation/ua/examples/my.store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/examples/basic/src/main/resources/org/opcfoundation/ua/examples/my.store -------------------------------------------------------------------------------- /examples/publisher/README.md: -------------------------------------------------------------------------------- 1 | # OPC Foundation UA JAVA - Azure integration sample 2 | 3 | Visit http://azure.com/iotdev to learn more about developing applications for Azure IoT. 4 | 5 | This subproject contains a sample for publishing server nodes to Azure IoT. 6 | 7 | * ClientPublisher connects as a client to a server and polls a node. The content of the node is converted to JSON and sent to IoTHub. 8 | 9 | ## Prerequisites 10 | 11 | This sample uses the [Azure IoT device SDK for Java](https://github.com/Azure/azure-iot-sdks/blob/master/java/device/readme.md). 12 | 13 | To get a device connection string [Setup a device on IoT Hub](https://github.com/Azure/azure-iot-sdks/blob/master/doc/setup_iothub.md). 14 | 15 | For more information on the Java integration in Azure IoT please follow [how-to-build-a-java-app-from-scratch](https://azure.microsoft.com/documentation/articles/iot-hub-java-java-getstarted/). 16 | 17 | ## Using 18 | Import this Maven project to your IDE. Assuming your IDE can match the main stack project and this example, you can start the sample within the IDE directly (works on eclipse). Assuming not or if you want to build the samples using maven, you need to first build the Stack and install/deploy it to your local/internal repository. 19 | 20 | Alternatively to use from command line: ```mvn clean install``` this project. 21 | 22 | Command line arguments for ```ClientPublisher```: 23 | * ```[OPC Server string]``` - OPC server,e.g. [opc.tcp://server:51210/UA/SampleServer] 24 | * ```[Device connection string]``` - String containing Hostname, Device Id & Device Key in the following format: HostName=;DeviceId=;SharedAccessKey= 25 | * ```[Protocol]``` - (https | amqps | mqtt | amqps_ws) 26 | 27 | ## Certificates 28 | 29 | The sample application creates one certificate: 30 | 31 | * OPC UA application instance certificate (self-signed) and private key, which are stored in ```.der``` & ```.pem``` 32 | 33 | The certificates are stored in the root of the project directory (but are .gitignored). 34 | 35 | The Java sample application does not validate the certificates, so it accepts secure connections with any application that has a certificate. Other applications may validate the certificates, and you need to follow their instructions on how to accept other application or HTTPS certificates. 36 | 37 | ## Common Problems - OPC UA Java Stack 38 | 39 | Please refer to [examples](../basic/README.md). 40 | 41 | -------------------------------------------------------------------------------- /graveyard/README.md: -------------------------------------------------------------------------------- 1 | # Idea&Feature Graveyard 2 | This "module" contains parts that are previously been part of the stack, but are not part of the main distribution for some reasons, but might still be something someone might need. These are not supported, nor might not compile/work with newer versions of java (or the main stack itself). 3 | 4 | Additionally this is somewhat experimental and the entire "module" might be removed in some version if deemed to be unuseful. 5 | 6 | ## SunJceCryptoProvider & SunJceCertificateProvider 7 | Removed in 1.4.0. See #164 (and possibly #165). These classes were originally intended as "last-effort-fallbacks", if Bouncy/SpongyCastle could not be used. They did this by depending on the private JRE APIs as java 6+ does not have public apis for creating and managing certificates. 8 | 9 | Starting from java 9+ those private APIs are no longer accessible and would not work. Additionally they never really fully worked (#7) with the full feature set that e.g. BouncyCastle did, so in the end users needed to use Bouncy/SpongyCastle after all. -------------------------------------------------------------------------------- /graveyard/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | org.opcfoundation.ua 6 | opc-ua-stack-extras 7 | 1.4.1.1-SNAPSHOT 8 | extras 9 | 10 | UTF-8 11 | 12 | 13 | 14 | 15 | org.opcfoundation.ua 16 | opc-ua-stack 17 | ${project.version} 18 | 19 | 20 | org.apache.httpcomponents 21 | httpclient 22 | 4.5.13 23 | 24 | 25 | org.apache.httpcomponents 26 | httpcore-nio 27 | 4.4.4 28 | 29 | 30 | org.bouncycastle 31 | bcpkix-jdk15on 32 | 1.60 33 | runtime 34 | 35 | 36 | 37 | 38 | 39 | maven-compiler-plugin 40 | 3.3 41 | 42 | 1.6 43 | 1.6 44 | 45 | 46 | 48 | 49 | org.codehaus.mojo 50 | animal-sniffer-maven-plugin 51 | 1.15 52 | 53 | 54 | org.codehaus.mojo.signature 55 | java16-sun 56 | 1.10 57 | 58 | 59 | 60 | 61 | api-check 62 | package 63 | 64 | check 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /license/LICENSE.bouncycastle: -------------------------------------------------------------------------------- 1 | License 2 | 3 | Copyright (c) 2000 - 2009 The Legion Of The Bouncy Castle (http://www.bouncycastle.org) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /license/LICENSE.slf4j: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2013 QOS.ch 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/assembly/dependencies.xml: -------------------------------------------------------------------------------- 1 | 3 | dependencies 4 | 5 | zip 6 | 7 | 8 | 9 | 10 | false 11 | lib 12 | false 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/assembly/project.xml: -------------------------------------------------------------------------------- 1 | 4 | project 5 | 6 | zip 7 | 8 | 9 | 10 | ${project.basedir} 11 | ./ 12 | true 13 | 14 | ${project.basedir}/bin/** 15 | **/*.log 16 | **/${project.build.directory}/** 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/application/AbstractServiceHandler.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.application; 14 | 15 | import java.util.Collection; 16 | 17 | import org.opcfoundation.ua.encoding.IEncodeable; 18 | 19 | /** 20 | * Abstract implementation for a service handler that can server only 21 | * one type of service request; 22 | */ 23 | public abstract class AbstractServiceHandler implements ServiceHandler { 24 | 25 | Class clazz; 26 | 27 | /** 28 | *

Constructor for AbstractServiceHandler.

29 | * 30 | * @param clazz a {@link java.lang.Class} object. 31 | */ 32 | public AbstractServiceHandler(Class clazz) 33 | { 34 | if (clazz==null) 35 | throw new IllegalArgumentException("null"); 36 | this.clazz = clazz; 37 | } 38 | 39 | /** {@inheritDoc} */ 40 | @Override 41 | public boolean supportsService(Class clazz) { 42 | return clazz.equals(this.clazz); 43 | } 44 | 45 | /** {@inheritDoc} */ 46 | @Override 47 | public void getSupportedServices(Collection> result) { 48 | result.add(clazz); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/application/ServerDiscoveryService.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.application; 14 | 15 | import org.opcfoundation.ua.common.ServiceFaultException; 16 | import org.opcfoundation.ua.core.FindServersRequest; 17 | import org.opcfoundation.ua.core.FindServersResponse; 18 | import org.opcfoundation.ua.core.RegisterServerRequest; 19 | import org.opcfoundation.ua.core.RegisterServerResponse; 20 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 21 | 22 | /** 23 | * This class is the service implementation of a discovery Server. 24 | * 25 | * NOTE! This class is not yet implemented. 26 | * 27 | * The plan is to create discovery server that supports various back-ends 28 | * using Java Naming and Directory Interface (JNDI). JNDI is extendable and 29 | * out-of-box it supports LDAP. 30 | * 31 | * See http://java.sun.com/products/jndi/ 32 | */ 33 | public class ServerDiscoveryService { 34 | 35 | /** 36 | *

onFindServers.

37 | * 38 | * @param req a {@link org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest} object. 39 | * @throws org.opcfoundation.ua.common.ServiceFaultException if any. 40 | */ 41 | public void onFindServers(EndpointServiceRequest req) 42 | throws ServiceFaultException 43 | { 44 | 45 | } 46 | 47 | void onRegisterServer(EndpointServiceRequest req) 48 | throws ServiceFaultException 49 | { 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/application/ServiceHandler.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.application; 14 | 15 | import java.util.Collection; 16 | 17 | import org.opcfoundation.ua.builtintypes.ServiceRequest; 18 | import org.opcfoundation.ua.builtintypes.ServiceResponse; 19 | import org.opcfoundation.ua.common.ServiceResultException; 20 | import org.opcfoundation.ua.encoding.IEncodeable; 21 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 22 | 23 | /** 24 | * Service Handler reads {@link ServiceRequest} from client, processes it, and returns 25 | * a {@link ServiceResponse}. 26 | * 27 | * @see ServiceHandlerComposition 28 | * @see AbstractServiceHandler 29 | */ 30 | public interface ServiceHandler { 31 | 32 | /** 33 | * Serve a service request. 34 | *

35 | * The implementation is allowed to may submit the response 36 | * later and from another thread. 37 | * 38 | * @param request the service request 39 | * @throws org.opcfoundation.ua.common.ServiceResultException if error 40 | */ 41 | void serve(EndpointServiceRequest request) throws ServiceResultException; 42 | 43 | /** 44 | * Queries whether this handler supports a given request class. 45 | * 46 | * @param requestMessageClass class 47 | * @return true if this service handler can handle given class 48 | */ 49 | boolean supportsService(Class requestMessageClass); 50 | 51 | /** 52 | * Get supported services. Result will be filled with the request class of 53 | * the supported services. 54 | * 55 | * @param result to be filled with request classes of supported services. 56 | */ 57 | void getSupportedServices(Collection> result); 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/application/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The code in this package is for application developer. The main classes here are Client and Server. 3 | */ 4 | package org.opcfoundation.ua.application; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/DataTypes.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.builtintypes; 14 | 15 | 16 | /** 17 | * A class that defines constants used by UA applications. 18 | * 19 | * @deprecated 20 | * @see BuiltinsMap 21 | */ 22 | public class DataTypes{ 23 | 24 | /** 25 | * Returns the class for the data type. 26 | * 27 | * @param dataTypeId a {@link org.opcfoundation.ua.builtintypes.NodeId} object. 28 | * @deprecated Use @See {@link BuiltinsMap#ID_CLASS_MAP} 29 | * @return a {@link java.lang.Class} object. 30 | */ 31 | public static Class getSystemType(NodeId dataTypeId) { 32 | return BuiltinsMap.ID_CLASS_MAP.getRight(dataTypeId); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/Enumeration.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.builtintypes; 14 | 15 | /** 16 | * Super interface for all UA encodeable enumerations. 17 | * getValue is needed to complete binary serialization. 18 | * 19 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 20 | */ 21 | public interface Enumeration { 22 | 23 | /** 24 | *

getValue.

25 | * 26 | * @return a int. 27 | */ 28 | int getValue(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/ServiceRequest.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.builtintypes; 14 | 15 | import org.opcfoundation.ua.core.RequestHeader; 16 | 17 | /** 18 | * Super inteface for all service requests messages 19 | * 20 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 21 | */ 22 | public interface ServiceRequest extends Structure { 23 | 24 | /** 25 | *

getRequestHeader.

26 | * 27 | * @return a {@link org.opcfoundation.ua.core.RequestHeader} object. 28 | */ 29 | RequestHeader getRequestHeader(); 30 | /** 31 | *

setRequestHeader.

32 | * 33 | * @param RequestHeader a {@link org.opcfoundation.ua.core.RequestHeader} object. 34 | */ 35 | void setRequestHeader(RequestHeader RequestHeader); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/ServiceResponse.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.builtintypes; 14 | 15 | import org.opcfoundation.ua.core.ResponseHeader; 16 | 17 | /** 18 | * Super interface for all service response messages 19 | * 20 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 21 | */ 22 | public interface ServiceResponse extends Structure { 23 | 24 | /** 25 | *

getResponseHeader.

26 | * 27 | * @return a {@link org.opcfoundation.ua.core.ResponseHeader} object. 28 | */ 29 | ResponseHeader getResponseHeader(); 30 | /** 31 | *

setResponseHeader.

32 | * 33 | * @param ResponseHeader a {@link org.opcfoundation.ua.core.ResponseHeader} object. 34 | */ 35 | void setResponseHeader(ResponseHeader ResponseHeader); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/Structure.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.builtintypes; 14 | 15 | import org.opcfoundation.ua.encoding.IEncodeable; 16 | 17 | /** 18 | * Super interface for all complex type serializable objects 19 | */ 20 | public interface Structure extends IEncodeable, Cloneable { 21 | 22 | /** 23 | * The NodeId for the actual DataType node defining this Structure type. Should never be null. 24 | * Shall always contain the NamespaceUri within the {@link ExpandedNodeId}. 25 | */ 26 | ExpandedNodeId getTypeId(); 27 | 28 | /** 29 | * The NodeId for the "Default XML" encodings node of this Structure type. Can be null if not supported. 30 | * Shall always contain the NamespaceUri within the {@link ExpandedNodeId}, if not null. 31 | */ 32 | ExpandedNodeId getXmlEncodeId(); 33 | 34 | /** 35 | * The NodeId for the "Default Binary" encodings node of this Structure type. Should never be null as the encoding is mandatory. 36 | * Shall always contain the NamespaceUri within the {@link ExpandedNodeId}. 37 | */ 38 | ExpandedNodeId getBinaryEncodeId(); 39 | 40 | /** 41 | * The NodeId for the "Default JSON" encodings node of this Structure type. Can be null if not supported. 42 | * Shall always contain the NamespaceUri within the {@link ExpandedNodeId}, if not null. 43 | */ 44 | ExpandedNodeId getJsonEncodeId(); 45 | 46 | /** 47 | * As every Structure is Cloneable, this method provides convinience method for 48 | * calling .clone for an unknown Structure. Classes implementing Structure should change the signature 49 | * to return the type of the implementing class. Returns a deep clone of this Structure object. 50 | */ 51 | Structure clone(); 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/builtintypes/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | OPC UA Part 6 defines 25 builtin types. Those 25 types are represented with the following java classes. 3 | Most builtin classes are immutable. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
IDNameJava ClassNotes
1Booleanjava.lang.Boolean
2SBytejava.lang.Byte
3Byteorg.opcfoundation.ua.builtintypes.UnsignedByte
4Int16java.lang.Short
5UInt16org.opcfoundation.ua.builtintypes.UnsignedShort
6Int32java.lang.Integer
7UInt32org.opcfoundation.ua.builtintypes.UnsignedInteger
8Int64java.lang.Long
9UInt64org.opcfoundation.ua.builtintypes.UnsignedLong
10Floatjava.lang.Float
11Doublejava.lang.Double
12Stringjava.lang.String
13DateTimeorg.opcfoundation.ua.builtintypes.DateTime
14Guidjava.util.UUID
15ByteStringorg.opcfoundation.ua.builtintypes.ByteString
16XmlElementorg.opcfoundation.ua.builtintypes.XmlElement
17NodeIdorg.opcfoundation.ua.builtintypes.NodeId
18ExpandedNodeIdorg.opcfoundation.ua.builtintypes.ExpandedNodeId
19StatusCodeorg.opcfoundation.ua.builtintypes.StatusCode
20QualifiedNameorg.opcfoundation.ua.builtintypes.QualifiedName
21LocalizedTextorg.opcfoundation.ua.builtintypes.LocalizedText
22ExtensionObjectorg.opcfoundation.ua.builtintypes.ExtensionObject
23DataValueorg.opcfoundation.ua.builtintypes.DataValue
24Variantorg.opcfoundation.ua.builtintypes.Variant
25DiagnosticInfoorg.opcfoundation.ua.builtintypes.DiagnosticInfo
32 | 33 |
Also, see class org.opcfoundation.ua.encoding.utils.BuiltinsMap for builtins id, uri and java class mappings. 34 | */ 35 | package org.opcfoundation.ua.builtintypes; 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/cert/CertificateCheck.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.cert; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Certificate checks that the Validator performs. The values are used to 19 | * define which checks passed in the validator. 20 | * 21 | * @see DefaultCertificateStoreListener 22 | */ 23 | public enum CertificateCheck { 24 | /** 25 | * is the certificate signed by the certificate itself (this can be OK) 26 | */ 27 | SelfSigned, 28 | 29 | /** 30 | * is the certificate signed by a trusted signer (or self) 31 | */ 32 | Signature, 33 | 34 | /** 35 | * is the certificate already defined as trusted, i.e. it is found from 36 | * the TrustedDir or added to the validator using addTrustedCertificate 37 | */ 38 | 39 | Trusted, 40 | /** 41 | * does the certificate contain the applicationUri, equal to the one in 42 | * the ApplicationDescription. 43 | */ 44 | Uri, 45 | 46 | /** 47 | * validity of the URI 48 | */ 49 | UriValid, 50 | 51 | /** is the certificate time valid */ 52 | Validity; 53 | 54 | /** 55 | * All tests that must pass, to accept the certificate. Defined as 56 | * including EnumSet.of(Trusted, Validity, Signature, Uri) 57 | */ 58 | public static EnumSet COMPULSORY = EnumSet.of(Trusted, Validity, Signature, Uri); 59 | 60 | } -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/cert/DefaultCertificateStoreListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.cert; 14 | 15 | import java.security.cert.X509CRL; 16 | 17 | import org.opcfoundation.ua.transport.security.Cert; 18 | 19 | /** 20 | * Listener for Cert changes for {@link DefaultCertificateValidator} 21 | */ 22 | public interface DefaultCertificateStoreListener { 23 | 24 | /** 25 | * Called after {@link DefaultCertificateValidator} adds a Certificate 26 | * to Rejected certificates 27 | * 28 | * @param cert 29 | * the added certificate 30 | */ 31 | public void onRejectedCertificateAdded(Cert cert); 32 | 33 | /** 34 | * Called after {@link DefaultCertificateValidator} adds a Certificate 35 | * Revoked List. 36 | * 37 | * @param crl added revocation list 38 | */ 39 | public void onRevokedListAdded(X509CRL crl); 40 | 41 | /** 42 | * Called after {@link DefaultCertificateValidator} adds a Certificate 43 | * to Trusted certificates 44 | * 45 | * @param cert 46 | * the added certificate 47 | */ 48 | public void onTrustedCertificateAdded(Cert cert); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/cert/DefaultCertificateValidatorListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.cert; 14 | 15 | import java.util.EnumSet; 16 | 17 | import org.opcfoundation.ua.core.ApplicationDescription; 18 | import org.opcfoundation.ua.transport.security.Cert; 19 | 20 | /** 21 | * An event handler interface for reacting to certificate validation handling 22 | * results. 23 | */ 24 | public interface DefaultCertificateValidatorListener { 25 | 26 | /** 27 | * Handle certificate validation. You can use the event to define your 28 | * custom handler to decide whether to trust or reject the certificate - 29 | * permanently or just this time. 30 | *

31 | * The method is called once the actual validator has already checked the 32 | * certificate and provides the results of the checks in the parameters. If 33 | * isTrusted, isSignVerified, isValid are all false, you should normally 34 | * accept the certificate. 35 | * 36 | * @param certificate 37 | * the certificate that is being validated 38 | * @param passedChecks 39 | * the certification checks that failed 40 | * @return validation result: accept or reject; once or permanently? 41 | */ 42 | ValidationResult onValidate(Cert certificate, ApplicationDescription applicationDescription, 43 | EnumSet passedChecks); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/cert/ValidationResult.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.cert; 14 | 15 | /** 16 | * Validation actions, in case a certificate is untrusted. 17 | */ 18 | public enum ValidationResult { 19 | AcceptOnce, 20 | 21 | AcceptPermanently, 22 | 23 | Reject 24 | } -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/common/IdentifierDescriptions.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.common; 14 | 15 | import java.lang.reflect.Field; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | import org.opcfoundation.ua.builtintypes.NodeId; 20 | import org.opcfoundation.ua.builtintypes.StatusCode; 21 | 22 | /** 23 | * Reads statuscode description annotations from generated StatusCode class 24 | * using reflection. Based on StatusCodeDescriptions. 25 | * 26 | * @see StatusCode 27 | * @author Otso Palonen (otso.palonen@prosys.fi) 28 | */ 29 | public class IdentifierDescriptions { 30 | 31 | private static Map NAME_MAP = null; 32 | 33 | private static synchronized void readDescriptions() { 34 | if (NAME_MAP != null) 35 | return; 36 | 37 | NAME_MAP = new HashMap(); 38 | 39 | Class clazz; 40 | try { 41 | clazz = Class.forName("org.opcfoundation.ua.core.Identifiers"); 42 | for (Field f : clazz.getFields()) { 43 | if (!f.getType().equals(NodeId.class)) 44 | continue; 45 | f.setAccessible(true); 46 | NodeId nodeId = (NodeId) f.get(null); 47 | String name = f.getName(); 48 | NAME_MAP.put(name, nodeId); 49 | } 50 | } catch (ClassNotFoundException e) { 51 | e.printStackTrace(); 52 | } catch (IllegalArgumentException e) { 53 | e.printStackTrace(); 54 | } catch (IllegalAccessException e) { 55 | e.printStackTrace(); 56 | } 57 | 58 | } 59 | 60 | /** 61 | *

toNodeId.

62 | * 63 | * @param name a {@link java.lang.String} object. 64 | * @return a {@link org.opcfoundation.ua.builtintypes.NodeId} object. 65 | */ 66 | public static NodeId toNodeId(String name) { 67 | readDescriptions(); 68 | NodeId nodeId = NAME_MAP.get(name); 69 | if (nodeId == null) 70 | throw new IllegalArgumentException("NodeId not found: " + name); 71 | return nodeId; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/common/RuntimeServiceResultException.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.common; 14 | 15 | /** 16 | *

RuntimeServiceResultException class.

17 | * 18 | */ 19 | @SuppressWarnings("serial") 20 | public class RuntimeServiceResultException extends RuntimeException { 21 | 22 | /** 23 | *

Constructor for RuntimeServiceResultException.

24 | * 25 | * @param cause a {@link org.opcfoundation.ua.common.ServiceResultException} object. 26 | */ 27 | public RuntimeServiceResultException(ServiceResultException cause) { 28 | super(cause); 29 | } 30 | 31 | /** {@inheritDoc} */ 32 | @Override 33 | public ServiceResultException getCause() { 34 | return (ServiceResultException) super.getCause(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/common/ServerTable.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.common; 14 | 15 | 16 | /** 17 | * Table for keeping the ServerUris, which are exposed by the server via the property Server.ServerArray. 18 | */ 19 | public class ServerTable extends UriTable { 20 | /** 21 | *

createFromArray.

22 | * 23 | * @param serverArray an array of {@link java.lang.String} objects. 24 | * @return a {@link org.opcfoundation.ua.common.ServerTable} object. 25 | */ 26 | public static ServerTable createFromArray(String[] serverArray) { 27 | ServerTable result = new ServerTable(); 28 | result.addAll(serverArray); 29 | return result; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains common and shared classes 3 | */ 4 | package org.opcfoundation.ua.common; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/AttributeServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface AttributeServiceSetHandler { 37 | 38 | void onRead(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | void onHistoryRead(EndpointServiceRequest req) throws ServiceFaultException; 41 | 42 | void onWrite(EndpointServiceRequest req) throws ServiceFaultException; 43 | 44 | void onHistoryUpdate(EndpointServiceRequest req) throws ServiceFaultException; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/DiscoveryServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface DiscoveryServiceSetHandler { 37 | 38 | void onFindServers(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | void onGetEndpoints(EndpointServiceRequest req) throws ServiceFaultException; 41 | 42 | void onRegisterServer(EndpointServiceRequest req) throws ServiceFaultException; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/MethodServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface MethodServiceSetHandler { 37 | 38 | void onCall(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/MonitoredItemServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface MonitoredItemServiceSetHandler { 37 | 38 | void onCreateMonitoredItems(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | void onModifyMonitoredItems(EndpointServiceRequest req) throws ServiceFaultException; 41 | 42 | void onSetMonitoringMode(EndpointServiceRequest req) throws ServiceFaultException; 43 | 44 | void onSetTriggering(EndpointServiceRequest req) throws ServiceFaultException; 45 | 46 | void onDeleteMonitoredItems(EndpointServiceRequest req) throws ServiceFaultException; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/SecureChannelServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface SecureChannelServiceSetHandler { 37 | 38 | void onOpenSecureChannel(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | void onCloseSecureChannel(EndpointServiceRequest req) throws ServiceFaultException; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/SessionServiceSetHandler.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.core; 31 | 32 | import org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest; 33 | import org.opcfoundation.ua.common.ServiceFaultException; 34 | 35 | 36 | public interface SessionServiceSetHandler { 37 | 38 | void onCreateSession(EndpointServiceRequest req) throws ServiceFaultException; 39 | 40 | void onActivateSession(EndpointServiceRequest req) throws ServiceFaultException; 41 | 42 | void onCloseSession(EndpointServiceRequest req) throws ServiceFaultException; 43 | 44 | void onCancel(EndpointServiceRequest req) throws ServiceFaultException; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/core/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * All the code in this package are codegenerated. See 'codegen/README.md' for more information. 3 | */ 4 | package org.opcfoundation.ua.core; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/EncodeType.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.encoding; 14 | 15 | /** 16 | *

EncodeType class.

17 | */ 18 | public enum EncodeType { 19 | Binary, 20 | Xml, 21 | Json; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/EncoderMode.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.encoding; 14 | 15 | /** 16 | *

EncoderMode class.

17 | */ 18 | public enum EncoderMode { 19 | 20 | /** 21 | * Strict encoder throws EncodingException if the object contains nulls 22 | * which cannot be encoded 23 | */ 24 | Strict, 25 | 26 | /** 27 | * NonStrict encoder encodes null values with default (empty) fields 28 | */ 29 | NonStrict 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/IEncodeable.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.encoding; 14 | 15 | import org.opcfoundation.ua.encoding.utils.EncodeableDesc; 16 | import org.opcfoundation.ua.encoding.utils.EncodeableDiscovery; 17 | 18 | /** 19 | * IEncodeable is a serializable object. The serialization methods are 20 | * externalized to IEncodeableSerializer. 21 | * 22 | * @see EncodeableDesc Description of IEncodeable class 23 | * @see EncodeableDiscovery Discovers all builtin IEncodeable classes 24 | */ 25 | public interface IEncodeable { 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/binary/ByteUtils.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.encoding.binary; 13 | 14 | import java.io.ByteArrayOutputStream; 15 | 16 | /** 17 | * Internal helper for byte operations within this package. 18 | * 19 | */ 20 | class ByteUtils { 21 | 22 | static byte[] concat(byte[] first, byte[] second) { 23 | ByteArrayOutputStream r = new ByteArrayOutputStream(); 24 | r.write(first, 0, first.length); 25 | r.write(second, 0, second.length); 26 | return r.toByteArray(); 27 | } 28 | 29 | static byte[] reverse(byte[] data) { 30 | if(data == null || data.length == 0) { 31 | return data; 32 | } 33 | 34 | byte[] r = new byte[data.length]; 35 | for(int i = 0;iDecoderUtils class.

20 | * 21 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 22 | */ 23 | public class DecoderUtils { 24 | 25 | /** 26 | * Fixes DiagnosticInfos of a Response header to point to the string 27 | * table of the response header. 28 | * 29 | * @param rh a {@link org.opcfoundation.ua.core.ResponseHeader} object. 30 | */ 31 | public static void fixResponseHeader(ResponseHeader rh) 32 | { 33 | String[] stringTable = rh.getStringTable(); 34 | if (stringTable == null) return; 35 | DiagnosticInfo di = rh.getServiceDiagnostics(); 36 | if (di==null) return; 37 | _fixDI(di, stringTable); 38 | } 39 | 40 | private static void _fixDI(DiagnosticInfo di, String[] stringTable) 41 | { 42 | di.setStringArray(stringTable); 43 | if (di.getInnerDiagnosticInfo()!=null) 44 | _fixDI(di.getInnerDiagnosticInfo(), stringTable); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/binary/EncoderUtils.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.encoding.binary; 13 | 14 | import org.opcfoundation.ua.encoding.EncodingException; 15 | import org.opcfoundation.ua.encoding.IEncoder; 16 | 17 | /** 18 | *

EncoderUtils class.

19 | * 20 | *@deprecated use equivalent methods from the {@link IEncoder} object 21 | */ 22 | @Deprecated 23 | public class EncoderUtils { 24 | /** 25 | *

put.

26 | * 27 | * @param encoder a {@link org.opcfoundation.ua.encoding.IEncoder} object. 28 | * @param fieldName a {@link java.lang.String} object. 29 | * @param o a {@link java.lang.Object} object. 30 | * @throws org.opcfoundation.ua.encoding.EncodingException if any. 31 | * @deprecated use {@link IEncoder#put(String, Object)} directly instead 32 | */ 33 | @Deprecated 34 | public static void put(IEncoder encoder, String fieldName, Object o) throws EncodingException { 35 | encoder.put(fieldName, o); 36 | } 37 | 38 | 39 | /** 40 | *

put.

41 | * 42 | * @param encoder a {@link org.opcfoundation.ua.encoding.IEncoder} object. 43 | * @param fieldName a {@link java.lang.String} object. 44 | * @param o a {@link java.lang.Object} object. 45 | * @param clazz a {@link java.lang.Class} object. 46 | * @throws org.opcfoundation.ua.encoding.EncodingException if any. 47 | * @deprecated use {@link IEncoder#put(String, Object, Class)} directly instead 48 | */ 49 | @Deprecated 50 | public static void put(IEncoder encoder, String fieldName, Object o, Class clazz) throws EncodingException { 51 | encoder.put(fieldName, o, clazz); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/binary/NodeIdEncoding.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.encoding.binary; 14 | 15 | import org.opcfoundation.ua.core.IdType; 16 | 17 | /** 18 | * NodeId binary encoding byte. 19 | */ 20 | public enum NodeIdEncoding { 21 | 22 | TwoByte((byte) 0x00, IdType.Numeric), 23 | FourByte((byte) 0x01, IdType.Numeric), 24 | Numeric((byte) 0x02, IdType.Numeric), 25 | String((byte) 0x03, IdType.String), 26 | Guid((byte) 0x04, IdType.Guid), 27 | ByteString((byte) 0x05, IdType.String); 28 | 29 | private final byte bits; 30 | private final IdType identifierType; 31 | 32 | private NodeIdEncoding(byte bits, IdType identifierType) { 33 | this.bits = bits; 34 | this.identifierType = identifierType; 35 | } 36 | 37 | /** 38 | *

Getter for the field bits.

39 | * 40 | * @return a byte. 41 | */ 42 | public byte getBits() { 43 | return bits; 44 | } 45 | 46 | /** 47 | *

toIdentifierType.

48 | * 49 | * @return a {@link org.opcfoundation.ua.core.IdType} object. 50 | */ 51 | public IdType toIdentifierType() 52 | { 53 | return identifierType; 54 | } 55 | 56 | /** 57 | *

getNodeIdEncoding.

58 | * 59 | * @param bits a int. 60 | * @return a {@link org.opcfoundation.ua.encoding.binary.NodeIdEncoding} object. 61 | */ 62 | public static NodeIdEncoding getNodeIdEncoding(int bits) { 63 | if (bits == TwoByte.getBits()) { 64 | return TwoByte; 65 | } else if (bits == FourByte.getBits()) { 66 | return FourByte; 67 | } else if (bits == Numeric.getBits()) { 68 | return Numeric; 69 | } else if (bits==String.getBits()) { 70 | return String; 71 | } else if (bits == Guid.getBits()) { 72 | return Guid; 73 | } else if (bits == ByteString.getBits()) { 74 | return ByteString; 75 | } else 76 | return null; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/binary/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The implementation of binary serialization 3 | */ 4 | package org.opcfoundation.ua.encoding.binary; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This folder contains serialization interfaces and serialization implementations 3 | */ 4 | package org.opcfoundation.ua.encoding; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility classes for encoding 3 | */ 4 | package org.opcfoundation.ua.encoding.utils; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/xml/XmlEncoder.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.encoding.xml; 14 | 15 | 16 | /** 17 | * TODO Implement this 18 | */ 19 | public class XmlEncoder /*implements IEncoder*/ { 20 | 21 | // TODO IMPLEMENT 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/encoding/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The implementation of xml serialization. XmlEncoder is still TODO. 3 | */ 4 | package org.opcfoundation.ua.encoding.xml; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/AsyncRead.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import org.opcfoundation.ua.common.ServiceResultException; 16 | import org.opcfoundation.ua.encoding.IEncodeable; 17 | import org.opcfoundation.ua.utils.AbstractState; 18 | 19 | /** 20 | *

AsyncRead class.

21 | */ 22 | public class AsyncRead extends AbstractState { 23 | 24 | IEncodeable msg; 25 | 26 | /** 27 | *

Constructor for AsyncRead.

28 | */ 29 | public AsyncRead() { 30 | super(ReadState.Waiting, ReadState.Error); 31 | } 32 | 33 | /** 34 | *

getMessage.

35 | * 36 | * @return a {@link org.opcfoundation.ua.encoding.IEncodeable} object. 37 | */ 38 | public IEncodeable getMessage() 39 | { 40 | return msg; 41 | } 42 | 43 | /** 44 | *

setError.

45 | * 46 | * @param e a {@link org.opcfoundation.ua.common.ServiceResultException} object. 47 | */ 48 | public synchronized void setError(ServiceResultException e) { 49 | assert(!getState().isFinal()); 50 | super.setError(e); 51 | } 52 | 53 | /** 54 | *

attemptSetError.

55 | * 56 | * @param e a {@link org.opcfoundation.ua.common.ServiceResultException} object. 57 | */ 58 | public synchronized void attemptSetError(ServiceResultException e) { 59 | if (getState().isFinal()) return; 60 | super.setError(e); 61 | } 62 | 63 | /** 64 | *

setComplete.

65 | * 66 | * @param msg a {@link org.opcfoundation.ua.encoding.IEncodeable} object. 67 | */ 68 | public synchronized void setComplete(IEncodeable msg) { 69 | assert(!getState().isFinal()); 70 | this.msg = msg; 71 | setState(ReadState.Complete); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/ClientServiceRequestState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | *

ClientServiceRequestState class.

19 | */ 20 | public enum ClientServiceRequestState { 21 | 22 | Init, // initial state 23 | Canceled, // Canceled before request was sent 24 | Sent, // request sent 25 | Complete, // response ready 26 | Error; 27 | 28 | /** Constant FINAL_STATES */ 29 | public final static EnumSet FINAL_STATES = EnumSet.of(Canceled, Complete, Error); 30 | 31 | /** 32 | *

isFinal.

33 | * 34 | * @return a boolean. 35 | */ 36 | public boolean isFinal() 37 | { 38 | return FINAL_STATES.contains(this); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/CloseableObject.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import org.opcfoundation.ua.common.ServiceResultException; 16 | import org.opcfoundation.ua.utils.IStatefulObject; 17 | 18 | /** 19 | *

CloseableObject interface.

20 | */ 21 | public interface CloseableObject extends IStatefulObject { 22 | 23 | /** 24 | * Close the object. This method is async, invocation makes the object 25 | * go into closing state. 26 | * 27 | * @return a {@link org.opcfoundation.ua.transport.CloseableObject} object. 28 | */ 29 | CloseableObject close(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/CloseableObjectState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Generic object states. 19 | * 20 | * Initial states: Closed, Opening 21 | * Final states: Closed 22 | * 23 | * State transition paths: 24 | * Closed 25 | * Closed -> Opening -> Open -> Closing -> Closed 26 | * Opening -> Open -> Closing -> Closed 27 | * 28 | */ 29 | public enum CloseableObjectState { 30 | 31 | Closed, 32 | Opening, 33 | Open, 34 | Closing; 35 | 36 | public final static EnumSet CLOSED_STATES = EnumSet.of(Closed, Opening); 37 | public final static EnumSet OPEN_STATES = EnumSet.of(Open, Closing); 38 | public final static EnumSet POST_OPENING_STATES = EnumSet.of(Open, Closing, Closed); 39 | 40 | public boolean isOpen(){ 41 | return this == Open || this == Closing; 42 | } 43 | 44 | public boolean isClosed(){ 45 | return this == Closed || this == Opening; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/ConnectionMonitor.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import java.util.Collection; 16 | 17 | /** 18 | *

ConnectionMonitor interface.

19 | * 20 | */ 21 | public interface ConnectionMonitor { 22 | 23 | /** 24 | * Connection listener 25 | */ 26 | public interface ConnectListener { 27 | void onConnect(Object sender, ServerConnection connection); 28 | 29 | void onClose(Object sender, ServerConnection connection); 30 | } 31 | 32 | /** 33 | *

getConnections.

34 | * 35 | * @param result a {@link java.util.Collection} object. 36 | */ 37 | void getConnections(Collection result); 38 | /** 39 | *

addConnectionListener.

40 | * 41 | * @param l a {@link org.opcfoundation.ua.transport.ConnectionMonitor.ConnectListener} object. 42 | */ 43 | void addConnectionListener(ConnectListener l); 44 | /** 45 | *

removeConnectionListener.

46 | * 47 | * @param l a {@link org.opcfoundation.ua.transport.ConnectionMonitor.ConnectListener} object. 48 | */ 49 | void removeConnectionListener(ConnectListener l); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/IConnectionListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import org.opcfoundation.ua.common.ServiceResultException; 16 | 17 | /** 18 | *

IConnectionListener interface.

19 | * 20 | */ 21 | public interface IConnectionListener { 22 | 23 | /** 24 | * The connection has been closed 25 | * 26 | * @param closeError a {@link org.opcfoundation.ua.common.ServiceResultException} object. 27 | */ 28 | void onClosed(ServiceResultException closeError); 29 | 30 | /** 31 | * Connection opened 32 | */ 33 | void onOpen(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/ReadState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Message async read states. 19 | * 20 | * Initial states: Waiting, Reading 21 | * Final states: Complete, Error 22 | * 23 | * The only allowed state transition paths: 24 | * Waiting -> Reading -> Complete 25 | * Waiting -> Reading -> Error 26 | * Reading -> Complete 27 | * Reading -> Error 28 | * 29 | * @see AsyncRead 30 | */ 31 | public enum ReadState { 32 | Waiting, // Reply has not arrived 33 | Complete, // Message has been received completely 34 | Error; // Error by stack or abortion. See getException() 35 | 36 | public static final EnumSet FINAL_STATES = EnumSet.of(Complete, Error); 37 | 38 | public boolean isFinal() { 39 | return this==Complete || this==Error; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/RequestChannel.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import org.opcfoundation.ua.builtintypes.ServiceRequest; 16 | import org.opcfoundation.ua.builtintypes.ServiceResponse; 17 | import org.opcfoundation.ua.common.ServiceResultException; 18 | import org.opcfoundation.ua.core.StatusCodes; 19 | import org.opcfoundation.ua.encoding.IEncodeable; 20 | 21 | /** 22 | * RequestChannel is a channel to do service requests with. 23 | */ 24 | public interface RequestChannel { 25 | 26 | /** 27 | * Sends a request over the secure channel.

28 | * 29 | * If the operation timeouts or the thread is interrupted a 30 | * ServiceResultException is thrown with {@link StatusCodes#Bad_Timeout}.

31 | * 32 | * @param request the request 33 | * @return the response 34 | * @throws org.opcfoundation.ua.common.ServiceResultException if error 35 | */ 36 | IEncodeable serviceRequest(ServiceRequest request) throws ServiceResultException; 37 | 38 | /** 39 | * Asynchronous operation to send a request over the secure channel. 40 | * 41 | * @param request the request 42 | * @return the result 43 | */ 44 | AsyncResult serviceRequestAsync(ServiceRequest request); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/ResultListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import org.opcfoundation.ua.common.ServiceResultException; 16 | 17 | /** 18 | * Result listener. 19 | * 20 | * Used with {@link AsyncResult}. 21 | */ 22 | public interface ResultListener { 23 | 24 | /** 25 | * Request completed, the result is available 26 | * 27 | * @param result the result 28 | */ 29 | void onCompleted(T result); 30 | 31 | /** 32 | * There was an error in processing the request 33 | * 34 | * @param error the error 35 | */ 36 | void onError(ServiceResultException error); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/ReverseTransportChannelSettings.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | public class ReverseTransportChannelSettings extends TransportChannelSettings{ 16 | 17 | // ReverseHello, expected Server(Application)Uri 18 | String reverseHelloServerUri = null; 19 | 20 | /** 21 | * Returns opc.tcp ReverseHello expected ServerUri. 22 | */ 23 | public String getReverseHelloServerUri() { 24 | return reverseHelloServerUri; 25 | } 26 | 27 | /** 28 | * Set ReverseHello expected Server(Application)Uri. 29 | */ 30 | public void setReverseHelloServerUri(String reverseHelloServerUri) { 31 | this.reverseHelloServerUri = reverseHelloServerUri; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/TransportConstants.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | /** 16 | *

TransportConstants class.

17 | * 18 | */ 19 | public class TransportConstants { 20 | 21 | /** Constant UA_TCP="http://opcfoundation.org/UA/profiles/tr"{trunked} */ 22 | public static final String UA_TCP = "http://opcfoundation.org/UA/profiles/transport/uatcp"; 23 | /** Constant WS_XML="http://opcfoundation.org/UA/profiles/tr"{trunked} */ 24 | public static final String WS_XML = "http://opcfoundation.org/UA/profiles/transport/wsxmlorbinary"; 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/WriteState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Message write states. 19 | * 20 | * Initial states: Queued 21 | * Final states: Flushed, Error 22 | * 23 | * The only allowed state transition paths: 24 | * Queued -> Writing -> Flushed 25 | * Queued -> Writing -> Error 26 | * 27 | * @see AsyncWrite 28 | */ 29 | public enum WriteState { 30 | Ready, 31 | Queued, // Message has been placed in write queue 32 | Writing, // Message is being written 33 | Written, // Message has been written. As always with internet, transmission is not quaranteed. 34 | Canceled, // Message was canceled 35 | Error; // Error by stack or abortion. (e.g. connection closed, aborted). See getException(). 36 | 37 | 38 | public static final EnumSet FINAL_STATES = EnumSet.of(Written, Error, Canceled); 39 | 40 | public static final EnumSet CANCELABLE_STATES = EnumSet.of(Ready, Queued); 41 | 42 | public boolean isFinal(){ 43 | return this==Error || this==Written || this==Canceled; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/endpoint/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Endpoint related classes 3 | */ 4 | package org.opcfoundation.ua.transport.endpoint; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/https/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Code for creating a HTTPS based secure channel 3 | */ 4 | package org.opcfoundation.ua.transport.https; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/impl/SecureChannelFactory.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.impl; 13 | 14 | import java.util.concurrent.atomic.AtomicInteger; 15 | 16 | import org.opcfoundation.ua.application.Server; 17 | import org.opcfoundation.ua.transport.EndpointServer; 18 | 19 | /** 20 | *

SecureChannelFactory class.

21 | * 22 | */ 23 | public class SecureChannelFactory { 24 | 25 | /** Secure channel counter */ 26 | AtomicInteger secureChannelCounter = new AtomicInteger(); 27 | 28 | EndpointServer endpointServer; 29 | 30 | Server serviceServer; 31 | 32 | /** 33 | *

Constructor for SecureChannelFactory.

34 | * 35 | * @param endpointServer a {@link org.opcfoundation.ua.transport.EndpointServer} object. 36 | * @param serviceServer a {@link org.opcfoundation.ua.application.Server} object. 37 | */ 38 | public SecureChannelFactory(EndpointServer endpointServer, Server serviceServer) 39 | { 40 | this.endpointServer = endpointServer; 41 | this.serviceServer = serviceServer; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/impl/SecureChannelRepository.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.impl; 13 | 14 | /** 15 | *

SecureChannelRepository class.

16 | * 17 | */ 18 | public class SecureChannelRepository { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *This package contains SecureChannel related implementations 3 | */ 4 | package org.opcfoundation.ua.transport.impl; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains SecureChannel and related interfaces 3 | */ 4 | package org.opcfoundation.ua.transport; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/AllowAllCertificatesValidator.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.security; 14 | 15 | import org.opcfoundation.ua.builtintypes.StatusCode; 16 | import org.opcfoundation.ua.core.ApplicationDescription; 17 | 18 | /** 19 | * A {@link CertificateValidator} that allows all certificates. 20 | * 21 | */ 22 | public class AllowAllCertificatesValidator implements CertificateValidator { 23 | 24 | /** {@inheritDoc} */ 25 | @Override 26 | public StatusCode validateCertificate(org.opcfoundation.ua.transport.security.Cert c) { 27 | return StatusCode.GOOD; 28 | } 29 | 30 | @Override 31 | public StatusCode validateCertificate(ApplicationDescription applicationDescription, Cert cert) { 32 | return StatusCode.GOOD; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/BcJceCryptoProvider.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.security; 13 | 14 | import org.opcfoundation.ua.utils.CryptoUtil; 15 | 16 | /** 17 | *

BcJceCryptoProvider class.

18 | * 19 | */ 20 | public class BcJceCryptoProvider extends JceCryptoProvider implements CryptoProvider { 21 | 22 | /** 23 | *

Constructor for BcJceCryptoProvider.

24 | */ 25 | public BcJceCryptoProvider() { 26 | super(CryptoUtil.loadOrInstallProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider")); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/CertificateProvider.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.security; 13 | 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.math.BigInteger; 17 | import java.security.GeneralSecurityException; 18 | import java.security.PrivateKey; 19 | import java.security.PublicKey; 20 | import java.security.cert.CertificateParsingException; 21 | import java.security.cert.X509Certificate; 22 | import java.util.Collection; 23 | import java.util.Date; 24 | import java.util.List; 25 | 26 | /** 27 | * Interface for creating certificates. 28 | * Designed for stack internal use to allow pluggable system of providers. 29 | * 30 | */ 31 | public interface CertificateProvider { 32 | 33 | public byte[] base64Decode(String string); 34 | 35 | public byte[] base64Decode(byte[] bytes); 36 | 37 | public String base64Encode(byte[] bytes); 38 | 39 | public X509Certificate generateCertificate(String domainName, 40 | PublicKey publicKey, PrivateKey privateKey, KeyPair issuerKeys, 41 | Date from, Date to, BigInteger serialNumber, String applicationUri, 42 | String... hostNames) throws GeneralSecurityException, IOException; 43 | 44 | public X509Certificate generateIssuerCert(PublicKey publicKey, 45 | PrivateKey privateKey, KeyPair issuerKeys, String domainName, 46 | BigInteger serialNumber, Date startDate, Date expiryDate) 47 | throws GeneralSecurityException, IOException; 48 | 49 | public Collection> getSubjectAlternativeNames(X509Certificate cert) 50 | throws CertificateParsingException; 51 | 52 | public void writeToPem(X509Certificate key, File savePath, String password, 53 | String algorithm) throws IOException; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/CertificateValidator.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.security; 14 | 15 | import org.opcfoundation.ua.builtintypes.StatusCode; 16 | import org.opcfoundation.ua.core.ApplicationDescription; 17 | 18 | /** 19 | * Certificate Validator estimates the validity of a certificate. 20 | * 21 | * @see AllowAllCertificatesValidator 22 | * @see DefaultCertificateValidator 23 | */ 24 | public interface CertificateValidator { 25 | 26 | public static final CertificateValidator ALLOW_ALL = new AllowAllCertificatesValidator(); 27 | 28 | /** 29 | * Validate (peer's) certificate 30 | * 31 | * @param cert the certificate 32 | * @return Bad statuscode to reject the certificate or Good to accept. 33 | */ 34 | StatusCode validateCertificate(Cert cert); 35 | 36 | /** 37 | * Validate the certificate against the ApplicationDescription. 38 | * 39 | * @param applicationDescription the application description 40 | * @param cert the certificate 41 | * @return Bad statuscode to reject the certificate or Good to accept. 42 | */ 43 | StatusCode validateCertificate(ApplicationDescription applicationDescription, Cert cert); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/CipherParams.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.security; 13 | 14 | /** 15 | *

CipherParams interface.

16 | * 17 | */ 18 | public interface CipherParams { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/KeyPairsKeyManager.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.security; 13 | 14 | import java.net.Socket; 15 | import java.security.Principal; 16 | import java.security.PrivateKey; 17 | import java.security.cert.X509Certificate; 18 | import java.util.Collection; 19 | 20 | import javax.net.ssl.X509KeyManager; 21 | 22 | 23 | /** 24 | * This class adapts a collection of key pair classes into a X509KeyManager. 25 | * 26 | * @author toni.kalajainen@semantum.fi 27 | */ 28 | public class KeyPairsKeyManager implements X509KeyManager { 29 | 30 | Collection keypairs; 31 | 32 | /** 33 | *

Constructor for KeyPairsKeyManager.

34 | * 35 | * @param keypairs a {@link java.util.Collection} object. 36 | */ 37 | public KeyPairsKeyManager(Collection keypairs) { 38 | this.keypairs = keypairs; 39 | } 40 | 41 | /** {@inheritDoc} */ 42 | @Override 43 | public String chooseClientAlias(String[] arg0, Principal[] arg1, Socket arg2) { 44 | return null; 45 | } 46 | 47 | /** {@inheritDoc} */ 48 | @Override 49 | public String chooseServerAlias(String arg0, Principal[] arg1, Socket arg2) { 50 | return null; 51 | } 52 | 53 | /** {@inheritDoc} */ 54 | @Override 55 | public X509Certificate[] getCertificateChain(String arg0) { 56 | return null; 57 | } 58 | 59 | /** {@inheritDoc} */ 60 | @Override 61 | public String[] getClientAliases(String arg0, Principal[] arg1) { 62 | return null; 63 | } 64 | 65 | /** {@inheritDoc} */ 66 | @Override 67 | public PrivateKey getPrivateKey(String arg0) { 68 | return null; 69 | } 70 | 71 | /** {@inheritDoc} */ 72 | @Override 73 | public String[] getServerAliases(String arg0, Principal[] arg1) { 74 | return null; 75 | } 76 | 77 | /** 78 | *

getKeyPairs.

79 | * 80 | * @return a {@link java.util.Collection} object. 81 | */ 82 | public Collection getKeyPairs() { 83 | return keypairs; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/ScJceCryptoProvider.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | package org.opcfoundation.ua.transport.security; 13 | 14 | import org.opcfoundation.ua.utils.CryptoUtil; 15 | 16 | /** 17 | *

ScJceCryptoProvider class.

18 | * 19 | */ 20 | public class ScJceCryptoProvider extends JceCryptoProvider implements CryptoProvider { 21 | 22 | /** 23 | *

Constructor for ScJceCryptoProvider.

24 | */ 25 | public ScJceCryptoProvider() { 26 | super(CryptoUtil.loadOrInstallProvider("SC", "org.spongycastle.jce.provider.BouncyCastleProvider")); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/security/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This folder contains common security related classes 3 | */ 4 | package org.opcfoundation.ua.transport.security; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/impl/ReverseHello.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.impl; 14 | 15 | import java.lang.reflect.Field; 16 | 17 | import org.opcfoundation.ua.encoding.IEncodeable; 18 | import org.opcfoundation.ua.utils.ObjectUtils; 19 | 20 | /** 21 | * ReverseHello is a message used in "reverse" TCP Handshake. Please see 1.04 22 | * Part 6 section 7.1.2.6 and 7.1.3 for more information. 23 | * 24 | */ 25 | public class ReverseHello implements IEncodeable{ 26 | 27 | String ServerUri; // ApplicationUri of the server 28 | String EndpointUrl; // URL Endpoint the client should send Hello 29 | 30 | private static Field[] fields; 31 | 32 | static { 33 | try { 34 | fields = new Field[]{ 35 | ReverseHello.class.getDeclaredField("ServerUri"), 36 | ReverseHello.class.getDeclaredField("EndpointUrl"),}; 37 | } catch (SecurityException e) { 38 | e.printStackTrace(); 39 | } catch (NoSuchFieldException e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | 44 | public static Field[] getFields() { 45 | return fields; 46 | } 47 | 48 | public ReverseHello() { 49 | 50 | } 51 | 52 | public ReverseHello(String serverUri, String endpointUrl) { 53 | this.ServerUri = serverUri; 54 | this.EndpointUrl = endpointUrl; 55 | } 56 | 57 | public String getServerUri() { 58 | return ServerUri; 59 | } 60 | 61 | public void setServerUri(String serverUri) { 62 | ServerUri = serverUri; 63 | } 64 | 65 | public String getEndpointUrl() { 66 | return EndpointUrl; 67 | } 68 | 69 | public void setEndpointUrl(String endpointUrl) { 70 | EndpointUrl = endpointUrl; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "ReverseHello: "+ObjectUtils.printFieldsDeep(this); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/impl/TcpConnectionParameters.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.impl; 14 | 15 | import org.opcfoundation.ua.utils.StackUtils; 16 | 17 | /** 18 | * TCP Connection parameters 19 | */ 20 | public class TcpConnectionParameters implements Cloneable { 21 | 22 | public int maxSendMessageSize = 0; // 0 = no limit 23 | public int maxSendChunkSize = (StackUtils.cores() > 1) ? 8196 : 65536; 24 | public int maxSendChunkCount = 0; // 0 = no limit 25 | 26 | public int maxRecvMessageSize = 0; // 0 = no limit 27 | public int maxRecvChunkSize = (StackUtils.cores() > 1) ? 8196 : 65536; 28 | public int maxRecvChunkCount = 0; // 0 = no limit 29 | 30 | public String endpointUrl; 31 | 32 | /** {@inheritDoc} */ 33 | @Override 34 | //Git issue 245 35 | //Suggestion provided by CWE link (http://cwe.mitre.org/data/definitions/491.html) 36 | public final TcpConnectionParameters clone() { 37 | try { 38 | return (TcpConnectionParameters) super.clone(); 39 | } catch (CloneNotSupportedException e) { 40 | throw new RuntimeException(e); 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/io/TcpConnectionLimits.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.io; 14 | 15 | 16 | /** 17 | * Negotiated connection limits. 18 | */ 19 | public class TcpConnectionLimits implements Cloneable { 20 | 21 | public int maxSendMessageSize; 22 | public int maxSendBufferSize; 23 | public int maxSendChunkCount; 24 | 25 | public int maxRecvMessageSize; 26 | public int maxRecvBufferSize; 27 | public int maxRecvChunkCount; 28 | 29 | /** {@inheritDoc} */ 30 | @Override 31 | //Git issue 245 32 | //Suggestion provided by CWE link (http://cwe.mitre.org/data/definitions/491.html) 33 | public final TcpConnectionLimits clone() { 34 | try { 35 | return (TcpConnectionLimits) super.clone(); 36 | } catch (CloneNotSupportedException e) { 37 | throw new RuntimeException(e); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/io/TcpQuotas.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.io; 14 | 15 | /** 16 | * Tcp connection quotas. Quota values are negotiated between client and server. 17 | * The negotiated values are stored in {@link TcpConnectionLimits}. 18 | */ 19 | public class TcpQuotas { 20 | 21 | /** Constant DEFAULT_CLIENT_QUOTA */ 22 | public static final TcpQuotas DEFAULT_CLIENT_QUOTA = new TcpQuotas(Integer.MAX_VALUE, TcpMessageLimits.MaxBufferSize, TcpMessageLimits.DefaultChannelLifetime, TcpMessageLimits.DefaultSecurityTokenLifeTime); 23 | /** Constant DEFAULT_SERVER_QUOTA */ 24 | public static final TcpQuotas DEFAULT_SERVER_QUOTA = new TcpQuotas(Integer.MAX_VALUE, TcpMessageLimits.MaxBufferSize, TcpMessageLimits.DefaultChannelLifetime, TcpMessageLimits.DefaultSecurityTokenLifeTime); 25 | 26 | public final int maxMessageSize; 27 | public final int maxBufferSize; 28 | public final int channelLifetime; 29 | public final int securityTokenLifetime; 30 | 31 | /** 32 | *

Constructor for TcpQuotas.

33 | * 34 | * @param maxMessageSize a int. 35 | * @param maxBufferSize a int. 36 | * @param channelLifetime a int. 37 | * @param securityTokenLifetime a int. 38 | */ 39 | public TcpQuotas(int maxMessageSize, int maxBufferSize, 40 | int channelLifetime, int securityTokenLifetime) { 41 | 42 | if (maxBufferSize < TcpMessageLimits.MinBufferSize) 43 | throw new IllegalArgumentException(); 44 | 45 | this.maxMessageSize = maxMessageSize; 46 | this.maxBufferSize = maxBufferSize; 47 | this.channelLifetime = channelLifetime; 48 | this.securityTokenLifetime = securityTokenLifetime; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/nio/Channel.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.nio; 14 | 15 | import org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder.MessageListener; 16 | 17 | /** 18 | *

Channel interface.

19 | * 20 | */ 21 | public interface Channel { 22 | 23 | /** 24 | *

addChannelListener.

25 | * 26 | * @param listener a {@link org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder.MessageListener} object. 27 | */ 28 | void addChannelListener(MessageListener listener); 29 | /** 30 | *

removeChannelListener.

31 | * 32 | * @param listener a {@link org.opcfoundation.ua.transport.tcp.nio.SecureInputMessageBuilder.MessageListener} object. 33 | */ 34 | void removeChannelListener(MessageListener listener); 35 | 36 | public static interface ChannelListener { 37 | 38 | /** 39 | * Handle input message. 40 | * 41 | * @param message incoming message 42 | * @return true if message is handled, false if not 43 | */ 44 | boolean handleMessage(InputMessage message); 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/nio/ChunksToMessage.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.nio; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | import java.util.concurrent.Callable; 18 | 19 | import org.opcfoundation.ua.encoding.EncoderContext; 20 | import org.opcfoundation.ua.encoding.IEncodeable; 21 | import org.opcfoundation.ua.encoding.binary.BinaryDecoder; 22 | import org.opcfoundation.ua.transport.tcp.impl.TcpConnectionParameters; 23 | import org.opcfoundation.ua.utils.bytebuffer.ByteBufferArrayReadable; 24 | 25 | /** 26 | * This {@link Callable} class unserializes chunk plaintexts into a message. 27 | */ 28 | public class ChunksToMessage implements Callable { 29 | 30 | Class expectedType; 31 | TcpConnectionParameters ctx; 32 | EncoderContext encoderCtx; 33 | ByteBuffer[] plaintexts; 34 | 35 | /** 36 | *

Constructor for ChunksToMessage.

37 | * 38 | * @param ctx a {@link org.opcfoundation.ua.transport.tcp.impl.TcpConnectionParameters} object. 39 | * @param expectedType type or null (if message expected) 40 | * @param plaintexts a {@link java.nio.ByteBuffer} object. 41 | * @param encoderCtx a {@link org.opcfoundation.ua.encoding.EncoderContext} object. 42 | */ 43 | public ChunksToMessage(TcpConnectionParameters ctx, EncoderContext encoderCtx, Class expectedType, ByteBuffer...plaintexts) 44 | { 45 | this.expectedType = expectedType; 46 | this.plaintexts = plaintexts; 47 | this.ctx = ctx; 48 | this.encoderCtx = encoderCtx; 49 | } 50 | 51 | /** {@inheritDoc} */ 52 | @Override 53 | public IEncodeable call() throws Exception { 54 | ByteBufferArrayReadable readable = new ByteBufferArrayReadable(plaintexts); 55 | readable.order(ByteOrder.LITTLE_ENDIAN); 56 | BinaryDecoder dec = new BinaryDecoder(readable); 57 | dec.setEncoderContext(encoderCtx); 58 | if (expectedType!=null) 59 | return dec.getEncodeable(null, expectedType); 60 | else 61 | return dec.getMessage(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/nio/MessageType.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.nio; 14 | 15 | /** 16 | *

MessageType class.

17 | */ 18 | public enum MessageType { 19 | 20 | Encodeable, 21 | Message 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/nio/MessageWriteState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.transport.tcp.nio; 14 | 15 | import java.util.EnumSet; 16 | 17 | 18 | /** 19 | * Message write states. 20 | * 21 | * Initial states: Ready 22 | * Final states: Canceled, Error, Flushed 23 | * 24 | * State transition paths: 25 | *

26 | * Encoding -> Encrypting -> Writing -> Flushed 27 | *

28 | * Encoding -> Encrypting -> Writing -> Error 29 | *

30 | * Encoding -> Encrypting -> Writing -> Canceled 31 | *

32 | * Encoding -> Encrypting -> Error 33 | *

34 | * Encoding -> Encrypting -> Canceled 35 | *

36 | * Encoding -> Error 37 | *

38 | * Encoding -> Canceled 39 | */ 40 | public enum MessageWriteState { 41 | 42 | Encoding, 43 | Encrypting, 44 | Writing, 45 | Flushed, 46 | Error, 47 | Canceled; 48 | 49 | public static final EnumSet FINAL_STATES = EnumSet.of(Error, Canceled, Flushed); 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/transport/tcp/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Code for creating TCP/IP based secure channel (in subpackages) 3 | */ 4 | package org.opcfoundation.ua.transport.tcp; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/AbstractStructure.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.utils; 2 | 3 | import org.opcfoundation.ua.builtintypes.ExpandedNodeId; 4 | import org.opcfoundation.ua.builtintypes.Structure; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * A base class for Structure implementations. Main use case for extending this class 10 | * is the default implementation for .clone which does not throw {@link CloneNotSupportedException} 11 | * in .clone method signature as Structure as of GH#65 extends Cloneable making it easier for 12 | * classes extending this class to just call super.clone without a try-catch block. 13 | */ 14 | public abstract class AbstractStructure implements Structure{ 15 | 16 | private static final Logger logger = LoggerFactory.getLogger(AbstractStructure.class); 17 | 18 | @Override 19 | public AbstractStructure clone() { 20 | try { 21 | return (AbstractStructure) super.clone(); 22 | } catch (CloneNotSupportedException e) { 23 | //It should be technically impossible for this call to fail as 24 | //Structure extends Cloneable, but handing this just in case. 25 | logger.error("Got a CloneNotSupportedException, should be impossible",e); 26 | throw new Error("Every Structure implementation shall be Cloneable", e); 27 | } 28 | } 29 | 30 | /** 31 | * Returns null by default unless overridden. 32 | */ 33 | @Override 34 | public ExpandedNodeId getXmlEncodeId() { 35 | return null; 36 | } 37 | 38 | /** 39 | * Returns null by default unless overridden. 40 | */ 41 | @Override 42 | public ExpandedNodeId getJsonEncodeId() { 43 | return null; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/CurrentThreadExecutor.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | import java.util.concurrent.Executor; 16 | 17 | /** 18 | * Executor that executes commands immediately in invokers thread. 19 | * 20 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 21 | */ 22 | public class CurrentThreadExecutor implements Executor { 23 | 24 | /** Constant INSTANCE */ 25 | public static final Executor INSTANCE = new CurrentThreadExecutor(); 26 | 27 | /** {@inheritDoc} */ 28 | public void execute(Runnable command) { 29 | command.run(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/Description.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | /** 19 | * Description 20 | */ 21 | @Retention(RetentionPolicy.RUNTIME) 22 | public @interface Description { 23 | String value(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/EncodingLimitsExceededIoException.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | import java.io.IOException; 16 | 17 | public class EncodingLimitsExceededIoException extends IOException{ 18 | 19 | private static final long serialVersionUID = -2400543558503916812L; 20 | 21 | public EncodingLimitsExceededIoException(String message) { 22 | super(message); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/SizeCalculationOutputStream.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | import java.io.OutputStream; 16 | import java.util.concurrent.atomic.AtomicInteger; 17 | 18 | /** 19 | * An OutputStream that only calculates the number of bytes written to it. 20 | * 21 | */ 22 | public class SizeCalculationOutputStream extends OutputStream{ 23 | 24 | private final AtomicInteger calc; 25 | 26 | /** 27 | * Create new {@link SizeCalculationOutputStream} with byte count of 0. 28 | */ 29 | public SizeCalculationOutputStream() { 30 | calc = new AtomicInteger(); 31 | } 32 | 33 | @Override 34 | public void write(int b) { 35 | calc.incrementAndGet(); 36 | } 37 | 38 | @Override 39 | public void write(byte[] b, int off, int len) { 40 | calc.addAndGet(len); 41 | } 42 | 43 | @Override 44 | public void write(byte[] b) { 45 | //NOTE, if b is null will throw NPE, which the the same logic as in OutputStream. 46 | calc.addAndGet(b.length); 47 | } 48 | 49 | /** 50 | * Gets current byte count of the stream. 51 | */ 52 | public int getLength() { 53 | return calc.get(); 54 | } 55 | 56 | /** 57 | * Resets current byte count to 0. 58 | */ 59 | public void reset() { 60 | calc.set(0); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/State.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | /** 16 | *

State class.

17 | * 18 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 19 | */ 20 | public class State extends AbstractState { 21 | 22 | /** 23 | *

Constructor for State.

24 | * 25 | * @param initialState a StateType object. 26 | */ 27 | public State(StateType initialState) { 28 | super(initialState); 29 | } 30 | 31 | /** 32 | *

setState.

33 | * 34 | * @param state a StateType object. 35 | * @return a boolean. 36 | */ 37 | public boolean setState(StateType state) { 38 | return super.setState(state); 39 | } 40 | 41 | /** {@inheritDoc} */ 42 | public StateType setState(StateType state, java.util.concurrent.Executor listenerExecutor, java.util.Set prerequisiteStates) { 43 | return super.setState(state, listenerExecutor, prerequisiteStates); 44 | }; 45 | 46 | /** 47 | *

setError.

48 | * 49 | * @param error a {@link java.lang.RuntimeException} object. 50 | */ 51 | public void setError(RuntimeException error) { 52 | super.setError(error); 53 | } 54 | 55 | /** 56 | *

attemptSetState.

57 | * 58 | * @param prerequisiteState a {@link java.util.Set} object. 59 | * @param newState a StateType object. 60 | * @return a StateType object. 61 | */ 62 | public StateType attemptSetState(java.util.Set prerequisiteState, StateType newState) { 63 | return super.attemptSetState(prerequisiteState, newState); 64 | } 65 | 66 | /** {@inheritDoc} */ 67 | @Override 68 | public void assertNoError() throws RuntimeException { 69 | super.assertNoError(); 70 | } 71 | 72 | /** {@inheritDoc} */ 73 | @Override 74 | protected void clearError() { 75 | super.clearError(); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/StateListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils; 14 | 15 | /** 16 | * Listener for state changes 17 | * 18 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 19 | */ 20 | public interface StateListener { 21 | 22 | /** 23 | * Call-back for state transition 24 | * 25 | * @param sender State monitor object 26 | * @param oldState new state 27 | * @param newState new state 28 | */ 29 | void onStateTransition(IStatefulObject sender, StateType oldState, StateType newState); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/AsyncSocket.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.asyncsocket; 14 | 15 | import java.io.IOException; 16 | import java.net.Socket; 17 | import java.net.SocketAddress; 18 | import java.nio.channels.SocketChannel; 19 | 20 | import org.opcfoundation.ua.utils.IStatefulObject; 21 | 22 | /** 23 | *

AsyncSocket interface.

24 | * 25 | * @see AsyncSocketImpl 26 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 27 | */ 28 | public interface AsyncSocket { 29 | 30 | /** 31 | *

getInputStream.

32 | * 33 | * @return a {@link org.opcfoundation.ua.utils.asyncsocket.AsyncInputStream} object. 34 | */ 35 | AsyncInputStream getInputStream(); 36 | /** 37 | *

getOutputStream.

38 | * 39 | * @return a {@link org.opcfoundation.ua.utils.asyncsocket.AsyncOutputStream} object. 40 | */ 41 | AsyncOutputStream getOutputStream(); 42 | /** 43 | *

close.

44 | * 45 | * @return a {@link org.opcfoundation.ua.utils.asyncsocket.AsyncSocketImpl} object. 46 | * @throws java.io.IOException if any. 47 | */ 48 | AsyncSocketImpl close() throws IOException; 49 | /** 50 | *

socketChannel.

51 | * 52 | * @return a {@link java.nio.channels.SocketChannel} object. 53 | */ 54 | SocketChannel socketChannel(); 55 | /** 56 | *

socket.

57 | * 58 | * @return a {@link java.net.Socket} object. 59 | */ 60 | Socket socket(); 61 | /** 62 | *

connect.

63 | * 64 | * @param addr a {@link java.net.SocketAddress} object. 65 | * @throws java.io.IOException if any. 66 | */ 67 | void connect(SocketAddress addr) throws IOException; 68 | /** 69 | *

getStateMonitor.

70 | * 71 | * @return a {@link org.opcfoundation.ua.utils.IStatefulObject} object. 72 | */ 73 | IStatefulObject getStateMonitor(); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/BufferMonitorState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.asyncsocket; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Server Socket states. 19 | * 20 | * Initial states: Waiting 21 | * Final states: Triggered, Canceled, Error 22 | * 23 | * State transitions: 24 | * Waiting -> Triggered 25 | * Waiting -> Canceled 26 | * Waiting -> Closed 27 | * Waiting -> Error 28 | * 29 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 30 | */ 31 | public enum BufferMonitorState { 32 | 33 | Waiting, // Alarm is waiting 34 | Triggered, // Alarm has been triggered 35 | Canceled, // Canceled by user 36 | Closed, // Stream was closed before trigger position could be reached 37 | Error; // Error occured before trigger position could be reached 38 | 39 | public static final EnumSet FINAL_STATES = EnumSet.of(Triggered, Canceled, Error, Closed); 40 | public static final EnumSet UNREACHABLE = EnumSet.of(Error, Closed); 41 | 42 | public boolean isFinal() { 43 | return FINAL_STATES.contains(this); 44 | } 45 | 46 | /** 47 | * Tests if the state is unreachable 48 | * 49 | * @return if true the state is unreachable 50 | */ 51 | public boolean isUnreachable() { 52 | return this == Error || this == Closed; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/MonitorListener.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.asyncsocket; 14 | 15 | import org.opcfoundation.ua.utils.StateListener; 16 | 17 | /** 18 | *

MonitorListener interface.

19 | * 20 | */ 21 | public interface MonitorListener extends StateListener { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/ServerSocketState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.asyncsocket; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Servcer Socket states. 19 | * 20 | * Initial states: Ready 21 | * Final states: Closed, Error 22 | * 23 | * State transitions: 24 | * Ready -> Bound -> Closed 25 | * Ready -> Bound -> Error 26 | * Ready -> Closed 27 | * 28 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 29 | */ 30 | public enum ServerSocketState { 31 | 32 | Ready, // Channel is open but not bound 33 | Bound, // Server is bound and accepting connections 34 | Error, // Error occured. See getError(). 35 | Closed; // Channel has been closed and system resources have been released 36 | 37 | public static final EnumSet OPEN_STATES = EnumSet.of(Ready, Bound); 38 | public static final EnumSet ERROR_STATES = EnumSet.of(Error); 39 | public static final EnumSet INITIAL_STATES = EnumSet.of(Ready); 40 | public static final EnumSet FINAL_STATES = EnumSet.of(Closed, Error); 41 | public static final EnumSet READY_TRANSITION_STATES = EnumSet.of(Bound, Closed); 42 | public static final EnumSet BOUND_TRANSITION_STATES = EnumSet.of(Closed, Error); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/SocketState.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.asyncsocket; 14 | 15 | import java.util.EnumSet; 16 | 17 | /** 18 | * Socket states. 19 | * 20 | * Initial states: Ready 21 | * Final states: Error, Closed 22 | * 23 | * State transitions: 24 | * Ready -> Connecting -> Connected -> Closed 25 | * Ready -> Connecting -> Connected -> Error 26 | * Ready -> Connecting -> Error 27 | * Ready -> Closed 28 | * 29 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 30 | */ 31 | public enum SocketState { 32 | 33 | Ready, // Initial state 34 | Connecting, // Connecting 35 | Connected, // Connected 36 | Error, // Closed with Error, see getError() 37 | Closed; // Closed and unusable 38 | 39 | public static final EnumSet OPEN_STATES = EnumSet.of(Ready, Connecting, Connected); 40 | public static final EnumSet ERROR_STATES = EnumSet.of(Error); 41 | public static final EnumSet INITIAL_STATES = EnumSet.of(Ready); 42 | public static final EnumSet NON_FINAL_STATES = EnumSet.of(Ready, Connecting, Connected); 43 | public static final EnumSet FINAL_STATES = EnumSet.of(Closed, Error); 44 | public static final EnumSet CONNECTED_TRANSITION_STATES = EnumSet.of(Closed, Error); 45 | public static final EnumSet CONNECTING_TRANSITION_STATES = EnumSet.of(Closed, Connected, Error); 46 | 47 | public boolean isFinal() 48 | { 49 | return FINAL_STATES.contains(this); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/asyncsocket/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Small java NIO based library that enables asynchronous and event based socket operations 3 | */ 4 | package org.opcfoundation.ua.utils.asyncsocket; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/bytebuffer/ByteBufferFactory.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.bytebuffer; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | /** 19 | *

Abstract ByteBufferFactory class.

20 | * 21 | * @author Toni Kalajainen (toni.kalajainen@vtt.fi) 22 | */ 23 | public abstract class ByteBufferFactory { 24 | 25 | /** Constant DEFAULT_ENDIAN_HEAP_BYTEBUFFER_FACTORY */ 26 | public static final ByteBufferFactory DEFAULT_ENDIAN_HEAP_BYTEBUFFER_FACTORY = 27 | new ByteBufferFactory() { 28 | @Override 29 | public ByteBuffer allocate(int capacity) { 30 | ByteBuffer result = ByteBuffer.allocate(capacity); 31 | result.order(ByteOrder.nativeOrder()); 32 | return null; 33 | }}; 34 | 35 | /** Constant LITTLE_ENDIAN_HEAP_BYTEBUFFER_FACTORY */ 36 | public static final ByteBufferFactory LITTLE_ENDIAN_HEAP_BYTEBUFFER_FACTORY = 37 | new ByteBufferFactory() { 38 | @Override 39 | public ByteBuffer allocate(int capacity) { 40 | ByteBuffer result = ByteBuffer.allocate(capacity); 41 | result.order(ByteOrder.LITTLE_ENDIAN); 42 | return result; 43 | }}; 44 | /** Constant BIG_ENDIAN_HEAP_BYTEBUFFER_FACTORY */ 45 | public static final ByteBufferFactory BIG_ENDIAN_HEAP_BYTEBUFFER_FACTORY = 46 | new ByteBufferFactory() { 47 | @Override 48 | public ByteBuffer allocate(int capacity) { 49 | ByteBuffer result = ByteBuffer.allocate(capacity); 50 | result.order(ByteOrder.BIG_ENDIAN); 51 | return result; 52 | }}; 53 | 54 | /** 55 | *

allocate.

56 | * 57 | * @param capacity a int. 58 | * @return a {@link java.nio.ByteBuffer} object. 59 | */ 60 | public abstract ByteBuffer allocate(int capacity); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/bytebuffer/ByteBufferUtils.java: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1996-2015, OPC Foundation. All rights reserved. 2 | The source code in this file is covered under a dual-license scenario: 3 | - RCL: for OPC Foundation members in good-standing 4 | - GPL V2: everybody else 5 | RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/ 6 | GNU General Public License as published by the Free Software Foundation; 7 | version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2 8 | This source code is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | */ 12 | 13 | package org.opcfoundation.ua.utils.bytebuffer; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.util.Arrays; 17 | 18 | /** 19 | *

ByteBufferUtils class.

20 | */ 21 | public class ByteBufferUtils { 22 | 23 | /** 24 | * Copies as much as possible 25 | * 26 | * @param src a {@link java.nio.ByteBuffer} object. 27 | * @param dst a {@link java.nio.ByteBuffer} object. 28 | */ 29 | public static void copyRemaining(ByteBuffer src, ByteBuffer dst) 30 | { 31 | int n = Math.min(src.remaining(), dst.remaining()); 32 | copy(src, dst, n); 33 | } 34 | 35 | /** 36 | *

copy.

37 | * 38 | * @param src a {@link java.nio.ByteBuffer} object. 39 | * @param dst a {@link java.nio.ByteBuffer} object. 40 | * @param length a int. 41 | */ 42 | public static void copy(ByteBuffer src, ByteBuffer dst, int length) 43 | { 44 | int srcLimit = src.limit(); 45 | int dstLimit = dst.limit(); 46 | src.limit(src.position() + length); 47 | dst.limit(dst.position() + length); 48 | dst.put(src); 49 | src.limit(srcLimit); 50 | dst.limit(dstLimit); 51 | } 52 | 53 | /** 54 | * Concatenate two arrays to one 55 | * 56 | * @param chunks an array of byte. 57 | * @return concatenation of all chunks 58 | */ 59 | public static byte[] concatenate(byte[]...chunks) 60 | { 61 | int len = 0; 62 | for (byte[] chunk : chunks) 63 | len += chunk.length; 64 | byte result[] = new byte[len]; 65 | int pos = 0; 66 | for (byte[] chunk : chunks) 67 | { 68 | System.arraycopy(chunk, 0, result, pos, chunk.length); 69 | pos += chunk.length; 70 | } 71 | return result; 72 | } 73 | 74 | /** 75 | * Fill the byte array with 0 values. 76 | * 77 | * @param value an array of byte. 78 | */ 79 | public static void clear(byte[] value) 80 | { 81 | Arrays.fill(value, (byte)0); 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/bytebuffer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * A byte buffer implementation 3 | */ 4 | package org.opcfoundation.ua.utils.bytebuffer; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/org/opcfoundation/ua/utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility classes 3 | */ 4 | package org.opcfoundation.ua.utils; 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/.gitignore: -------------------------------------------------------------------------------- 1 | #Ignores nothing but allows us to have this folder in the repo as it is in maven standard layout 2 | # -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/BuildHelper.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua; 2 | 3 | public class BuildHelper { 4 | 5 | public static boolean isJdk6Toolchain() { 6 | return "true".equalsIgnoreCase(System.getProperty("useJdk6Toolchain")); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/ByteStringTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class ByteStringTest { 8 | 9 | @Test 10 | public void testByteStringConstructorValueCopy() throws Exception { 11 | //tests that the constructor of ByteString does copy the array 12 | byte[] changing = new byte[]{1,2,3,4,5,6,7,8,9}; 13 | byte[] original = new byte[]{1,2,3,4,5,6,7,8,9}; 14 | ByteString bs1 = ByteString.valueOf(changing); 15 | ByteString bs2 = ByteString.valueOf(original); 16 | 17 | //change the bs1 input data -- should not effect it 18 | changing[0] = 10; 19 | assertEquals(bs1, bs2); 20 | } 21 | 22 | @Test 23 | public void testByteStringEquals() throws Exception { 24 | byte[] b1 = new byte[]{1,2,3,4,5,6,7,8,9}; 25 | byte[] b2 = new byte[]{1,2,3,4,5,6,7,8,9}; 26 | 27 | byte[] b3 = new byte[]{2,2,3,4,5,6,7,8,9};//1->2 28 | ByteString bs1 = ByteString.valueOf(b1); 29 | ByteString bs2 = ByteString.valueOf(b2); 30 | ByteString bs3 = ByteString.valueOf(b3); 31 | 32 | assertEquals(bs1, bs2); 33 | assertNotEquals(bs1, bs3); 34 | } 35 | 36 | @Test 37 | public void testByteStringHashCode() throws Exception { 38 | byte[] b1 = new byte[]{1,2,3,4,5,6,7,8,9}; 39 | byte[] b2 = new byte[]{1,2,3,4,5,6,7,8,9}; 40 | 41 | ByteString bs1 = ByteString.valueOf(b1); 42 | ByteString bs2 = ByteString.valueOf(b2); 43 | 44 | //hashcodes should match 45 | assertEquals(bs1.hashCode(), bs2.hashCode()); 46 | } 47 | 48 | @Test 49 | public void testByteStringReturnCopy() throws Exception { 50 | //tests that returned byte array is different java object 51 | 52 | byte[] b = new byte[]{1,2,3,4,5,6,7,8,9}; 53 | ByteString bs = ByteString.valueOf(b); 54 | assertNotSame(bs.getValue(), b); 55 | 56 | } 57 | 58 | @Test 59 | public void testByteStringValueReturnIsCopy() throws Exception { 60 | // Ensures that the output value returned from ByteString is a copy 61 | // and not the internal state 62 | byte[] b1 = new byte[]{1,2,3,4,5,6,7,8,9}; 63 | byte[] b2 = new byte[]{1,2,3,4,5,6,7,8,9}; 64 | 65 | ByteString bs1 = ByteString.valueOf(b1); 66 | ByteString bs2 = ByteString.valueOf(b2); 67 | 68 | byte[] r = bs1.getValue(); 69 | r[0] = 10; 70 | 71 | assertEquals(bs1, bs2); 72 | 73 | } 74 | 75 | @Test 76 | public void testToString() throws Exception { 77 | byte[] b1 = new byte[]{1,2,3,4,5,6,7,8,110}; 78 | ByteString bs = ByteString.valueOf(b1); 79 | System.out.println(bs); 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/ExtensionObjectTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.opcfoundation.ua.core.AddNodesItem; 7 | 8 | public class ExtensionObjectTest { 9 | 10 | @Test 11 | public void lazyEncodeEquals() throws Exception{ 12 | ExtensionObject e1 = new ExtensionObject(new AddNodesItem()); 13 | ExtensionObject e2 = new ExtensionObject(new AddNodesItem()); 14 | 15 | assertEquals(e1, e2); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/UnsignedByteTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class UnsignedByteTest { 8 | 9 | @Test 10 | public void parseString() throws Exception { 11 | assertEquals(new UnsignedByte(0), UnsignedByte.parseUnsignedByte("0", 10)); 12 | assertEquals(new UnsignedByte(0), UnsignedByte.parseUnsignedByte("-0", 10)); 13 | assertEquals(new UnsignedByte(102), UnsignedByte.parseUnsignedByte("1100110", 2)); 14 | assertEquals(new UnsignedByte(255), UnsignedByte.parseUnsignedByte("255", 10)); 15 | assertEquals(new UnsignedByte(0), UnsignedByte.parseUnsignedByte("0", 10)); 16 | assertEquals(new UnsignedByte(20), UnsignedByte.parseUnsignedByte("K", 27)); 17 | } 18 | 19 | @Test(expected = IllegalArgumentException.class) 20 | public void parseErrorString() throws Exception { 21 | UnsignedByte.parseUnsignedByte("-FF", 16); 22 | } 23 | 24 | @Test(expected = IllegalArgumentException.class) 25 | public void parseErrorString2() throws Exception { 26 | UnsignedByte.parseUnsignedByte("256", 10); 27 | } 28 | 29 | @Test(expected = IllegalArgumentException.class) 30 | public void parseErrorString3() throws Exception { 31 | UnsignedByte.parseUnsignedByte("-1", 10); 32 | } 33 | 34 | @Test(expected = NumberFormatException.class) 35 | public void parseErrorString4() throws Exception { 36 | UnsignedByte.parseUnsignedByte("99", 8); 37 | } 38 | 39 | @Test(expected = NumberFormatException.class) 40 | public void parseErrorString5() throws Exception { 41 | UnsignedByte.parseUnsignedByte("Kona", 10); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/UnsignedIntegerTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class UnsignedIntegerTest { 8 | 9 | @Test 10 | public void parseString() throws Exception { 11 | assertEquals(new UnsignedInteger(0), UnsignedInteger.parseUnsignedInteger("0", 10)); 12 | assertEquals(new UnsignedInteger(473), UnsignedInteger.parseUnsignedInteger("473", 10)); 13 | assertEquals(new UnsignedInteger(0), UnsignedInteger.parseUnsignedInteger("-0", 10)); 14 | assertEquals(new UnsignedInteger(102), UnsignedInteger.parseUnsignedInteger("1100110", 2)); 15 | assertEquals(new UnsignedInteger(4294967295l), UnsignedInteger.parseUnsignedInteger("4294967295", 10)); 16 | assertEquals(new UnsignedInteger(0), UnsignedInteger.parseUnsignedInteger("0", 10)); 17 | assertEquals(new UnsignedInteger(411787), UnsignedInteger.parseUnsignedInteger("Kona", 27)); 18 | } 19 | 20 | @Test(expected = IllegalArgumentException.class) 21 | public void parseErrorString() throws Exception { 22 | UnsignedInteger.parseUnsignedInteger("-FF", 16); 23 | } 24 | 25 | @Test(expected = IllegalArgumentException.class) 26 | public void parseErrorString2() throws Exception { 27 | UnsignedInteger.parseUnsignedInteger("4294967296", 10); 28 | } 29 | 30 | @Test(expected = IllegalArgumentException.class) 31 | public void parseErrorString3() throws Exception { 32 | UnsignedInteger.parseUnsignedInteger("-1", 10); 33 | } 34 | 35 | @Test(expected = NumberFormatException.class) 36 | public void parseErrorString4() throws Exception { 37 | UnsignedInteger.parseUnsignedInteger("99", 8); 38 | } 39 | 40 | @Test(expected = NumberFormatException.class) 41 | public void parseErrorString5() throws Exception { 42 | UnsignedInteger.parseUnsignedInteger("Kona", 10); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/UnsignedLongTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class UnsignedLongTest { 8 | 9 | @Test 10 | public void parseString() throws Exception { 11 | assertEquals(new UnsignedLong(0), UnsignedLong.parseUnsignedLong("0", 10)); 12 | assertEquals(new UnsignedLong(473), UnsignedLong.parseUnsignedLong("473", 10)); 13 | assertEquals(new UnsignedLong(0), UnsignedLong.parseUnsignedLong("-0", 10)); 14 | assertEquals(new UnsignedLong(102), UnsignedLong.parseUnsignedLong("1100110", 2)); 15 | assertEquals(UnsignedLong.MAX_VALUE, UnsignedLong.parseUnsignedLong("18446744073709551615", 10)); 16 | assertEquals(new UnsignedLong(0), UnsignedLong.parseUnsignedLong("0", 10)); 17 | assertEquals(new UnsignedLong(411787), UnsignedLong.parseUnsignedLong("Kona", 27)); 18 | } 19 | 20 | @Test(expected = IllegalArgumentException.class) 21 | public void parseErrorString() throws Exception { 22 | UnsignedLong.parseUnsignedLong("-FF", 16); 23 | } 24 | 25 | @Test(expected = IllegalArgumentException.class) 26 | public void parseErrorString2() throws Exception { 27 | UnsignedLong.parseUnsignedLong("18446744073709551616", 10); 28 | } 29 | 30 | @Test(expected = IllegalArgumentException.class) 31 | public void parseErrorString3() throws Exception { 32 | UnsignedLong.parseUnsignedLong("-1", 10); 33 | } 34 | 35 | @Test(expected = NumberFormatException.class) 36 | public void parseErrorString4() throws Exception { 37 | UnsignedLong.parseUnsignedLong("99", 8); 38 | } 39 | 40 | @Test(expected = NumberFormatException.class) 41 | public void parseErrorString5() throws Exception { 42 | UnsignedLong.parseUnsignedLong("Kona", 10); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/builtintypes/UnsignedShortTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.builtintypes; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class UnsignedShortTest { 8 | 9 | @Test 10 | public void parseString() throws Exception { 11 | assertEquals(new UnsignedShort(0), UnsignedShort.parseUnsignedShort("0", 10)); 12 | assertEquals(new UnsignedShort(473), UnsignedShort.parseUnsignedShort("473", 10)); 13 | assertEquals(new UnsignedShort(0), UnsignedShort.parseUnsignedShort("-0", 10)); 14 | assertEquals(new UnsignedShort(102), UnsignedShort.parseUnsignedShort("1100110", 2)); 15 | assertEquals(new UnsignedShort(65535), UnsignedShort.parseUnsignedShort("65535", 10)); 16 | assertEquals(new UnsignedShort(0), UnsignedShort.parseUnsignedShort("0", 10)); 17 | assertEquals(new UnsignedShort(280), UnsignedShort.parseUnsignedShort("aa", 27)); 18 | } 19 | 20 | @Test(expected = IllegalArgumentException.class) 21 | public void parseErrorString() throws Exception { 22 | UnsignedShort.parseUnsignedShort("-FF", 16); 23 | } 24 | 25 | @Test(expected = IllegalArgumentException.class) 26 | public void parseErrorString2() throws Exception { 27 | UnsignedShort.parseUnsignedShort("65536", 10); 28 | } 29 | 30 | @Test(expected = IllegalArgumentException.class) 31 | public void parseErrorString3() throws Exception { 32 | UnsignedShort.parseUnsignedShort("-1", 10); 33 | } 34 | 35 | @Test(expected = NumberFormatException.class) 36 | public void parseErrorString4() throws Exception { 37 | UnsignedShort.parseUnsignedShort("99", 8); 38 | } 39 | 40 | @Test(expected = NumberFormatException.class) 41 | public void parseErrorString5() throws Exception { 42 | UnsignedShort.parseUnsignedShort("Kona", 10); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/cert/CertificateStoreTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.cert; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertTrue; 5 | import static org.mockito.Mockito.mock; 6 | import static org.mockito.Mockito.when; 7 | 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | import org.opcfoundation.ua.builtintypes.StatusCode; 14 | import org.opcfoundation.ua.core.StatusCodes; 15 | import org.opcfoundation.ua.transport.security.Cert; 16 | import org.opcfoundation.ua.transport.security.KeyPair; 17 | import org.opcfoundation.ua.utils.CertificateUtils; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | 21 | public class CertificateStoreTest { 22 | 23 | private static final Logger logger = LoggerFactory.getLogger(CertificateStoreTest.class); 24 | private static Cert cert; 25 | private static Cert cert2; 26 | 27 | @Test 28 | public void testCerts() throws Exception { 29 | CertificateStore store = mock(CertificateStore.class); 30 | Set temp = new HashSet(); 31 | temp.add(cert); 32 | when(store.getTrustedCerts()).thenReturn(temp); 33 | 34 | DefaultCertificateValidator validator = new DefaultCertificateValidator(store); 35 | 36 | //this cert should be accepted because it is in trusted dir 37 | StatusCode code = validator.validateCertificate(cert); 38 | assertTrue(code.isGood()); 39 | 40 | //this cert should not be accepted because it is not in trusted dir 41 | StatusCode code2 = validator.validateCertificate(cert2); 42 | assertTrue(!code2.isGood()); 43 | assertEquals(StatusCodes.Bad_SecurityChecksFailed.intValue(), code2.getValue().intValue()); 44 | } 45 | 46 | @BeforeClass 47 | public static void generateCertificates() throws Exception{ 48 | logger.info("Generating in-memory test certificates..."); 49 | String applicationUri = "urn:localhost:OPCUA:testapplication"; 50 | String hostNames = "localhost"; 51 | String commonName = "commonname"; 52 | String organisation = "test organization"; 53 | int validityTime = 356; //days 54 | 55 | //test cert 1 56 | KeyPair kp = CertificateUtils.createApplicationInstanceCertificate(commonName, organisation, applicationUri, validityTime, hostNames); 57 | cert = kp.getCertificate(); 58 | 59 | //test cert 2 60 | applicationUri = "urn:localhost:OPCUA:testapplication2"; 61 | KeyPair kp2 = CertificateUtils.createApplicationInstanceCertificate(commonName, organisation, applicationUri, validityTime, hostNames); 62 | cert2 = kp2.getCertificate(); 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/common/NamespaceTableTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.common; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.opcfoundation.ua.builtintypes.ExpandedNodeId; 7 | import org.opcfoundation.ua.builtintypes.NodeId; 8 | 9 | public class NamespaceTableTest { 10 | 11 | @Test 12 | public void testNodeIdEqualsOpaque() throws Exception { 13 | NamespaceTable testTable = new NamespaceTable(); 14 | NodeId b = new NodeId(1, new byte[] { 'a', '0' }); 15 | ExpandedNodeId c = new ExpandedNodeId(null, 1, new byte[] { 'a', '0' }); 16 | ExpandedNodeId d = new ExpandedNodeId(null, 1, new byte[] { 'a', '0' }); 17 | ExpandedNodeId e = new ExpandedNodeId(null, 1, new byte[] { 'a', '0', '1' }); 18 | 19 | assertEquals(true, testTable.nodeIdEquals(b, c)); 20 | assertEquals(true, testTable.nodeIdEquals(d, c)); 21 | 22 | assertEquals(false, testTable.nodeIdEquals(b, e)); 23 | assertEquals(false, testTable.nodeIdEquals(d, e)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/core/StandardEngineeringUnitsTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.core; 2 | 3 | import static org.junit.Assert.assertSame; 4 | 5 | import org.junit.Test; 6 | 7 | public class StandardEngineeringUnitsTest { 8 | 9 | @Test 10 | public void testPrint() throws Exception { 11 | print(StandardEngineeringUnits.AIR_DRY_TON); 12 | print(StandardEngineeringUnits.TONNE_PER_CUBIC_METRE); 13 | 14 | } 15 | 16 | @Test 17 | public void testFindWithCommonCode() throws Exception { 18 | EUInformation eu = StandardEngineeringUnits.getByCommonCode("D41"); 19 | assertSame(StandardEngineeringUnits.TONNE_PER_CUBIC_METRE, eu); 20 | } 21 | 22 | @Test 23 | public void testFindWithUnitId() throws Exception { 24 | EUInformation eu = StandardEngineeringUnits.getByUnitId(4534840); 25 | assertSame(StandardEngineeringUnits.AIR_DRY_TON, eu); 26 | } 27 | 28 | private static void print(EUInformation eu){ 29 | System.out.println(eu.getDescription()); 30 | System.out.println(eu.getDisplayName()); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/encoding/binary/ByteUtilsTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.encoding.binary; 2 | 3 | import static org.junit.Assert.assertArrayEquals; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import org.junit.Test; 7 | 8 | public class ByteUtilsTest { 9 | @Test 10 | public void reverseNullElement() throws Exception { 11 | byte[] actual = ByteUtils.reverse(null); 12 | assertNull(actual); 13 | } 14 | 15 | @Test 16 | public void reverse0Element() throws Exception { 17 | byte[] d = new byte[] {}; 18 | byte[] expected = new byte[] {}; 19 | byte[] actual = ByteUtils.reverse(d); 20 | assertArrayEquals(expected, actual); 21 | } 22 | 23 | @Test 24 | public void reverse1Element() throws Exception { 25 | byte[] d = new byte[] {1}; 26 | byte[] expected = new byte[] {1}; 27 | byte[] actual = ByteUtils.reverse(d); 28 | assertArrayEquals(expected, actual); 29 | } 30 | 31 | @Test 32 | public void reverse2Element() throws Exception { 33 | byte[] d = new byte[] {1,2}; 34 | byte[] expected = new byte[] {2,1}; 35 | byte[] actual = ByteUtils.reverse(d); 36 | assertArrayEquals(expected, actual); 37 | } 38 | 39 | @Test 40 | public void reverse3Element() throws Exception { 41 | byte[] d = new byte[] {1,2,3}; 42 | byte[] expected = new byte[] {3,2,1}; 43 | byte[] actual = ByteUtils.reverse(d); 44 | assertArrayEquals(expected, actual); 45 | } 46 | 47 | @Test 48 | public void reverse4Element() throws Exception { 49 | byte[] d = new byte[] {1,2,3,4}; 50 | byte[] expected = new byte[] {4,3,2,1}; 51 | byte[] actual = ByteUtils.reverse(d); 52 | assertArrayEquals(expected, actual); 53 | } 54 | 55 | @Test 56 | public void concat() throws Exception { 57 | byte[] f = new byte[] {1,2}; 58 | byte[] s = new byte[] {3,4}; 59 | byte[] expected = new byte[] {1,2,3,4}; 60 | byte[] actual = ByteUtils.concat(f, s); 61 | assertArrayEquals(expected, actual); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/transport/security/BcCryptoProviderTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.transport.security; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class BcCryptoProviderTest { 8 | 9 | @Test 10 | public void base64decode() throws Exception { 11 | // "teststring" encoded as Base64 12 | String data = "dGVzdHN0cmluZw=="; 13 | BcCryptoProvider sut = new BcCryptoProvider(); 14 | String out = new String(sut.base64Decode(data)); 15 | assertEquals("teststring", out); 16 | } 17 | 18 | @Test 19 | public void base64decodeWithWhitespace() throws Exception { 20 | // "teststring" encoded as Base64 21 | String data = "dGVzdHN0cmluZ" + "\r\n" + " " + "w=="; 22 | BcCryptoProvider sut = new BcCryptoProvider(); 23 | String out = new String(sut.base64Decode(data)); 24 | assertEquals("teststring", out); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/transport/security/CertTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.transport.security; 2 | 3 | import static org.junit.Assert.assertArrayEquals; 4 | 5 | import org.junit.BeforeClass; 6 | import org.junit.Test; 7 | import org.opcfoundation.ua.utils.CertificateUtils; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.spongycastle.util.Arrays; 11 | 12 | public class CertTest { 13 | 14 | private static final Logger logger = LoggerFactory 15 | .getLogger(CertTest.class); 16 | 17 | private static Cert cert; 18 | private static Cert cert2; 19 | 20 | @BeforeClass 21 | public static void generateCertificates() throws Exception { 22 | logger.info("Generating in-memory test certificates..."); 23 | String applicationUri = "urn:localhost:OPCUA:testapplication"; 24 | String hostNames = "localhost"; 25 | String commonName = "commonname"; 26 | String organisation = "test organization"; 27 | int validityTime = 356; // days 28 | 29 | // test cert 1 30 | KeyPair kp = CertificateUtils.createApplicationInstanceCertificate( 31 | commonName, organisation, applicationUri, validityTime, 32 | hostNames); 33 | cert = kp.getCertificate(); 34 | 35 | // test cert 2 36 | applicationUri = "urn:localhost:OPCUA:testapplication2"; 37 | KeyPair kp2 = CertificateUtils.createApplicationInstanceCertificate( 38 | commonName, organisation, applicationUri, validityTime, 39 | hostNames); 40 | cert2 = kp2.getCertificate(); 41 | 42 | } 43 | 44 | @Test 45 | public void thumbprintCalculationInCertChain() throws Exception { 46 | /* 47 | * GH#145 48 | * 49 | * Purpose of this test is to check that the thumprint of a cert is 50 | * calculated correctly when there are more than one cert in the encoded 51 | * form (see specification v.1.04 Part 6 section 6.2.3 52 | * "Certificate Chains" 53 | */ 54 | 55 | byte[] data1 = cert.getEncoded(); 56 | byte[] data2 = cert2.getEncoded(); 57 | 58 | // Sidenote, the 2 certs are not a chain, but this works for the purpose of this test 59 | byte[] dataCombined = Arrays.concatenate(data1, data2); 60 | 61 | // if calculation is done correctly, the thumbprint of the combined 62 | // should be the one of the first, i.e. data1 63 | Cert combined = new Cert(dataCombined); 64 | assertArrayEquals(cert.getEncodedThumbprint(), combined.getEncodedThumbprint()); 65 | 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/transport/security/SecurityModeTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.transport.security; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.util.Collection; 6 | import java.util.EnumSet; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | import org.junit.Test; 11 | import org.opcfoundation.ua.core.MessageSecurityMode; 12 | 13 | public class SecurityModeTest { 14 | 15 | @Test 16 | public void combinationsEmptyAndNull() throws Exception { 17 | assertTrue(SecurityMode.combinations(null, null).isEmpty()); 18 | assertTrue(SecurityMode.combinations(EnumSet.of(MessageSecurityMode.None), null).isEmpty()); 19 | assertTrue(SecurityMode.combinations(null, EnumSet.of(SecurityPolicy.NONE)).isEmpty()); 20 | assertTrue(SecurityMode.combinations(new HashSet(), new HashSet()).isEmpty()); 21 | } 22 | 23 | @Test 24 | public void combinationsNonePairsOnlyWithNone() throws Exception { 25 | assertExactContentsEquals(SecurityMode.NONE, SecurityMode.combinations(EnumSet.of(MessageSecurityMode.None, MessageSecurityMode.Sign), EnumSet.of(SecurityPolicy.NONE))); 26 | assertExactContentsEquals(SecurityMode.NONE, SecurityMode.combinations(EnumSet.of(MessageSecurityMode.None), EnumSet.allOf(SecurityPolicy.class))); 27 | } 28 | 29 | @Test 30 | public void combinations() throws Exception { 31 | Set expected = new HashSet(); 32 | expected.add(SecurityMode.NONE); 33 | expected.add(SecurityMode.BASIC128RSA15_SIGN); 34 | expected.add(SecurityMode.BASIC128RSA15_SIGN_ENCRYPT); 35 | expected.add(SecurityMode.BASIC256_SIGN); 36 | expected.add(SecurityMode.BASIC256_SIGN_ENCRYPT); 37 | 38 | Set actual = SecurityMode.combinations(EnumSet.of(MessageSecurityMode.None, MessageSecurityMode.Sign, MessageSecurityMode.SignAndEncrypt), 39 | EnumSet.of(SecurityPolicy.NONE, SecurityPolicy.BASIC128RSA15, SecurityPolicy.BASIC256)); 40 | System.out.println(actual); 41 | assertExactContentsEquals(expected, actual); 42 | } 43 | 44 | private void assertExactContentsEquals(T element, 45 | Collection collectionThatShouldContainOnlyElement) { 46 | assertEquals(1, collectionThatShouldContainOnlyElement.size()); 47 | assertTrue(collectionThatShouldContainOnlyElement.contains(element)); 48 | } 49 | 50 | private void assertExactContentsEquals(Collection elements, 51 | Collection collectionThatShouldContainOnlyElements) { 52 | //Note that this could be done nicer, but will work for now.. 53 | assertEquals(elements.size(), collectionThatShouldContainOnlyElements.size()); 54 | for(T element : elements) { 55 | assertTrue(collectionThatShouldContainOnlyElements.contains(element)); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/transport/tcp/io/TcpConnectionTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.transport.tcp.io; 2 | 3 | import org.junit.Rule; 4 | import org.junit.Test; 5 | import org.junit.rules.Timeout; 6 | import org.opcfoundation.ua.common.ServiceResultException; 7 | import org.opcfoundation.ua.core.EndpointConfiguration; 8 | import org.opcfoundation.ua.core.EndpointDescription; 9 | import org.opcfoundation.ua.core.MessageSecurityMode; 10 | import org.opcfoundation.ua.encoding.EncoderContext; 11 | import org.opcfoundation.ua.transport.ReverseTransportChannelSettings; 12 | import org.opcfoundation.ua.transport.security.SecurityPolicy; 13 | import org.opcfoundation.ua.utils.EndpointUtil; 14 | 15 | public class TcpConnectionTest { 16 | 17 | /** 18 | * Timeout for all tests in this class. 19 | */ 20 | @Rule 21 | public Timeout timeout = Timeout.seconds(10); 22 | 23 | 24 | @Test(expected=ServiceResultException.class) 25 | public void reverseHelloTimeout() throws Exception { 26 | TcpConnection sut = new TcpConnection(); 27 | 28 | String url = "opc.tcp://"+EndpointUtil.getHostname()+":8888"; 29 | ReverseTransportChannelSettings settings = new ReverseTransportChannelSettings(); 30 | settings.setReverseHelloServerUri("urn:unknownserver:test"); 31 | settings.setConfiguration(EndpointConfiguration.defaults()); 32 | settings.getOpctcpSettings().setReverseHelloAcceptTimeout(2000); 33 | EndpointDescription serverEndpoint = new EndpointDescription(); 34 | serverEndpoint.setSecurityMode(MessageSecurityMode.None); 35 | serverEndpoint.setSecurityPolicyUri(SecurityPolicy.NONE.getPolicyUri()); 36 | serverEndpoint.setEndpointUrl("opc.tcp://"+EndpointUtil.getHostname()+":8999"); 37 | settings.setDescription(serverEndpoint); 38 | EncoderContext ctx = EncoderContext.getDefaultInstance(); 39 | sut.initialize(url, settings, ctx); 40 | 41 | //Should timeout in 2 seconds 42 | sut.open(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/unittests/TestUnsignedLong.java: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Copyright (c) 2005-2015 The OPC Foundation, Inc. All rights reserved. 3 | * 4 | * OPC Foundation MIT License 1.00 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following 13 | * conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be 16 | * included in all copies or substantial portions of the Software. 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | * OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * The complete license agreement can be found here: 27 | * http://opcfoundation.org/License/MIT/1.00/ 28 | * ======================================================================*/ 29 | 30 | package org.opcfoundation.ua.unittests; 31 | import java.math.BigInteger; 32 | 33 | import org.opcfoundation.ua.builtintypes.UnsignedLong; 34 | 35 | import junit.framework.TestCase; 36 | 37 | 38 | public class TestUnsignedLong extends TestCase { 39 | 40 | public void testBigInteger() { 41 | BigInteger bi = BigInteger.valueOf(Long.MAX_VALUE); 42 | UnsignedLong v1 = UnsignedLong.valueOf(Long.MAX_VALUE); 43 | UnsignedLong v2 = new UnsignedLong(bi); 44 | assertEquals(v1, v2); 45 | 46 | BigInteger bi2 = bi.add(BigInteger.valueOf(1)); 47 | v1 = v1.add(1); 48 | v2 = new UnsignedLong(bi2); 49 | assertEquals(v1, v2); 50 | 51 | v1 = v1.subtract(1); 52 | v2 = new UnsignedLong(bi); 53 | assertEquals(v1, v2); 54 | 55 | v1 = UnsignedLong.MAX_VALUE.subtract(1); 56 | v2 = new UnsignedLong(Long.MAX_VALUE).add(Long.MAX_VALUE); 57 | assertEquals(v1, v2); 58 | 59 | v1 = UnsignedLong.MAX_VALUE.subtract(Long.MAX_VALUE); 60 | v2 = new UnsignedLong(Long.MAX_VALUE).add(1); 61 | assertEquals(v1, v2); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/opcfoundation/ua/utils/StringUtilsTest.java: -------------------------------------------------------------------------------- 1 | package org.opcfoundation.ua.utils; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | public class StringUtilsTest { 8 | 9 | @Test 10 | public void removeWhitespace() throws Exception { 11 | assertEquals("aa", StringUtils.removeWhitespace("\t\r\n aa")); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/ClientCert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/src/test/resources/org/opcfoundation/ua/unittests/ClientCert.der -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/ClientCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/src/test/resources/org/opcfoundation/ua/unittests/ClientCert.pfx -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/SampleXmlData1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Original Chocolate Chip Cookies 4 | 5 | Mike Mueller 6 | 7 | 8 | snacks 9 | cookies 10 | chocolate 11 | 12 | 13 | Easy 14 | 10 minutes 15 | 11 minutes 16 | 5 dozen cookies or about 4 dozen bars 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Mom recommends increasing the cooking time to 20 minutes or until the cookies resemble igneous rocks. 28 | 29 | butter 30 | brown sugar 31 | granulated sugar 32 | vanilla 33 | all-purpose flour 34 | baking soda 35 | salt 36 | eggs 37 | chopped nuts 38 | Semi-Sweet Chocolate Morsels 39 | 40 | 41 | Preheat oven to 375 degrees. 42 | Combine flour, baking soda and salt in a small bowl. 43 | Beat butter, granulated sugar, brown sugar, and vanilla extract in a large mixing bowl. 44 | Add eggs one at a time, beating well after each addition. 45 | Gradually beat in the flour mixture. 46 | Stir in morsels and nuts. 47 | Drop by rounded tablespoon onto ungreased baking sheets. 48 | Bake for 9 to 11 minutes or until golden brown. 49 | Let stand for two minutes; remove to wire racks to cool completely. 50 | 51 | 5 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/SampleXmlData2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Original Chocolate Chip Cookies 5 | 6 | 7 | Mike Mueller 8 | 9 | 10 | 11 | cookies 12 | snacks 13 | chocolate 14 | 15 | 16 | 17 | Easy 18 | 10 minutes 19 | 11 minutes 20 | 5 dozen cookies or about 4 dozen bars 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Mom recommends increasing the cooking time to 20 minutes or until the cookies resemble igneous rocks. 34 | 35 | 36 | butter 37 | brown sugar 38 | granulated sugar 39 | vanilla 40 | all-purpose flour 41 | baking soda 42 | salt 43 | eggs 44 | chopped nuts 45 | Semi-Sweet Chocolate Morsels 46 | 47 | 48 | 49 | Preheat oven to 375 degrees. 50 | Combine flour, baking soda and salt in a small bowl. 51 | Beat butter, granulated sugar, brown sugar, and vanilla extract in a large mixing bowl. 52 | Add eggs one at a time, beating well after each addition. 53 | Gradually beat in the flour mixture. 54 | Stir in morsels and nuts. 55 | Drop by rounded tablespoon onto ungreased baking sheets. 56 | Bake for 9 to 11 minutes or until golden brown. 57 | Let stand for two minutes; remove to wire racks to cool completely. 58 | 59 | 60 | 5 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/SampleXmlData3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Different Title 5 | 6 | 7 | 8 | Alokas N N 9 | 10 | 11 | 12 | chocolate 13 | 14 | 15 | Easy 16 | 10 minutes 17 | 11 minutes 18 | 5 dozen cookies or about 4 dozen bars 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Mom recommends increasing the cooking time to 20 minutes or until the cookies resemble igneous rocks. 30 | -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/SampleXmlData4.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | Original Chocolate Chip Cookies 4 | 5 | Mike Mueller 6 | 7 | 8 | snacks 9 | cookies 10 | chocolate 11 | 12 | 13 | Easy 14 | 10 minutes 15 | 11 minutes 16 | 5 dozen cookies or about 4 dozen bars 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Mom recommends increasing the cooking time to 20 minutes or until the cookies resemble igneous rocks. 28 | 29 | butter 30 | brown sugar 31 | granulated sugar 32 | vanilla 33 | all-purpose flour 34 | baking soda 35 | salt 36 | eggs 37 | chopped nuts 38 | Semi-Sweet Chocolate Morsels 39 | 40 | 41 | Preheat oven to 375 degrees. 42 | Combine flour, baking soda and salt in a small bowl. 43 | Beat butter, granulated sugar, brown sugar, and vanilla extract in a large mixing bowl. 44 | Add eggs one at a time, beating well after each addition. 45 | Gradually beat in the flour mixture. 46 | Stir in morsels and nuts. 47 | Drop by rounded tablespoon onto ungreased baking sheets. 48 | Bake for 9 to 11 minutes or until golden brown. 49 | Let stand for two minutes; remove to wire racks to cool completely. 50 | 51 | 5 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/ServerCert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/src/test/resources/org/opcfoundation/ua/unittests/ServerCert.der -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/UAServerCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/src/test/resources/org/opcfoundation/ua/unittests/UAServerCert.pfx -------------------------------------------------------------------------------- /src/test/resources/org/opcfoundation/ua/unittests/keystore.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OPCFoundation/UA-Java-Legacy/d5d4a2c6b7ef578582f37a59d48ccb1ecc2217a8/src/test/resources/org/opcfoundation/ua/unittests/keystore.p12 --------------------------------------------------------------------------------