18:35, EEST
February 21, 2014
Hi there,
for validation purposes and also for providing the user with a drop down of all security modes to select from, I need to enumerate all possible securityModes, aka combinations of SecurityPolicies and MessageSecurityModes.
I tried 2 different approaches (code snippets are in Kotlin, but should be understandable by Java users as well):
val messageSecurityModes = MessageSecurityMode.values()
variant #1:
resulting in:
[http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#None,None]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss,SignAndEncrypt]
and variant 2#
resulting in
[http://opcfoundation.org/UA/SecurityPolicy#None,None]
[http://opcfoundation.org/UA/SecurityPolicy#None,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#None,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,None]
[http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256,None]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256,None]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep,None]
[http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep,SignAndEncrypt]
[http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss,None]
[http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss,Sign]
[http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss,SignAndEncrypt]
Obviously, not all results of the second variant make sense. Should the constructor
not throw an InvalidArgumentException (or similar) for any invalid combination of MessageSecurityMode and SecurityPolicy?
Thanks,
Hans-Uwe
9:52, EEST
Moderators
February 11, 2020
Hello,
As mentioned in the documentation of the SecurityMode(SecurityPolicy securityPolicy, MessageSecurityMode messageSecurityMode) constructor: “Note! it is recommended to use the existing constants or the combinations(Set modes, Set policies) methods using the constants of the given classes instead of calling this directly.”
It’s true that the method could verify that the entered combination makes sense, but in general using this method shouldn’t be necessary as combinations method provides a set of valid SecurityModes and the static constant SecurityModes can be used instead of constructing new ones.
Most Users Ever Online: 1919
Currently Online:
10 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6451
Newest Members:
jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettingerModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1