src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java
branchJDK-8145252-TLS13-branch
changeset 56703 33a2451070d3
parent 56702 75527e40bdfd
child 56708 25178bb3e8f5
equal deleted inserted replaced
56702:75527e40bdfd 56703:33a2451070d3
    51             new CHPreSharedKeyConsumer();
    51             new CHPreSharedKeyConsumer();
    52     static final HandshakeAbsence chOnLoadAbsence =
    52     static final HandshakeAbsence chOnLoadAbsence =
    53             new CHPreSharedKeyAbsence();
    53             new CHPreSharedKeyAbsence();
    54     static final HandshakeConsumer chOnTradeConsumer =
    54     static final HandshakeConsumer chOnTradeConsumer =
    55             new CHPreSharedKeyUpdate();
    55             new CHPreSharedKeyUpdate();
       
    56     static final SSLStringize chStringize =
       
    57             new CHPreSharedKeyStringize();
    56 
    58 
    57     static final HandshakeProducer shNetworkProducer =
    59     static final HandshakeProducer shNetworkProducer =
    58             new SHPreSharedKeyProducer();
    60             new SHPreSharedKeyProducer();
    59     static final ExtensionConsumer shOnLoadConsumer =
    61     static final ExtensionConsumer shOnLoadConsumer =
    60             new SHPreSharedKeyConsumer();
    62             new SHPreSharedKeyConsumer();
    61     static final HandshakeAbsence shOnLoadAbsence =
    63     static final HandshakeAbsence shOnLoadAbsence =
    62             new SHPreSharedKeyAbsence();
    64             new SHPreSharedKeyAbsence();
       
    65     static final SSLStringize shStringize =
       
    66             new SHPreSharedKeyStringize();
    63 
    67 
    64     private static final class PskIdentity {
    68     private static final class PskIdentity {
    65         final byte[] identity;
    69         final byte[] identity;
    66         final int obfuscatedAge;
    70         final int obfuscatedAge;
    67 
    71 
   232             return result.toString();
   236             return result.toString();
   233         }
   237         }
   234     }
   238     }
   235 
   239 
   236     private static final
   240     private static final
       
   241             class CHPreSharedKeyStringize implements SSLStringize {
       
   242         @Override
       
   243         public String toString(ByteBuffer buffer) {
       
   244             try {
       
   245                 // As the HandshakeContext parameter of CHPreSharedKeySpec
       
   246                 // constructor is used for fatal alert only, we can use
       
   247                 // null HandshakeContext here as we don't care about exception.
       
   248                 //
       
   249                 // Please take care of this code if the CHPreSharedKeySpec
       
   250                 // constructor is updated in the future.
       
   251                 return (new CHPreSharedKeySpec(null, buffer)).toString();
       
   252             } catch (Exception ex) {
       
   253                 // For debug logging only, so please swallow exceptions.
       
   254                 return ex.getMessage();
       
   255             }
       
   256         }
       
   257     }
       
   258 
       
   259     private static final
   237             class SHPreSharedKeySpec implements SSLExtensionSpec {
   260             class SHPreSharedKeySpec implements SSLExtensionSpec {
   238         final int selectedIdentity;
   261         final int selectedIdentity;
   239 
   262 
   240         SHPreSharedKeySpec(int selectedIdentity) {
   263         SHPreSharedKeySpec(int selectedIdentity) {
   241             this.selectedIdentity = selectedIdentity;
   264             this.selectedIdentity = selectedIdentity;
   270             Object[] messageFields = {
   293             Object[] messageFields = {
   271                 Utilities.byte16HexString(selectedIdentity)
   294                 Utilities.byte16HexString(selectedIdentity)
   272             };
   295             };
   273 
   296 
   274             return messageFormat.format(messageFields);
   297             return messageFormat.format(messageFields);
       
   298         }
       
   299     }
       
   300 
       
   301     private static final
       
   302             class SHPreSharedKeyStringize implements SSLStringize {
       
   303         @Override
       
   304         public String toString(ByteBuffer buffer) {
       
   305             try {
       
   306                 // As the HandshakeContext parameter of SHPreSharedKeySpec
       
   307                 // constructor is used for fatal alert only, we can use
       
   308                 // null HandshakeContext here as we don't care about exception.
       
   309                 //
       
   310                 // Please take care of this code if the SHPreSharedKeySpec
       
   311                 // constructor is updated in the future.
       
   312                 return (new SHPreSharedKeySpec(null, buffer)).toString();
       
   313             } catch (Exception ex) {
       
   314                 // For debug logging only, so please swallow exceptions.
       
   315                 return ex.getMessage();
       
   316             }
   275         }
   317         }
   276     }
   318     }
   277 
   319 
   278     private static final
   320     private static final
   279             class CHPreSharedKeyConsumer implements ExtensionConsumer {
   321             class CHPreSharedKeyConsumer implements ExtensionConsumer {