• 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

78.57
/Source/JNA/waffle-jna/src/main/java/waffle/windows/auth/impl/WindowsCredentialsHandleImpl.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.windows.auth.impl;
8

9
import com.sun.jna.platform.win32.Secur32;
10
import com.sun.jna.platform.win32.Sspi;
11
import com.sun.jna.platform.win32.Sspi.CredHandle;
12
import com.sun.jna.platform.win32.Sspi.TimeStamp;
13
import com.sun.jna.platform.win32.Win32Exception;
14
import com.sun.jna.platform.win32.WinError;
15

16
import waffle.windows.auth.IWindowsCredentialsHandle;
17

18
/**
19
 * Pre-existing credentials of a security principal. This is a handle to a previously authenticated logon data used by a
20
 * security principal to establish its own identity, such as a password, or a Kerberos protocol ticket.
21
 */
22
public class WindowsCredentialsHandleImpl implements IWindowsCredentialsHandle {
23

24
    /** The principal name. */
25
    private final String principalName;
26

27
    /** The credentials type. */
28
    private final int credentialsType;
29

30
    /** The security package. */
31
    private final String securityPackage;
32

33
    /** The handle. */
34
    private CredHandle handle;
35

36
    /**
37
     * A new Windows credentials handle.
38
     *
39
     * @param newPrincipalName
40
     *            Principal name.
41
     * @param newCredentialsType
42
     *            Credentials type.
43
     * @param newSecurityPackage
44
     *            Security package.
45
     */
46
    public WindowsCredentialsHandleImpl(final String newPrincipalName, final int newCredentialsType,
47
            final String newSecurityPackage) {
2✔
48
        this.principalName = newPrincipalName;
2✔
49
        this.credentialsType = newCredentialsType;
2✔
50
        this.securityPackage = newSecurityPackage;
2✔
51
    }
2✔
52

53
    /**
54
     * Returns the current credentials handle.
55
     *
56
     * @param securityPackage
57
     *            Security package, eg. "Negotiate".
58
     *
59
     * @return A windows credentials handle
60
     */
61
    public static IWindowsCredentialsHandle getCurrent(final String securityPackage) {
62
        final IWindowsCredentialsHandle handle = new WindowsCredentialsHandleImpl(null, Sspi.SECPKG_CRED_OUTBOUND,
2✔
63
                securityPackage);
64
        handle.initialize();
2✔
65
        return handle;
2✔
66
    }
67

68
    /**
69
     * Initialize a new credentials handle.
70
     */
71
    @Override
72
    public void initialize() {
73
        this.handle = new CredHandle();
2✔
74
        final TimeStamp clientLifetime = new TimeStamp();
2✔
75
        final int rc = Secur32.INSTANCE.AcquireCredentialsHandle(this.principalName, this.securityPackage,
2✔
76
                this.credentialsType, null, null, null, null, this.handle, clientLifetime);
77
        if (WinError.SEC_E_OK != rc) {
2!
78
            throw new Win32Exception(rc);
×
79
        }
80
    }
2✔
81

82
    /**
83
     * Dispose of the credentials handle.
84
     */
85
    @Override
86
    public void dispose() {
87
        if (this.handle != null && !this.handle.isNull()) {
2!
88
            final int rc = Secur32.INSTANCE.FreeCredentialsHandle(this.handle);
2✔
89
            if (WinError.SEC_E_OK != rc) {
2!
90
                throw new Win32Exception(rc);
×
91
            }
92
        }
93
    }
2✔
94

95
    /**
96
     * Get CredHandle.
97
     *
98
     * @return the handle
99
     */
100
    @Override
101
    public CredHandle getHandle() {
102
        return this.handle;
2✔
103
    }
104
}
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