Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CONJ-634] avoid import of non dependency to permit compilation Ahead…
… of time
- Loading branch information
Showing
8 changed files
with
174 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/org/mariadb/jdbc/internal/com/send/gssapi/GssUtility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.mariadb.jdbc.internal.com.send.gssapi; | ||
|
||
import com.sun.jna.Platform; | ||
import org.mariadb.jdbc.internal.io.input.PacketInputStream; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
public class GssUtility { | ||
|
||
/** | ||
* Get authentication method according to classpath. | ||
* Windows native authentication is using Waffle-jna. | ||
* | ||
* @return authentication method | ||
*/ | ||
public static BiFunction<PacketInputStream, Integer, GssapiAuth> getAuthenticationMethod() { | ||
try { | ||
//Waffle-jna has jna as dependency, so if not available on classpath, just use standard authentication | ||
if (Platform.isWindows()) { | ||
try { | ||
Class.forName("waffle.windows.auth.impl.WindowsAuthProviderImpl"); | ||
return (reader, packSeq) -> new WindowsNativeSspiAuthentication(reader, packSeq); | ||
} catch (ClassNotFoundException cle) { | ||
//waffle not in the classpath | ||
} | ||
} | ||
} catch (Throwable cle) { | ||
//jna jar's are not in classpath | ||
} | ||
return (reader, packSeq) -> new StandardGssapiAuthentication(reader, packSeq); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/mariadb/jdbc/internal/io/socket/SocketHandlerFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.mariadb.jdbc.internal.io.socket; | ||
|
||
import org.mariadb.jdbc.UrlParser; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
|
||
@FunctionalInterface | ||
public interface SocketHandlerFunction { | ||
Socket apply(UrlParser a, String b) throws IOException; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/mariadb/jdbc/internal/io/socket/SocketUtility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.mariadb.jdbc.internal.io.socket; | ||
|
||
import com.sun.jna.Platform; | ||
import org.mariadb.jdbc.internal.util.Utils; | ||
|
||
import java.io.IOException; | ||
|
||
public class SocketUtility { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static SocketHandlerFunction getSocketHandler() { | ||
try { | ||
//forcing use of JNA to ensure AOT compilation | ||
Platform.getOSType(); | ||
|
||
return (urlParser, host) -> { | ||
if (urlParser.getOptions().pipe != null) { | ||
return new NamedPipeSocket(host, urlParser.getOptions().pipe); | ||
} else if (urlParser.getOptions().localSocket != null) { | ||
try { | ||
return new UnixDomainSocket(urlParser.getOptions().localSocket); | ||
} catch (RuntimeException re) { | ||
throw new IOException(re.getMessage(), re.getCause()); | ||
} | ||
} else if (urlParser.getOptions().sharedMemory != null) { | ||
try { | ||
return new SharedMemorySocket(urlParser.getOptions().sharedMemory); | ||
} catch (RuntimeException re) { | ||
throw new IOException(re.getMessage(), re.getCause()); | ||
} | ||
} else { | ||
return Utils.standardSocket(urlParser, host); | ||
} | ||
|
||
}; | ||
} catch (Throwable cle) { | ||
//jna jar's are not in classpath | ||
} | ||
return (urlParser, host) -> Utils.standardSocket(urlParser, host); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/org/mariadb/jdbc/internal/util/PidRequestInter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.mariadb.jdbc.internal.util; | ||
|
||
public interface PidRequestInter { | ||
String getPid(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters