• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Waffle / waffle / 6364

01 Feb 2026 02:07AM UTC coverage: 46.217%. Remained the same
6364

push

github

web-flow
Merge pull request #3206 from Waffle/renovate/checkstyle.version

Update dependency com.puppycrawl.tools:checkstyle to v13.1.0

276 of 734 branches covered (37.6%)

Branch coverage included in aggregate %.

1019 of 2068 relevant lines covered (49.27%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.96
/Source/JNA/waffle-jna/src/main/java/waffle/util/SPNegoMessage.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2010-2026 The Waffle Project Contributors: https://github.com/Waffle/waffle/graphs/contributors
6
 */
7
package waffle.util;
8

9
/**
10
 * Rudimentary NTLM message utility.
11
 */
12
public final class SPNegoMessage {
13

14
    // Check for NegTokenInit. It has always a special oid ("spnegoOid"),
15
    // which makes it rather easy to detect.
16
    /** The Constant SPENGO_OID. */
17
    private static final byte[] SPENGO_OID = { 0x06, 0x06, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02 };
2✔
18

19
    // Check if this message is SPNEGO authentication token.
20
    // There are two token types, NegTokenInit and NegTokenArg.
21
    // For details and specification, see
22
    // https://msdn.microsoft.com/en-us/library/ms995330.aspx
23

24
    /**
25
     * Checks if is neg token init.
26
     *
27
     * @param message
28
     *            the message
29
     *
30
     * @return true, if is neg token init
31
     */
32
    public static boolean isNegTokenInit(final byte[] message) {
33

34
        // Message should always contains at least some kind of
35
        // id byte and length. If it is too short, it
36
        // cannot be a SPNEGO message.
37
        if (message == null || message.length < 2) {
2!
38
            return false;
×
39
        }
40

41
        // First byte should always be 0x60 (Application Constructed Object)
42
        if (message[0] != 0x60) {
2✔
43
            return false;
2✔
44
        }
45

46
        // Next byte(s) contain token length, figure out
47
        // how many bytes are used for length data
48
        int lenBytes = 1;
2✔
49
        if ((message[1] & 0x80) != 0) {
2!
50
            lenBytes = 1 + (message[1] & 0x7f);
×
51
        }
52

53
        if (message.length < SPNegoMessage.SPENGO_OID.length + 1 + lenBytes) {
2✔
54
            return false;
2✔
55
        }
56

57
        // Now check for SPNEGO OID, which should start just after length data.
58
        for (int i = 0; i < SPNegoMessage.SPENGO_OID.length; i++) {
2✔
59
            if (SPNegoMessage.SPENGO_OID[i] != message[i + 1 + lenBytes]) {
2!
60
                return false;
×
61
            }
62
        }
63

64
        return true;
2✔
65
    }
66

67
    // Check for NegTokenArg. It doesn't have oid similar to NegTokenInit.
68
    // Instead id has one-byte id (0xa1). Obviously this is not
69
    // a great way to detect the message, so we check encoded
70
    // message length against number of received message bytes.
71
    /**
72
     * Checks if is neg token arg.
73
     *
74
     * @param message
75
     *            the message
76
     *
77
     * @return true, if is neg token arg
78
     */
79
    public static boolean isNegTokenArg(final byte[] message) {
80

81
        // Message should always contains at least some kind of
82
        // id byte and length. If it is too short, it
83
        // cannot be a SPNEGO message.
84
        if (message == null || message.length < 2) {
2!
85
            return false;
×
86
        }
87

88
        // Check if this is NegTokenArg packet, it's id is 0xa1
89
        if ((message[0] & 0xff) != 0xa1) {
2✔
90
            return false;
2✔
91
        }
92

93
        int lenBytes;
94
        int len;
95

96
        // Get length of message for additional check.
97
        if ((message[1] & 0x80) == 0) {
2!
98
            len = message[1];
2✔
99
        } else {
100
            lenBytes = message[1] & 0x7f;
×
101
            len = 0;
×
102
            final int i = 2;
×
103
            while (lenBytes > 0) {
×
104
                len = len << 8;
×
105
                len |= message[i] & 0xff;
×
106
                --lenBytes;
×
107
            }
108
        }
109

110
        return len + 2 == message.length;
2✔
111
    }
112

113
    /**
114
     * Instantiates a new SP nego message.
115
     */
116
    private SPNegoMessage() {
117
        // Prevent Instantiation of object
118
    }
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc