如何使用Java确定哪个安全管理器在z/OS上处于活动状态?

Joh*_*ann 4 zos

我在z/OS上编写Java代码,我需要找出系统上哪个安全管理器(RACF,ACF2或TopSecret)处于活动状态.我怎样才能做到这一点?

Joh*_*ann 5

您可以使用IBM JZOS包来查看内存,如下所示.对于生产代码,我会为安全管理器创建一个枚举,而不是传递字符串并且必须处理字符串比较.

import com.ibm.jzos.ZUtil;

/**
 * This is a sample program that uses IBM JZOS to determine
 * the Enterprise Security Manager that is active on a z/OS
 * system.
 * <p>
 * @see com.ibm.jzos.ZUtil#peekOSMemory(long, int)
 * @see com.ibm.jzos.ZUtil#peekOSMemory(long, byte[])
 */
public class peek {

    public static void main(String[] args) throws Exception {

        byte[] rcvtIdBytes = new byte[4];
        long pPSA  = 0L;
        int psaOffsetCVT = 16;
        long pCVT  = ZUtil.peekOSMemory(pPSA + psaOffsetCVT, 4); // Get address of CVT from PSA+16

        int cvtOffsetCVTRAC = 0x3e0;                             // Offset of CVTRAC (@RCVT) in the CVT
        long pCVTRAC =
                ZUtil.peekOSMemory(pCVT + cvtOffsetCVTRAC, 4);   // Get the address of CVTRAC (Mapped by ICHPRCVT)

        // Now we can retrieve the 4 byte ID (in IBM-1047) of the active ESM.
        int cvtracOffsetRCVTID = 0x45;                                   // Offset of RCVTID in the RCVT
        ZUtil.peekOSMemory(pCVTRAC + cvtracOffsetRCVTID, rcvtIdBytes);   // Get the RCVTID

        String rcvtId = new String(rcvtIdBytes, "IBM-1047");

        System.out.println("The Security Manager is: "+rcvtId);
    }
}
Run Code Online (Sandbox Code Playgroud)