AuditPolicyManager.java
/*
** Module : AuditPolicyManager.java
** Abstract : Provides AUDIT-POLICY attributes and methods support
**
** Copyright (c) 2019-2022, Golden Code Development Corporation.
**
**
** -#- -I- --Date-- ---------------------------------------Description----------------------------------------
** 001 IAS 20190506 Created initial version.
** 002 IAS 20190522 Added ENCRYPT-AUDIT-MAC-KEY implementation.
** 003 CA 20220426 Added AUDIT-ENABLED builtin function stubs.
** CA 20220610 Don't return null, instead return unknown values, otherwise the the client will abend if
** it calls these unimplemented APIs.
** 004 AS 20250130 Added missing implementation token support.
*/
/*
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You may find a copy of the GNU Affero GPL version 3 at the following
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
**
** Additional terms under GNU Affero GPL version 3 section 7:
**
** Under Section 7 of the GNU Affero GPL version 3, the following additional
** terms apply to the works covered under the License. These additional terms
** are non-permissive additional terms allowed under Section 7 of the GNU
** Affero GPL version 3 and may not be removed by you.
**
** 0. Attribution Requirement.
**
** You must preserve all legal notices or author attributions in the covered
** work or Appropriate Legal Notices displayed by works containing the covered
** work. You may not remove from the covered work any author or developer
** credit already included within the covered work.
**
** 1. No License To Use Trademarks.
**
** This license does not grant any license or rights to use the trademarks
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
** of Golden Code Development Corporation. You are not authorized to use the
** name Golden Code, FWD, or the names of any author or contributor, for
** publicity purposes without written authorization.
**
** 2. No Misrepresentation of Affiliation.
**
** You may not represent yourself as Golden Code Development Corporation or FWD.
**
** You may not represent yourself for publicity purposes as associated with
** Golden Code Development Corporation, FWD, or any author or contributor to
** the covered work, without written authorization.
**
** 3. No Misrepresentation of Source or Origin.
**
** You may not represent the covered work as solely your work. All modified
** versions of the covered work must be marked in a reasonable way to make it
** clear that the modified work is not originating from Golden Code Development
** Corporation or FWD. All modified versions must contain the notices of
** attribution required in this license.
*/
package com.goldencode.p2j.util;
import java.nio.charset.*;
import org.apache.commons.codec.binary.*;
import com.goldencode.proxy.*;
/**
* Provides static methods implementing support for the
* AUDIT-POLICY system handle attributes and methods
* See {@link CommonAuditPolicy}
*
*/
public class AuditPolicyManager
{
/** A token used for non repetitive logging of missing isAuditEnabled implementation.
* It is to be removed from the class attributes after the feature is implemented. */
private static volatile Object isAuditEnabledToken = null;
/**
* Get a the instance for the AUDIT-POLICY system handle. Is obtained using a call to the
* {@link StaticProxy#obtain(Class, Class[])}, using the {@link CommonAuditPolicy} interface
* and its methods implemented by these classes: {@link AuditPolicyManager}.
*
* @return See above.
*/
public static handle asHandle()
{
// TODO: implement
return new handle();
}
/**
* Implementation of AUDIT-POLICY:ENCRYPT-AUDIT-MAC-KEY method.
* Encrypts and encodes the specified character expression and returns an encrypted character
* value that you can store for later use in message authentication code (MAC) operations
*
* @param key
* A character expression containing the key to encrypt.
*
* @return An encrypted character value that you can store for later use in message
* authentication code (MAC) operations.
*/
@LegacyMethod(name = "ENCRYPT-AUDIT-MAC-KEY")
public static character encryptAuditMacKey(character key)
{
if (key.isUnknown())
{
return new character();
}
byte[] bkey = key.toStringMessage().getBytes(StandardCharsets.UTF_8);
byte[] progress = "PROGRESS".getBytes(StandardCharsets.UTF_8);
for (int i = 0; i < bkey.length; i++)
{
bkey[i] ^= progress[i % progress.length];
}
return new character(String.copyValueOf(Hex.encodeHex(bkey)));
}
/**
* Implementation of AUDIT-POLICY:REFRESH-AUDIT-POLICY method.
* Notifies the specified audit-enabled database that its audit policy tables have changed,
* which causes the database to refresh its current run-time audit policy settings cache
* before performing any more database operations.
*
* @param seqNo
* The sequence number of the connected database that needs to refresh its audit
* policy settings cache.
*
* @return <code>true</code> if operation succeeded or
* <code>false</code> otherwise
*/
@LegacyMethod(name = "REFRESH-AUDIT-POLICY")
public static logical refreshAuditPolicy(integer seqNo)
{
UnimplementedFeature.missing("REFRESH-AUDIT-POLICY method is not implemented.");
return new logical();
}
/**
* Implementation of AUDIT-POLICY:REFRESH-AUDIT-POLICY method.
* Notifies the specified audit-enabled database that its audit policy tables have changed,
* which causes the database to refresh its current run-time audit policy settings cache
* before performing any more database operations.
*
* @param alias
* The logical name or alias of the connected database that needs to refresh its
* audit policy settings cache..
*
* @return <code>true</code> if operation succeeded or
* <code>false</code> otherwise
*/
@LegacyMethod(name = "REFRESH-AUDIT-POLICY")
public static logical refreshAuditPolicy(character alias)
{
UnimplementedFeature.missing("REFRESH-AUDIT-POLICY method is not implemented.");
return new logical();
}
/**
* Implementation of the AUDIT-ENABLED function.
*
* @param seqNo
* The sequence number of the connected database.
*
* @return n/a
*/
public static logical isAuditEnabled(integer seqNo)
{
isAuditEnabledToken =
UnimplementedFeature.missing("AUDIT-ENABLED function is not implemented.",
isAuditEnabledToken);
return new logical();
}
/**
* Implementation of the AUDIT-ENABLED function.
*
* @param alias
* The logical name or alias of the connected database.
*
* @return n/a
*/
public static logical isAuditEnabled(character alias)
{
return isAuditEnabled(new integer());
}
/**
* Implementation of the AUDIT-ENABLED function.
*
* @return n/a
*/
public static logical isAuditEnabled()
{
return isAuditEnabled(new integer());
}
}