Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.transport.sshd.agent.connector

public final Class PageantLibrary

extends Object
Class Inheritance
Imports
java.io.Closeable, .IOException, java.nio.charset.StandardCharsets, java.util.List, org.slf4j.Logger, .LoggerFactory, com.sun.jna.Memory, .Pointer, .Structure, com.sun.jna.platform.win32.WinBase, .WinDef.HWND, .WinDef.LPARAM, .WinDef.LRESULT, .WinNT, .WinNT.HANDLE, .WinUser

The PageantLibrary encapsulates the shared memory access and provides a simple pipe abstraction.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PageantLibrary.CopyStruct

Windows' COPYDATASTRUCT.

pack-priv static interface
PageantLibrary.Pipe

An abstraction for a bi-directional pipe.

private static class

Field Summary

Modifier and TypeField and Description
private static final Logger
private static final String
PAGEANT

Pageant's "class" and "window name".

private static final int
PAGEANT_ID

Magic constant from Pageant; ID for the CopyStruct used in SendMessage.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
close(LibraryHolder libs, WinNT.HANDLE file, Pointer memory, boolean silent)

pack-priv PageantLibrary.Pipe

Returns:

the Pipe, or null if none created
createPipe
(String
for the pipe
name
,
int
maximum size for messages
maxSize
)

Creates a new Pipe.

pack-priv boolean

Returns:

true if Pageant is running, false otherwise
isPageantAvailable
()

Determines whether Pageant is currently running.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
PAGEANTback to summary
private static final String PAGEANT

Pageant's "class" and "window name".

PAGEANT_IDback to summary
private static final int PAGEANT_ID

Magic constant from Pageant; ID for the CopyStruct used in SendMessage.

See Also
"random goop"

Constructor Detail

PageantLibraryback to summary
public PageantLibrary()

Method Detail

closeback to summary
private static void close(LibraryHolder libs, WinNT.HANDLE file, Pointer memory, boolean silent) throws IOException
createPipeback to summary
pack-priv PageantLibrary.Pipe createPipe(String name, int maxSize) throws IOException

Creates a new Pipe.

Parameters
name:String

for the pipe

maxSize:int

maximum size for messages

Returns:PageantLibrary.Pipe

the Pipe, or null if none created

Exceptions
IOException:
on errors
isPageantAvailableback to summary
pack-priv boolean isPageantAvailable()

Determines whether Pageant is currently running.

Returns:boolean

true if Pageant is running, false otherwise

org.eclipse.jgit.internal.transport.sshd.agent.connector back to summary

public Class PageantLibrary.CopyStruct

extends Structure
Class Inheritance

Windows' COPYDATASTRUCT. Must be public for JNA.

Field Summary

Modifier and TypeField and Description
public long
cbData

Data length; number of bytes in lpData.

public int
dwData

Must be set the PAGEANT_ID.

public Pointer
lpData

Points to cbData bytes.

Inherited from com.sun.jna.Structure:
ALIGN_DEFAULTALIGN_GNUCALIGN_MSVCALIGN_NONECALCULATE_SIZE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected List<String>
getFieldOrder()

Overrides com.sun.jna.Structure.getFieldOrder.

Returns this Structure's field names in their proper order.

Inherited from com.sun.jna.Structure:
allocateMemoryallocateMemoryautoAllocateautoReadautoReadautoWriteautoWritecacheTypeInfocalculateSizeclearcreateFieldsOrdercreateFieldsOrdercreateFieldsOrdercreateFieldsOrderdataEqualsdataEqualsensureAllocatedequalsfieldOffsetgetAutoReadgetAutoWritegetFieldListgetFieldsgetNativeAlignmentgetNativeSizegetNativeSizegetPointergetStringEncodinggetStructAlignmenthashCodenewInstancenewInstancereadreadFieldreadFieldsetAlignTypesetAutoReadsetAutoSynchsetAutoWritesetStringEncodingsizesortFieldstoArraytoArraytoStringtoStringuseMemoryuseMemorywritewriteFieldwriteFieldwriteField

Field Detail

cbDataback to summary
public long cbData

Data length; number of bytes in lpData.

dwDataback to summary
public int dwData

Must be set the PAGEANT_ID.

lpDataback to summary
public Pointer lpData

Points to cbData bytes.

Constructor Detail

CopyStructback to summary
public CopyStruct()

Method Detail

getFieldOrderback to summary
protected List<String> getFieldOrder()

Overrides com.sun.jna.Structure.getFieldOrder.

Doc from com.sun.jna.Structure.getFieldOrder.

Returns this Structure's field names in their proper order.
When defining a new Structure you shouldn't override this method, but use FieldOrder annotation to define your field order(this also works with inheritance)
If you want to do something non-standard you can override the method and define it as followed


protected List getFieldOrder() {
    return Arrays.asList(...);
}

Important Note

When deriving from an existing Structure subclass, ensure that you augment the list provided by the superclass, e.g.


protected List getFieldOrder() {
    List fields = new LinkedList(super.getFieldOrder());
    fields.addAll(Arrays.asList(...));
    return fields;
}
Field order must be explicitly indicated, since the field order as returned by Class#getFields() is not guaranteed to be predictable.
Returns:List<String>

ordered list of field names

Annotations
@Override
org.eclipse.jgit.internal.transport.sshd.agent.connector back to summary

pack-priv Interface PageantLibrary.Pipe

extends Closeable
Known Direct Implementers
org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.PipeImpl

An abstraction for a bi-directional pipe.

Method Summary

Modifier and TypeMethod and Description
public void
receive(byte[]
to read
data
)

Reads bytes from the pipe until data is full.

public void
send(byte[]
to send
message
)

Send the given message.

Inherited from java.io.Closeable:
close

Method Detail

receiveback to summary
public void receive(byte[] data) throws IOException

Reads bytes from the pipe until data is full.

Parameters
data:byte[]

to read

Exceptions
IOException:
on errors
sendback to summary
public void send(byte[] message) throws IOException

Send the given message.

Parameters
message:byte[]

to send

Exceptions
IOException:
on errors
org.eclipse.jgit.internal.transport.sshd.agent.connector back to summary

private Class PageantLibrary.PipeImpl

extends Object
implements Pipe
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.PipeImpl
All Implemented Interfaces
org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe, java.io.Closeable, java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
private final WinNT.HANDLE
private final LibraryHolder
private final Pointer
private final byte[]
private long
private final WinDef.HWND

Constructor Summary

AccessConstructor and Description
pack-priv
PipeImpl(LibraryHolder libs, WinDef.HWND window, String name, WinNT.HANDLE file, Pointer memory)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private Pointer
public void
receive(byte[]
to read
data
)

Implements org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.receive.

Reads bytes from the pipe until data is full.

public void
send(byte[]
to send
message
)

Implements org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.send.

Send the given message.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final WinNT.HANDLE file
libsback to summary
private final LibraryHolder libs
memoryback to summary
private final Pointer memory
nameback to summary
private final byte[] name
readPosback to summary
private long readPos
windowback to summary
private final WinDef.HWND window

Constructor Detail

PipeImplback to summary
pack-priv PipeImpl(LibraryHolder libs, WinDef.HWND window, String name, WinNT.HANDLE file, Pointer memory)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
initback to summary
private Pointer init(PageantLibrary.CopyStruct c)
receiveback to summary
public void receive(byte[] data) throws IOException

Implements org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.receive.

Doc from org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.receive.

Reads bytes from the pipe until data is full.

Parameters
data:byte[]

to read

Annotations
@Override
Exceptions
IOException:
on errors
sendback to summary
public void send(byte[] message) throws IOException

Implements org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.send.

Doc from org.eclipse.jgit.internal.transport.sshd.agent.connector.PageantLibrary.Pipe.send.

Send the given message.

Parameters
message:byte[]

to send

Annotations
@Override
Exceptions
IOException:
on errors