Top Description Inners Fields Constructors Methods
org.eclipse.jgit.lfs.internal

public Class LfsConnectionFactory

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME, org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP, .HttpSupport.HDR_ACCEPT, .HttpSupport.HDR_ACCEPT_ENCODING, .HttpSupport.HDR_CONTENT_TYPE

Provides means to get a valid LFS connection for a given repository.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final int
private static final Map<String, LfsConnectionFactory.AuthCache>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String
discoverLfsUrl(Repository db, String purpose, Map<String, String> additionalHeaders, String remoteUrl)

private static String
public static HttpConnection

Returns:

the connection for the lfs server. e.g. "https://github.com/github/git-lfs.git/info/lfs"
getLfsConnection
(Repository
the repository to work with
db
,
String
the method (GET,PUT,...) of the request this connection will be used for
method
,
String
the action, e.g. Protocol.OPERATION_DOWNLOAD
purpose
)

Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url.

public static HttpConnection

Returns:

a connection. output mode is not set.
getLfsContentConnection
(Repository
the repo to fetch required configuration from
repo
,
Protocol.Action
the action for which to create a connection
action
,
String
the target method (GET or PUT)
method
)

Create a connection for the specified org.eclipse.jgit.lfs.Protocol.Action.

private static String

Returns:

the URL for the LFS server. e.g. "https://github.com/github/git-lfs.git/info/lfs"
getLfsUrl
(Repository
the repository to work with
db
,
String
the action, e.g. Protocol.OPERATION_DOWNLOAD
purpose
,
Map<String, String>
additional headers that can be used to connect to LFS server
additionalHeaders
)

Get LFS Server URL.

private static Protocol.ExpiringAction
getSshAuthentication(Repository db, String purpose, String remoteUrl, URIish u)

public static Protocol.Request

Returns:

a request that can be serialized to JSON
toRequest
(String
the operation to perform, e.g. Protocol.OPERATION_DOWNLOAD
operation
,
LfsPointer...
the LFS resources affected
resources
)

Create request that can be serialized to JSON

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SCHEME_HTTPSback to summary
private static final String SCHEME_HTTPS
SCHEME_SSHback to summary
private static final String SCHEME_SSH
SSH_AUTH_TIMEOUT_SECONDSback to summary
private static final int SSH_AUTH_TIMEOUT_SECONDS
sshAuthCacheback to summary
private static final Map<String, LfsConnectionFactory.AuthCache> sshAuthCache

Constructor Detail

LfsConnectionFactoryback to summary
public LfsConnectionFactory()

Method Detail

discoverLfsUrlback to summary
private static String discoverLfsUrl(Repository db, String purpose, Map<String, String> additionalHeaders, String remoteUrl) throws URISyntaxException, IOException, CommandFailedException
extractProjectNameback to summary
private static String extractProjectName(URIish u)
getLfsConnectionback to summary
public static HttpConnection getLfsConnection(Repository db, String method, String purpose) throws IOException

Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url. The LFS server URL is computed from remote.[remote].url by appending "/info/lfs". In case there is no URL configured, a SSH remote URI can be used to auto-detect the LFS URI by using the remote "git-lfs-authenticate" command.

Parameters
db:Repository

the repository to work with

method:String

the method (GET,PUT,...) of the request this connection will be used for

purpose:String

the action, e.g. Protocol.OPERATION_DOWNLOAD

Returns:HttpConnection

the connection for the lfs server. e.g. "https://github.com/github/git-lfs.git/info/lfs"

Exceptions
IOException:
if an IO error occurred
getLfsContentConnectionback to summary
public static HttpConnection getLfsContentConnection(Repository repo, Protocol.Action action, String method) throws IOException

Create a connection for the specified org.eclipse.jgit.lfs.Protocol.Action.

Parameters
repo:Repository

the repo to fetch required configuration from

action:Protocol.Action

the action for which to create a connection

method:String

the target method (GET or PUT)

Returns:HttpConnection

a connection. output mode is not set.

Annotations
@NonNull
Exceptions
IOException:
in case of any error.
getLfsUrlback to summary
private static String getLfsUrl(Repository db, String purpose, Map<String, String> additionalHeaders) throws IOException

Get LFS Server URL.

Parameters
db:Repository

the repository to work with

purpose:String

the action, e.g. Protocol.OPERATION_DOWNLOAD

additionalHeaders:Map<String, String>

additional headers that can be used to connect to LFS server

Returns:String

the URL for the LFS server. e.g. "https://github.com/github/git-lfs.git/info/lfs"

Exceptions
IOException:
if the LFS config is invalid or cannot be accessed
See Also
Server Discovery documentation
getSshAuthenticationback to summary
private static Protocol.ExpiringAction getSshAuthentication(Repository db, String purpose, String remoteUrl, URIish u) throws IOException, CommandFailedException
toRequestback to summary
public static Protocol.Request toRequest(String operation, LfsPointer... resources)

Create request that can be serialized to JSON

Parameters
operation:String

the operation to perform, e.g. Protocol.OPERATION_DOWNLOAD

resources:LfsPointer[]

the LFS resources affected

Returns:Protocol.Request

a request that can be serialized to JSON

org.eclipse.jgit.lfs.internal back to summary

private final Class LfsConnectionFactory.AuthCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long
pack-priv Protocol.ExpiringAction
private static final DateTimeFormatter
pack-priv long

Constructor Summary

AccessConstructor and Description
public
AuthCache(Protocol.ExpiringAction
action with an additional expiration timestamp
action
)

Creates a cache entry for an authentication response.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTH_CACHE_EAGER_TIMEOUTback to summary
private static final long AUTH_CACHE_EAGER_TIMEOUT
cachedActionback to summary
pack-priv Protocol.ExpiringAction cachedAction
ISO_FORMATback to summary
private static final DateTimeFormatter ISO_FORMAT
validUntilback to summary
pack-priv long validUntil

Constructor Detail

AuthCacheback to summary
public AuthCache(Protocol.ExpiringAction action)

Creates a cache entry for an authentication response.

The timeout of the cache token is extracted from the given action. If no timeout can be determined, the token will be used only once.

Parameters
action:Protocol.ExpiringAction

action with an additional expiration timestamp