Skip to content
Permalink
Browse files

[misc] correcting JNA default version and according documentation

(cherry picked from commit 42ce66a)
  • Loading branch information...
rusher committed Feb 5, 2019
1 parent e1e90ec commit 6615d6a6b3a136d2db0abf5f32b8f4c913f7d30c
@@ -56,7 +56,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.sql.SQLException;
@@ -108,7 +107,7 @@ public void authenticate(final PacketOutputStream out, final PacketInputStream i
}
jaasConfFile.deleteOnExit();
} catch (final IOException ex) {
throw new UncheckedIOException(ex);
throw ex;
}

System.setProperty("java.security.auth.login.config", jaasConfFile.getCanonicalPath());
@@ -120,42 +119,45 @@ public void authenticate(final PacketOutputStream out, final PacketInputStream i
final Subject mySubject = loginContext.getSubject();
if (!mySubject.getPrincipals().isEmpty()) {
try {
PrivilegedExceptionAction<Void> action = () -> {
try {
Oid krb5Mechanism = new Oid("1.2.840.113554.1.2.2");
PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try {
Oid krb5Mechanism = new Oid("1.2.840.113554.1.2.2");

GSSManager manager = GSSManager.getInstance();
GSSName peerName = manager.createName(servicePrincipalName, GSSName.NT_USER_NAME);
GSSContext context =
manager.createContext(peerName,
krb5Mechanism,
null,
GSSContext.DEFAULT_LIFETIME);
context.requestMutualAuth(true);
GSSManager manager = GSSManager.getInstance();
GSSName peerName = manager.createName(servicePrincipalName, GSSName.NT_USER_NAME);
GSSContext context =
manager.createContext(peerName,
krb5Mechanism,
null,
GSSContext.DEFAULT_LIFETIME);
context.requestMutualAuth(true);

byte[] inToken = new byte[0];
byte[] outToken;
while (!context.isEstablished()) {
byte[] inToken = new byte[0];
byte[] outToken;
while (!context.isEstablished()) {

outToken = context.initSecContext(inToken, 0, inToken.length);
outToken = context.initSecContext(inToken, 0, inToken.length);

// Send a token to the peer if one was generated by acceptSecContext
if (outToken != null) {
out.startPacket(sequence.incrementAndGet());
out.write(outToken);
out.flush();
// Send a token to the peer if one was generated by acceptSecContext
if (outToken != null) {
out.startPacket(sequence.incrementAndGet());
out.write(outToken);
out.flush();
}
if (!context.isEstablished()) {
Buffer buffer = in.getPacket(true);
sequence.set(in.getLastPacketSeq());
inToken = buffer.readRawBytes(buffer.remaining());
}
}
if (!context.isEstablished()) {
Buffer buffer = in.getPacket(true);
sequence.set(in.getLastPacketSeq());
inToken = buffer.readRawBytes(buffer.remaining());
}
}

} catch (GSSException le) {
throw new SQLException("GSS-API authentication exception", "28000", 1045, le);
} catch (GSSException le) {
throw new SQLException("GSS-API authentication exception", "28000", 1045, le);
}
return null;
}
return null;
};
Subject.doAs(mySubject, action);
} catch (PrivilegedActionException exception) {
@@ -323,7 +323,7 @@ boolean ConvertStringSecurityDescriptorToSecurityDescriptor(String sddl, int sdd
public Pointer lpSecurityDescriptor;
public boolean bInheritHandle;

protected java.util.List getFieldOrder() {
protected java.util.List<String> getFieldOrder() {
return Arrays.asList("nLength", "lpSecurityDescriptor", "bInheritHandle");
}
}
@@ -205,7 +205,7 @@ public SockAddr(String sunPath) {
allocateMemory();
}

protected java.util.List getFieldOrder() {
protected java.util.List<String> getFieldOrder() {
return Arrays.asList("sun_family", "sun_path");
}

@@ -52,11 +52,11 @@

package org.mariadb.jdbc.internal.protocol.authentication;

import java.sql.SQLException;

import org.mariadb.jdbc.internal.com.send.authentication.AuthenticationPlugin;
import org.mariadb.jdbc.internal.util.Options;

import java.sql.SQLException;


/**
* Provider to handle plugin authentication. This can allow library users to override our default
@@ -67,7 +67,16 @@
/**
* The default provider will construct a new pool on every request.
*/
public static final AuthenticationProvider DEFAULT_PROVIDER = DefaultAuthenticationProvider::processAuthPlugin;
public static final AuthenticationProvider DEFAULT_PROVIDER = new AuthenticationProvider() {
@Override
public AuthenticationPlugin processAuthPlugin(String plugin,
String password,
byte[] authData,
Options options)
throws SQLException {
return DefaultAuthenticationProvider.processAuthPlugin(plugin, password, authData, options);
}
};

private static volatile AuthenticationProvider currentProvider = null;

0 comments on commit 6615d6a

Please sign in to comment.
You can’t perform that action at this time.