0

This is the errors lines i get it :

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "src" is null
    at java.base/java.util.Base64$Decoder.decode(Base64.java:589)
    at kerberos.client.Client.sendRequestToTGS(Client.java:219)
    at kerberos.client.Client.main(Client.java:96)`

`base64.java.589: public byte[] decode(String src) {
            return decode(src.getBytes(ISO_8859_1.INSTANCE));
Client.java:219 : byte[] encodedKey=Base64.getDecoder().decode(tgsSessionKey);

Client.java.96 : String messageToTGS = sendRequestToTGS(tgsSessionKey,tgt);

and this is the sendRequestToTGS:

private static String sendRequestToTGS(String tgsSessionKey, String tgt)
    throws IOException {
        // Generate the request message
                 
        byte[] encodedKey =  Base64.getDecoder().decode(tgsSessionKey);
                //System.out.println("hi bb : ");
        SecretKey originalKey = new SecretKeySpec(encodedKey, 0,
                encodedKey.length, "AES");

        StringBuffer authenticator = new StringBuffer("");
        Long startTime = System.currentTimeMillis();
        String timeStamp = Long.toString(startTime);
        String usrname = username;
        usrname = usrname.replace("\n", "").replace("\r", "");
        authenticator = authenticator.append(usrname).append(";")
                .append(timeStamp);
        System.out.println("Authenticator is : " + authenticator);

        // Encrypting Authenticator
        String encryptedAuthenticator = null;
        try {
            encryptedAuthenticator = e.encrypt(originalKey,
                    authenticator.toString());
            System.out.println("Encrypted Authenticator is: "
                    + encryptedAuthenticator);
        } catch (Exception e) {
            System.err
                    .println("Error occured during Authenticator Encryption: "
                            + e.getMessage());
            e.printStackTrace();
        }
        return encryptedAuthenticator + ";" + tgt;
    }
001
  • 13,291
  • 5
  • 35
  • 66

0 Answers0