Skip to content

Commit

Permalink
UpdateForProfileHandles (#219)
Browse files Browse the repository at this point in the history
Signed-off-by: John Eberhard <[email protected]>
  • Loading branch information
jeber-ibm authored Nov 4, 2024
1 parent eb17c1c commit f52014e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
31 changes: 31 additions & 0 deletions src/main/java/com/ibm/as400/access/AS400ImplNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,37 @@ class AS400ImplNative
}

static native byte[] signonNative(byte[] userId) throws NativeException;
/* Swap to a user profile using the userid and password */
/* The swapToPH is the profile handle generated from the userid and passowrd */
/* The swapFromPH is the profile handle to get back to the original profile handle */
static native void swapToNative(byte[] userId, byte[] bytes, byte[] swapToPH, byte[] swapFromPH) throws NativeException;
/* Swap using a profile handle and free the old handle */
/* swapToPH is the old profile handle that will be released. This handle will also be released. */
/* swapFromPH is the profile to swap to */
static native void swapBackNative(byte[] swapToPH, byte[] swapFromPH) throws NativeException;


/* New method to create a profile handle. This method is only available after IBM 7.5.
* The create profile handle should be used with SwapToProfileHandleNative to do the
* swap.
* This profile handle should be released when the AS400 object is closed */
static native void createProfileHandleNative(byte[] profileHandle, String userId, char[] password, char[] additionalAuthenticationFactor) throws NativeException;

/* Swap to the user associated with swapToPH. The swapFromPH is the handle for the original user, */
/* which is used with swapping back using swapBackAndReleaseNative */
static native void swapToProfileHandleNative(byte[] swapToPH, byte[] swapFromPH) throws NativeException;

/* Swap back to the original profile handle and free it */
static native void swapBackAndReleaseNative(byte[] swapFromPH) throws NativeException;

/* Create profile handle with additional authentication information.
* This method is only available after IBM 7.5.
* This profile handle should be released when the AS400 object is done with it. */
public static native void createProfileHandle2Native(byte[] profileHandle,
String userId, char[] password, char[] additionalAuthenticationFactor,
String verificationId, String remoteIpAddress, int jRemotePort, String localIpAddress, int jLocalPort ) throws NativeException;




}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class EnhancedProfileTokenImplNative
* @exception RetrieveFailedException If errors occur while generating the
* token.
*/
public static native byte[] nativeCreateToken(
static native byte[] nativeCreateToken(
String user,
char[] password,
char[] additionalAuthenticationFactor,
Expand Down Expand Up @@ -195,7 +195,7 @@ public static native byte[] nativeCreateToken(
* @exception RetrieveFailedException If errors occur while generating the
* token.
*/
public static native byte[] nativeCreateTokenSpecialPassword(
static native byte[] nativeCreateTokenSpecialPassword(
String user,
char[] password,
char[] additionalAuthenticationFactor,
Expand Down Expand Up @@ -225,7 +225,7 @@ public static native byte[] nativeCreateTokenSpecialPassword(
*
* @throws SwapFailedException If errors occur while swapping thread identity.
*/
public static native void nativeSwap(
static native void nativeSwap(
byte[] token,
String verificationId,
String remoteIpAddress) throws SwapFailedException;
Expand Down Expand Up @@ -262,7 +262,7 @@ public static native void nativeSwap(
* @exception RetrieveFailedException If errors occur while generating the
* token.
*/
public static native byte[] nativeCreateTokenFromToken(
static native byte[] nativeCreateTokenFromToken(
byte[] token,
String verificationId,
String remoteIpAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ native byte[] nativeCreateToken(
// @exception RetrieveFailedException If errors occur while generating
// the token.

// TODO: Write native code in /osxpf/v7r5m0.xpf/cur/cmvc/base.pgm/yjsp.xpf
native byte[] nativeCreateTokenChar(
String user,
char[] password,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ibm/as400/access/Trace.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ private static void logSource(Object source, StringBuffer buffer) { //
}
buffer.append(simpleName);
buffer.append('@');
buffer.append(source.hashCode());
buffer.append(System.identityHashCode(source));
buffer.append("] ");
}

Expand All @@ -705,7 +705,7 @@ private static void logSource(Object source, PrintWriter writer) { //
}
writer.print(simpleName);
writer.print('@');
writer.print(source.hashCode());
writer.print(System.identityHashCode(source));
writer.print("] ");
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/ibm/as400/access/jdbcClient/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,7 @@ private Object callMethod(String left, PrintStream printStreamForCallMethod) {
try {
boolean methodFound = false;
StringBuffer possibleErrors = new StringBuffer();
int exceptionCount = 0;

Object variable = null;
int paramIndex = left.indexOf("(");
Expand Down Expand Up @@ -3047,11 +3048,11 @@ private Object callMethod(String left, PrintStream printStreamForCallMethod) {
try {
methods[m].setAccessible(true);
variable = methods[m].invoke(callObject, parameters);
} catch (Exception e) {
} catch (Throwable e) {
if (e instanceof java.lang.reflect.InvocationTargetException) {
Throwable nextException = e.getCause();
if (nextException != null && (nextException instanceof Exception )) {
e = (Exception ) nextException;
if (nextException != null ) {
e = nextException;
}
}
if (e instanceof XAException) {
Expand All @@ -3060,7 +3061,9 @@ private Object callMethod(String left, PrintStream printStreamForCallMethod) {
possibleErrors.append("Exception "+e+"\n");
if (printStackTrace_) printStackTraceToStringBuffer(e, possibleErrors);
possibleErrors.append("Calling method " + methodName
+ " with " + methodParameters + " failed\n");
+ " with " + methodParameters + " failed exception in Exeception"+exceptionCount+"\n");
addVariable("Exception"+exceptionCount, e);
exceptionCount++;
methodFound = false;
}
} else {
Expand Down

0 comments on commit f52014e

Please sign in to comment.