Пример #1
0
 /**
  * Return a static reference to this instance. If the instance has not been instantiated, call the
  * boostrap:
  *
  * <ul>
  *   <li>Load from fortress.properties
  *   <li>Load some overrides from System properties
  *   <li>Load from ou=Config ldap node
  * </ul>
  *
  * @return this
  */
 public static Config getInstance() {
   if (sINSTANCE == null) {
     synchronized (Config.class) {
       if (sINSTANCE == null) {
         sINSTANCE = new Config();
         if (!sINSTANCE.isRemoteConfigLoaded()) {
           sINSTANCE.loadRemoteConfig();
         }
       }
     }
   }
   return sINSTANCE;
 }
  /** Package private default constructor. */
  GroupDAO() {
    super();
    GROUP_OBJECT_CLASS_IMPL = Config.getInstance().getProperty(GROUP_OBJECT_CLASS);
    GROUP_PROTOCOL_ATTR_IMPL = Config.getInstance().getProperty(GROUP_PROTOCOL_ATTR);
    GROUP_PROPERTY_ATTR_IMPL = Config.getInstance().getProperty(GROUP_PROPERTY_ATTR);

    GROUP_OBJ_CLASS = new String[] {SchemaConstants.TOP_OC, GROUP_OBJECT_CLASS_IMPL};

    GROUP_ATRS =
        new String[] {
          SchemaConstants.CN_AT,
          SchemaConstants.DESCRIPTION_AT,
          GlobalIds.TYPE,
          GROUP_PROTOCOL_ATTR_IMPL,
          GROUP_PROPERTY_ATTR_IMPL,
          SchemaConstants.MEMBER_AT
        };
  }
/**
 * Factory class used to instantiate the ExampleAdminMgrImpl.
 *
 * @author <a href="mailto:[email protected]">Apache Directory Project</a>
 * @created December 26, 2010
 */
public class ExampleAdminMgrFactory {
  private static String exampleAdminClassName =
      Config.getProperty(EIds.EXAMPLE_ADMIN_IMPLEMENTATION);

  public static ExampleAdminMgr createInstance() throws SecurityException {
    ExampleAdminMgr adminMgr;
    if (exampleAdminClassName == null || exampleAdminClassName.compareTo("") == 0) {
      exampleAdminClassName = EIds.EXAMPLE_ADMIN_DEFAULT_CLASS;
    }
    adminMgr = (ExampleAdminMgr) ClassUtil.createInstance(exampleAdminClassName);
    return adminMgr;
  }
}
  /**
   * This method creates raw data format that represents UserAdminRole temporal and ARBAC
   * constraints using instance variables inside entity. The raw data is eventually stored in the
   * 'ftARC' attribute on the 'ftUserAttrs' object class. This is the raw format that Fortress uses
   * to condense the temporal and ARBAC data into a compact String for efficient storage and
   * retrieval and is not intended to be called by external programs.
   *
   * @return String contains a raw formatted String that maps to 'ftARC' attribute on 'ftUserAttrs'
   *     object class
   */
  @Override
  public String getRawData() {
    String szRole;
    String delimeter = Config.getInstance().getDelimiter();
    StringBuilder sb = new StringBuilder();
    sb.append(name);
    sb.append(delimeter);
    sb.append(this.getTimeout());
    sb.append(delimeter);

    if (this.getBeginTime() != null) {
      sb.append(this.getBeginTime());
    }

    sb.append(delimeter);

    if (this.getEndTime() != null) {
      sb.append(this.getEndTime());
    }

    sb.append(delimeter);

    if (this.getBeginDate() != null) {
      sb.append(this.getBeginDate());
    }

    sb.append(delimeter);

    if (this.getEndDate() != null) {
      sb.append(this.getEndDate());
    }

    sb.append(delimeter);

    if (this.getBeginLockDate() != null) {
      sb.append(this.getBeginLockDate());
    }

    sb.append(delimeter);

    if (this.getEndLockDate() != null) {
      sb.append(this.getEndLockDate());
    }

    sb.append(delimeter);

    if (this.getDayMask() != null) {
      sb.append(this.getDayMask());
    }

    if (this.getOsUSet() != null) {
      for (String org : this.getOsUSet()) {
        sb.append(delimeter);
        sb.append(U);
        sb.append(GlobalIds.PROP_SEP);
        sb.append(org);
      }
    }

    if (this.getOsPSet() != null) {
      for (String org : this.getOsPSet()) {
        sb.append(delimeter);
        sb.append(P);
        sb.append(GlobalIds.PROP_SEP);
        sb.append(org);
      }
    }
    if (StringUtils.isNotEmpty(this.getRoleRangeRaw())) {
      sb.append(delimeter);
      sb.append(R);
      sb.append(GlobalIds.PROP_SEP);
      sb.append(this.getRoleRangeRaw());
    }

    szRole = sb.toString();
    return szRole;
  }
  /**
   * This method loads UserAdminRole entity temporal and ARBAC constraint instance variables with
   * data that was retrieved from the 'ftARC' attribute on the 'ftUserAttrs' object class. This is
   * the raw format that Fortress uses to condense the temporal and ARBAC data into a compact String
   * for efficient storage and retrieval and is not intended to be called by external programs.
   *
   * @param szRawData contains a raw formatted String that maps to 'ftARC' attribute on
   *     'ftUserAttrs' object class
   * @param contextId contains the tenant id.
   * @param parentUtil provides method to getParents.
   */
  public void load(String szRawData, String contextId, ParentUtil parentUtil) {
    if ((szRawData != null) && (szRawData.length() > 0)) {
      String[] tokens =
          StringUtils.splitPreserveAllTokens(szRawData, Config.getInstance().getDelimiter());
      for (int i = 0; i < tokens.length; i++) {
        if (StringUtils.isNotEmpty(tokens[i])) {
          switch (i) {
            case 0:
              name = tokens[i];
              parents = parentUtil.getParentsCB(name.toUpperCase(), contextId);
              break;

            case 1:
              this.setTimeout(Integer.parseInt(tokens[i]));
              break;

            case 2:
              this.setBeginTime(tokens[i]);
              break;

            case 3:
              this.setEndTime(tokens[i]);
              break;

            case 4:
              this.setBeginDate(tokens[i]);
              break;

            case 5:
              this.setEndDate(tokens[i]);
              break;

            case 6:
              this.setBeginLockDate(tokens[i]);
              break;

            case 7:
              this.setEndLockDate(tokens[i]);
              break;

            case 8:
              this.setDayMask(tokens[i]);
              break;

            default:
              String szValue = tokens[i];
              int indx = szValue.indexOf(P + GlobalIds.PROP_SEP);
              if (indx >= 0) {
                String szOsP = szValue.substring(indx + 2);
                this.setOsP(szOsP);
              }
              indx = szValue.indexOf(U + GlobalIds.PROP_SEP);
              if (indx >= 0) {
                String szOsU = szValue.substring(indx + 2);
                this.setOsU(szOsU);
              }
              indx = szValue.indexOf(R + GlobalIds.PROP_SEP);
              if (indx >= 0) {
                String szRangeRaw = szValue.substring(indx + 2);
                this.setRoleRangeRaw(szRangeRaw);
              }
              break;
          }
        }
      }
    }
  }