src/java.base/share/classes/sun/security/ssl/ServerNameExtension.java

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 250 
 251     @Override
 252     void send(HandshakeOutStream s) throws IOException {
 253         s.putInt16(type.id);
 254         if (listLength == 0) {
 255             s.putInt16(listLength);     // in ServerHello, empty extension_data
 256         } else {
 257             s.putInt16(listLength + 2); // length of extension_data
 258             s.putInt16(listLength);     // length of ServerNameList
 259 
 260             for (SNIServerName sniName : sniMap.values()) {
 261                 s.putInt8(sniName.getType());         // server name type
 262                 s.putBytes16(sniName.getEncoded());   // server name value
 263             }
 264         }
 265     }
 266 
 267     @Override
 268     public String toString() {
 269         StringBuilder sb = new StringBuilder();

 270         for (SNIServerName sniName : sniMap.values()) {
 271             sb.append("[" + sniName + "]");
 272         }
 273 
 274         return "Extension " + type + ", server_name: " + sb;
 275     }
 276 
 277     private static class UnknownServerName extends SNIServerName {
 278         UnknownServerName(int code, byte[] encoded) {
 279             super(code, encoded);
 280         }
 281     }
 282 
 283 }


 250 
 251     @Override
 252     void send(HandshakeOutStream s) throws IOException {
 253         s.putInt16(type.id);
 254         if (listLength == 0) {
 255             s.putInt16(listLength);     // in ServerHello, empty extension_data
 256         } else {
 257             s.putInt16(listLength + 2); // length of extension_data
 258             s.putInt16(listLength);     // length of ServerNameList
 259 
 260             for (SNIServerName sniName : sniMap.values()) {
 261                 s.putInt8(sniName.getType());         // server name type
 262                 s.putBytes16(sniName.getEncoded());   // server name value
 263             }
 264         }
 265     }
 266 
 267     @Override
 268     public String toString() {
 269         StringBuilder sb = new StringBuilder();
 270         sb.append("Extension ").append(type).append(", server_name: ");
 271         for (SNIServerName sniName : sniMap.values()) {
 272             sb.append('[').append(sniName).append(']');
 273         }
 274         return sb.toString();

 275     }
 276 
 277     private static class UnknownServerName extends SNIServerName {
 278         UnknownServerName(int code, byte[] encoded) {
 279             super(code, encoded);
 280         }
 281     }
 282 
 283 }