src/java.security.jgss/share/classes/sun/security/krb5/internal/ktab/KeyTabEntry.java
changeset 59024 b046ba510bbc
parent 47216 71c04702a3d5
equal deleted inserted replaced
59023:f0dca628176c 59024:b046ba510bbc
     1 /*
     1 /*
       
     2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  *
     4  *
     4  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     5  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    30 
    31 
    31 package sun.security.krb5.internal.ktab;
    32 package sun.security.krb5.internal.ktab;
    32 
    33 
    33 import sun.security.krb5.*;
    34 import sun.security.krb5.*;
    34 import sun.security.krb5.internal.*;
    35 import sun.security.krb5.internal.*;
    35 import java.io.UnsupportedEncodingException;
    36 
       
    37 import static java.nio.charset.StandardCharsets.ISO_8859_1;
    36 
    38 
    37 /**
    39 /**
    38  * This class represents a Key Table entry. Each entry contains the service principal of
    40  * This class represents a Key Table entry. Each entry contains the service principal of
    39  * the key, time stamp, key version and secret key itself.
    41  * the key, time stamp, key version and secret key itself.
    40  *
    42  *
    81     }
    83     }
    82     public int entryLength() {
    84     public int entryLength() {
    83         int totalPrincipalLength = 0;
    85         int totalPrincipalLength = 0;
    84         String[] names = service.getNameStrings();
    86         String[] names = service.getNameStrings();
    85         for (int i = 0; i < names.length; i++) {
    87         for (int i = 0; i < names.length; i++) {
    86             try {
    88             totalPrincipalLength += principalSize + names[i].getBytes(ISO_8859_1).length;
    87                 totalPrincipalLength += principalSize + names[i].getBytes("8859_1").length;
       
    88             } catch (UnsupportedEncodingException exc) {
       
    89             }
       
    90         }
    89         }
    91 
    90 
    92         int realmLen = 0;
    91         int realmLen = realm.toString().getBytes(ISO_8859_1).length;
    93         try {
       
    94             realmLen = realm.toString().getBytes("8859_1").length;
       
    95         } catch (UnsupportedEncodingException exc) {
       
    96         }
       
    97 
    92 
    98         int size = principalComponentSize +  realmSize + realmLen
    93         int size = principalComponentSize +  realmSize + realmLen
    99             + totalPrincipalLength + principalTypeSize
    94             + totalPrincipalLength + principalTypeSize
   100             + timestampSize + keyVersionSize
    95             + timestampSize + keyVersionSize
   101             + keyTypeSize + keySize + keyblock.length;
    96             + keyTypeSize + keySize + keyblock.length;