Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User handle, doc reformatting, GUI MFA changes, DDM factor support #195

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,581 changes: 1,541 additions & 1,040 deletions src/main/java/com/ibm/as400/access/AS400.java

Large diffs are not rendered by default.

72 changes: 49 additions & 23 deletions src/main/java/com/ibm/as400/access/AS400GenAuthTknDS.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
// The AS400GenAuthTknDS class represents the data stream for the 'Generate authentication token' request.
class AS400GenAuthTknDS extends ClientAccessDataStream
{
AS400GenAuthTknDS(byte[] userIDbytes, byte[] authenticationBytes, int byteType, int profileTokenType, int profileTokenTimeout, int serverLevel)
AS400GenAuthTknDS(byte[] userIDbytes, byte[] authenticationBytes, int authScheme, int profileTokenType, int profileTokenTimeout, int serverLevel,
byte[] addAuthFactor)
{
super(new byte[45 + authenticationBytes.length + ((userIDbytes == null || byteType == 1|| byteType ==2)?0:16) + (serverLevel < 5 ? 0 : 7)]); //@AI8C
super(new byte[45 + authenticationBytes.length
+ ((userIDbytes == null || authScheme == 1|| authScheme ==2) ? 0:16)
+ (serverLevel < 5 ? 0 : 7)
+ ((serverLevel >= 18 && null != addAuthFactor && 0 < addAuthFactor.length) ? addAuthFactor.length + 10: 0)
]);

setLength(data_.length);
// setHeaderID(0x0000);
Expand All @@ -32,25 +37,24 @@ class AS400GenAuthTknDS extends ClientAccessDataStream
setReqRepID(0x7007);

// Type of authentication bytes.
//@AF6A Start
if (byteType == AS400.AUTHENTICATION_SCHEME_IDENTITY_TOKEN)
if (authScheme == AS400.AUTHENTICATION_SCHEME_IDENTITY_TOKEN)
data_[20] = (byte)0x06;
else
data_[20] = (byte)0x02;

if (byteType == AS400.AUTHENTICATION_SCHEME_GSS_TOKEN)
if (authScheme == AS400.AUTHENTICATION_SCHEME_GSS_TOKEN)
data_[20] = (byte)0x05;

if (byteType == AS400.AUTHENTICATION_SCHEME_PASSWORD) {
if (authenticationBytes.length == 8) {
if (authScheme == AS400.AUTHENTICATION_SCHEME_PASSWORD)
{
if (authenticationBytes.length == 8)
data_[20] = (byte)0x01;
} else if (authenticationBytes.length == 20) {
else if (authenticationBytes.length == 20)
data_[20] = (byte)0x03;
} else {
else
data_[20] = (byte)0x07;
}
}//@AF6A End
//data_[20] = (byteType == AS400.AUTHENTICATION_SCHEME_PASSWORD) ? (authenticationBytes.length == 8) ? (byte)0x01 : (byte)0x03 : (byteType == AS400.AUTHENTICATION_SCHEME_GSS_TOKEN) ? (byte)0x05 : (byteType == AS400.AUTHENTICATION_SCHEME_IDENTITY_TOKEN) ? (byte)0x06 : (byte)0x02; //@AF6D
}

// Return type, 0x01 = profile token.
data_[21] = 0x01;

Expand All @@ -59,7 +63,7 @@ class AS400GenAuthTknDS extends ClientAccessDataStream
set16bit(0x1116, 26);
data_[28] = (byte)(0xF0 | profileTokenType);

// Experation interval.
// Expiration interval.
set32bit(10, 29);
set16bit(0x1117, 33);
set32bit(profileTokenTimeout, 35);
Expand All @@ -68,40 +72,62 @@ class AS400GenAuthTknDS extends ClientAccessDataStream
// LL
set32bit(6 + authenticationBytes.length, 39);
// CP
if (byteType == 0)
{
if (authScheme == 0)
set16bit(0x1105, 43);
}
else
{
set16bit(0x1115, 43);
}

// Data.
System.arraycopy(authenticationBytes, 0, data_, 45, authenticationBytes.length);

int offset = 45 + authenticationBytes.length;

if (userIDbytes != null && byteType != 1 && byteType != 2) //@AI8C
if (userIDbytes != null && authScheme != 1 && authScheme != 2)
{
// Set user ID info.
// LL
set32bit(16, 45 + authenticationBytes.length);
set32bit(16, offset);
// CP
set16bit(0x1104, 49 + authenticationBytes.length);
set16bit(0x1104, offset + 4);
// EBCDIC user ID.
System.arraycopy(userIDbytes, 0, data_, 51 + authenticationBytes.length, 10);
System.arraycopy(userIDbytes, 0, data_, offset + 6, 10);

offset += 6 + 10;
}


if (serverLevel >= 5)
{
int offset = 45 + authenticationBytes.length + ((userIDbytes == null || byteType == 1|| byteType ==2) ? 0 : 16); //@AI8C
// Set return error messages.
// LL
set32bit(7, offset);
// CP
set16bit(0x1128, offset + 4);
// Data.
data_[offset + 6] = 0x01;

offset += 6 + 1;
}

if (serverLevel >= 18)
{
if (null != addAuthFactor && 0 < addAuthFactor.length)
{
// LL
set32bit(addAuthFactor.length + 4 + 2 + 4, offset);
// CP
set16bit(0x112F, offset + 4);
// CCSID
set32bit(1208, offset + 6);
// data
System.arraycopy(addAuthFactor, 0, data_, offset + 10, addAuthFactor.length);

offset += 10 + addAuthFactor.length;
}
}
}

@Override
void write(OutputStream out) throws IOException
{
if (Trace.traceOn_) Trace.log(Trace.DIAGNOSTIC, "Sending generate authentication token request...");
Expand Down
Loading