aaa4j / aaa4j-radius

Java library for building RADIUS clients and RADIUS servers
https://aaa4j.org
Apache License 2.0
27 stars 11 forks source link

the vendorspecificatrribues problem #21

Open wpp5632447 opened 3 months ago

wpp5632447 commented 3 months ago

Hello, can you solve the search and insertion of multiple private vendor attributes with the following data structure [typeid,vendorid] //typeid = 26, or24x.26 [vendortype,length,value] [vendortype,length,value] [vendortype,length,value] [vendortype,length,value] [vendortype,length,value] I spent a long time solving the parsing problem, but I couldn't solve the insertion problem of the above structure. If I try to solve it forcefully, it will turn the code into a pile of crap thinks

tsyd commented 3 months ago

Hello, the library doesn't currently have a good way to compact vendor-specific attributes into a single top-level attribute. For now, you could use RawAttribute like this when sending:

ByteBuffer byteBuffer = ByteBuffer.allocate(253);

byteBuffer.putInt(311); // Microsoft (26.311)
byteBuffer.put((byte) 7); // MPPE-Encryption-Policy (26.311.7)
byteBuffer.put((byte) (2 + 4)); // 2 + size of the value below (integer)
byteBuffer.putInt(1);
byteBuffer.put((byte) 21); // ARAP-PW-Change-Reason (26.311.21)
byteBuffer.put((byte) (2 + 4)); // 2 + size of the value below (integer)
byteBuffer.putInt(4);

byte[] rawAttributeData = new byte[byteBuffer.position()];
System.arraycopy(byteBuffer.array(), 0, rawAttributeData, 0, byteBuffer.position());

new RawAttribute(26, rawAttributeData);

A future version of the library will have a cleaner way of doing this using the built-in attribute dictionary support.

wpp5632447 commented 3 months ago

Thank you, great TSYD. Thank you for taking the time out of your busy schedule to answer my question, after a month of research (as I am not a real programmer). I downloaded the complete source code package and made modifications to the vendor attribute to parse and insert multiple VSAs. Multi vas explanation: i.e. (26.311. [7, x, x, x, x, x,...]) a structure like this, as shown in the following figure I modified the dictionary generation source code to parse multiple VSAs Modified the VendorAttribute encode/decode method I copied VSA to VSAS and made modifications. If possible, I hope you can add this feature to serve the multi VSA that some manufacturers like to use now, If you need my code, I will provide it for free. It's just that I wrote it poorly, but I can still implement this feature. 1724374930160