# Principal.java

    /*
    ** Module   : Principal.java
    ** Abstract : Implementation of the OpenEdge.Security.Principal builtin class.
    **
    ** Copyright (c) 2025, Golden Code Development Corporation.
    **
    ** -#- -I- --Date-- -------------------------------Description--------------------------------
    ** 001 ICP 20250313 First version.
    */

    /*
    ** 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.oo.security;

    import com.goldencode.p2j.oo.lang.*;
    import com.goldencode.p2j.util.*;

    import static com.goldencode.p2j.report.ReportConstants.*;
    import static com.goldencode.p2j.util.BlockManager.*;
    import static com.goldencode.p2j.util.InternalEntry.*;

    /**
     * Implementation of the OpenEdge.Security.Principal builtin class.
     */
    @LegacyResource(resource = "OpenEdge.Security.Principal")
    @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
    public class Principal
    extends BaseObject
    {
       @LegacySignature(type = Type.PROPERTY, name = "Token")
       private handle token = TypeFactory.handle();

       @LegacySignature(type = Type.CONSTRUCTOR, name = "Principal", parameters =
       {
          @LegacyParameter(name = "phClientPrincipal", type = "HANDLE", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public void __security_principal_constructor__(final handle _phClientPrincipal)
       {
          handle phClientPrincipal = TypeFactory.initInput(_phClientPrincipal);

          internalProcedure(Principal.class, this, "Principal", new Block((Body) () ->
          {
             __lang_BaseObject_constructor__();
          }));
       }

       @LegacySignature(type = Type.CONSTRUCTOR, name = "Principal", parameters =
       {
          @LegacyParameter(name = "phClientPrincipal", type = "HANDLE", mode = "INPUT"),
          @LegacyParameter(name = "plAutoDestroy", type = "LOGICAL", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public void __security_principal_constructor__(final handle _phClientPrincipal, final logical _plAutoDestroy)
       {
          handle phClientPrincipal = TypeFactory.initInput(_phClientPrincipal);
          logical plAutoDestroy = TypeFactory.initInput(_plAutoDestroy);

          internalProcedure(Principal.class, this, "Principal", new Block((Body) () ->
          {
             __lang_BaseObject_constructor__();
          }));
       }

       @LegacySignature(type = Type.GETTER, name = "Token", returns = "HANDLE")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public handle getToken()
       {
          return token.duplicate();
       }

       @LegacySignature(type = Type.SETTER, name = "Token", parameters =
       {
          @LegacyParameter(name = "var", type = "HANDLE", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       private void setToken(handle var)
       {
          token.assign(var);
       }

       @LegacySignature(type = Type.METHOD, name = "AssertUser", returns = "LOGICAL")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical assertUser()
       {
          return function(Principal.class, this, "AssertUser", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "AssertUser", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcDb", type = "CHARACTER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical assertUser(final character _pcDb)
       {
          character pcDb = TypeFactory.initInput(_pcDb);

          return function(Principal.class, this, "AssertUser", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Authorize", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcRole", type = "CHARACTER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical authorize(final character _pcRole)
       {
          character pcRole = TypeFactory.initInput(_pcRole);

          return function(Principal.class, this, "Authorize", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Authorize", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcRole", type = "CHARACTER", extent = -1, mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical authorize(final character[] _pcRole)
       {
          character[] pcRole[] =
          {
             TypeFactory.initInput(_pcRole)
          };

          return function(Principal.class, this, "Authorize", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "AuthorizeAll", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcRole", type = "CHARACTER", extent = -1, mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical authorizeAll(final character[] _pcRole)
       {
          character[] pcRole[] =
          {
             TypeFactory.initInput(_pcRole)
          };

          return function(Principal.class, this, "AuthorizeAll", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "AuthorizeOne", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcRole", type = "CHARACTER", extent = -1, mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical authorizeOne(final character[] _pcRole)
       {
          character[] pcRole[] =
          {
             TypeFactory.initInput(_pcRole)
          };

          return function(Principal.class, this, "AuthorizeOne", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_()
       {
          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "prCP", type = "RAW", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_(final raw _prCp)
       {
          raw prCp = TypeFactory.initInput(_prCp);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "pcCP", type = "CHARACTER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_(final character _pcCp)
       {
          character pcCp = TypeFactory.initInput(_pcCp);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "poRequestInfo", type = "OBJECT", qualified = "progress.lang.oerequestinfo", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_(final object<? extends OerequestInfo> _poRequestInfo)
       {
          object<? extends OerequestInfo> poRequestInfo = TypeFactory.initInput(_poRequestInfo);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "pDbNum", type = "INTEGER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_(final integer _pDbNum)
       {
          integer pDbNum = TypeFactory.initInput(_pDbNum);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "poCP", type = "OBJECT", qualified = "openedge.core.memptr", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import__1(final object<? extends com.goldencode.p2j.oo.core.Memptr> _poCp)
       {
          object<? extends com.goldencode.p2j.oo.core.Memptr> poCp = TypeFactory.initInput(_poCp);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Import", returns = "OBJECT", qualified = "openedge.security.principal", parameters =
       {
          @LegacyParameter(name = "pmCP", type = "MEMPTR", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public static object<? extends Principal> import_(final memptr _pmCp)
       {
          memptr pmCp = TypeFactory.initInput(_pmCp);

          return function(Principal.class, "Import", object.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Validate", returns = "LOGICAL")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical validate_()
       {
          return function(Principal.class, this, "Validate", logical.class, new Block());
       }

       @LegacySignature(type = Type.METHOD, name = "Validate", returns = "LOGICAL", parameters =
       {
          @LegacyParameter(name = "pcKey", type = "CHARACTER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_STUB)
       public logical validate_(final character _pcKey)
       {
          character pcKey = TypeFactory.initInput(_pcKey);

          return function(Principal.class, this, "Validate", logical.class, new Block());
       }
    }