public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_USER_FACILITY_ATTR_VIRT);
   attr.setFriendlyName("shell");
   attr.setType(String.class.getName());
   attr.setDescription("Computed shell from user preferences");
   return attr;
 }
 public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_VO_ATTR_DEF);
   attr.setFriendlyName("membershipExpirationRules");
   attr.setType(LinkedHashMap.class.getName());
   attr.setDescription("Rules which define how the membership is extended.");
   return attr;
 }
 @Override
 public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_MEMBER_RESOURCE_ATTR_DEF);
   attr.setFriendlyName("filesQuota");
   attr.setType(Integer.class.getName());
   attr.setDescription("Soft quota for number of files.");
   return attr;
 }
Example #4
0
 private static AttributeDefinition createAttributeDefinition(Map<String, String> beanAttr) {
   if (beanAttr == null) return null;
   AttributeDefinition attributeDefinition = new AttributeDefinition();
   attributeDefinition.setId(Integer.valueOf(beanAttr.get("id")).intValue());
   attributeDefinition.setFriendlyName(BeansUtils.eraseEscaping(beanAttr.get("friendlyName")));
   attributeDefinition.setNamespace(BeansUtils.eraseEscaping(beanAttr.get("namespace")));
   attributeDefinition.setType(BeansUtils.eraseEscaping(beanAttr.get("type")));
   return attributeDefinition;
 }
 @Override
 public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_ENTITYLESS_ATTR_DEF);
   attr.setFriendlyName("namespace_maxGID");
   attr.setDisplayName("Max GID in namespace");
   attr.setType(Integer.class.getName());
   attr.setDescription("Maximal value of Group ID.");
   return attr;
 }
 @Override
 public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_RESOURCE_ATTR_DEF);
   attr.setFriendlyName("defaultDataQuotas");
   attr.setDisplayName("Default data quotas on any volumes.");
   attr.setType(LinkedHashMap.class.getName());
   attr.setDescription(
       "Every record is the path (to volume) and the quota in format 'SoftQuota:HardQuota' in (M, G, T, ...), G is default. Example: '10G:20T'.");
   return attr;
 }
 @Override
 public AttributeDefinition getAttributeDefinition() {
   AttributeDefinition attr = new AttributeDefinition();
   attr.setNamespace(AttributesManager.NS_FACILITY_ATTR_DEF);
   attr.setFriendlyName("ldapBaseDN");
   attr.setDisplayName("LDAP base DN");
   attr.setType(String.class.getName());
   attr.setDescription(
       "Base part of DN, which will be used for all entities propagated to facility. Should be like \"ou=sth,dc=example,dc=domain\" (without quotes)");
   return attr;
 }
  @Override
  public Attribute getAttributeValue(
      PerunSessionImpl sess, User user, AttributeDefinition attributeDefinition)
      throws InternalErrorException {
    Attribute attribute = new Attribute(attributeDefinition);
    HashMap<String, String> organizationsWithLoa = new LinkedHashMap<String, String>();

    List<UserExtSource> extSources =
        sess.getPerunBl().getUsersManagerBl().getUserExtSources(sess, user);
    if (extSources == null || extSources.isEmpty())
      return attribute; // If no userExtSources, so no Loa for any of them.

    String version = attributeDefinition.getFriendlyNameParameter();
    if (version == null)
      throw new InternalErrorException(
          "There is no parameter (cs or en) in attribute " + attributeDefinition);

    UserExtSource userExtSourceForCreating = null;
    UserExtSource userExtSourceForModifiing = null;

    // Initialize MapOfExtSource
    initializeMapOfExtSourceName();

    for (UserExtSource uES : extSources) {
      String uEName = uES.getExtSource().getName();
      String uELoa = String.valueOf(uES.getLoa());

      if (uES.getCreatedAt() != null) {
        Date testingDate = null;
        Date lastUsedDate = null;
        boolean parsed = true;
        try {
          testingDate = BeansUtils.DATE_FORMATTER.parse(uES.getCreatedAt());
        } catch (Exception ex) {
          // Not Parsed correctly
          parsed = false;
        }
        if (parsed) {
          if (userExtSourceForCreating == null || userExtSourceForCreating.getCreatedAt() == null)
            userExtSourceForCreating = uES;
          else {
            try {
              lastUsedDate =
                  BeansUtils.DATE_FORMATTER.parse(userExtSourceForCreating.getCreatedAt());
              if (testingDate != null && testingDate.compareTo(lastUsedDate) < 0) {
                userExtSourceForCreating = uES;
              }
            } catch (Exception ex) {
              // Not Parsed correctly
              userExtSourceForCreating = uES;
            }
          }
        }
      }

      if (uES.getModifiedAt() != null) {
        Date testingDate = null;
        Date lastUsedDate = null;
        boolean parsed = true;
        try {
          testingDate = BeansUtils.DATE_FORMATTER.parse(uES.getModifiedAt());
        } catch (Exception ex) {
          // Not Parsed correctly
          parsed = false;
        }
        if (parsed) {
          if (userExtSourceForModifiing == null
              || userExtSourceForModifiing.getModifiedAt() == null) userExtSourceForModifiing = uES;
          else {
            try {
              lastUsedDate =
                  BeansUtils.DATE_FORMATTER.parse(userExtSourceForModifiing.getModifiedAt());
              if (testingDate != null && testingDate.compareTo(lastUsedDate) < 0) {
                userExtSourceForModifiing = uES;
              }
            } catch (Exception ex) {
              // Not Parsed correctly
              userExtSourceForModifiing = uES;
            }
          }
        }
      }

      String uESimpleName = getSimpleNameOfExtSource(uEName, version.equals("cs"));
      organizationsWithLoa.put(uESimpleName, uELoa);
    }

    // Set created,modified by userExtSources
    if (userExtSourceForCreating != null) {
      attribute.setValueCreatedAt(userExtSourceForCreating.getCreatedAt());
      attribute.setValueCreatedBy(userExtSourceForCreating.getCreatedBy());
    }
    if (userExtSourceForModifiing != null) {
      attribute.setValueModifiedAt(userExtSourceForModifiing.getModifiedAt());
      attribute.setValueModifiedBy(userExtSourceForModifiing.getModifiedBy());
    }
    attribute.setValue(organizationsWithLoa);
    return attribute;
  }