예제 #1
0
  /**
   * Creates new SyncAttribute instances out of the properties of an entity. The newly created
   * instances are added to syncAttributeList.
   *
   * <p>SyncLSyncAttributeink is a JAXB Xml class generated out of verinice import and export XML
   * schema files: sernet/verinice/service/sync sync.xsd data.xsd mapping.xsd
   *
   * @param entity
   * @param syncAttributeList
   * @param typeId
   * @param huiTypeFactory
   */
  public static void transform(
      Entity entity,
      List<SyncAttribute> syncAttributeList,
      String typeId,
      HUITypeFactory huiTypeFactory,
      ExportReferenceTypes exportReferenceTypes) {
    Map<String, PropertyList> properties = entity.getTypedPropertyLists();
    for (String propertyTypeId : properties.keySet()) {

      PropertyType propertyType = huiTypeFactory.getPropertyType(typeId, propertyTypeId);
      if (propertyType == null) {
        LOG.warn("Property type not found in SNCA.xml: " + propertyTypeId + ", typeId: " + typeId);
      }

      if (propertyType == null || propertyType.isReportable()) {
        SyncAttribute syncAttribute = new SyncAttribute();
        // Add <syncAttribute> to this <syncObject>:
        syncAttribute.setName(propertyTypeId);

        // transform dbid to uuid for the export
        if (isReference(propertyType)) {
          PropertyList propertyList = entity.getProperties(propertyTypeId);
          exportReferenceTypes.mapEntityDatabaseId2ExtId(syncAttribute, propertyList);

        } else {
          entity.exportProperties(propertyTypeId, syncAttribute.getValue());
        }

        if (!syncAttribute.getValue().isEmpty()) {
          syncAttributeList.add(syncAttribute);
        }
      }
    }
  }
예제 #2
0
 public void setScopeOnly(boolean scopeOnly) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_SCOPE);
   if (scopeOnly) {
     entity.setSimpleValue(type, PROP_SCOPE_YES);
   } else {
     entity.setSimpleValue(type, PROP_SCOPE_NO);
   }
 }
예제 #3
0
 public void setRcpUser(boolean rcpUser) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_RCP);
   if (rcpUser) {
     entity.setSimpleValue(type, PROP_RCP_YES);
   } else {
     entity.setSimpleValue(type, PROP_RCP_NO);
   }
 }
예제 #4
0
 public void setAdminUser(boolean isAdmin) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_ISADMIN);
   if (isAdmin) {
     entity.setSimpleValue(type, PROP_ISADMIN_YES);
   } else {
     entity.setSimpleValue(type, PROP_ISADMIN_NO);
   }
 }
예제 #5
0
 public void setWebUser(boolean webUser) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_WEB);
   if (webUser) {
     entity.setSimpleValue(type, PROP_WEB_YES);
   } else {
     entity.setSimpleValue(type, PROP_WEB_NO);
   }
 }
예제 #6
0
  private void setLinkText() {
    PropertyList propList = entity.getProperties(type.getId());
    savedProp = propList != null ? propList.getProperty(0) : null;

    if (savedProp == null) {
      savedProp = entity.createNewProperty(type, ""); // $NON-NLS-1$
    }
    if (savedProp.getPropertyValue() != null) {
      link.setText(savedProp.getPropertyValue());
    }
    link.pack();
  }
예제 #7
0
 public void setIsDeactivatedUser(boolean isDeactivated) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_DEACTIVATED);
   if (type == null) {
     LOG.error(
         "Can not set property: "
             + PROP_DEACTIVATED
             + ". Property type is not defined, check SNCA.xml.");
     return;
   }
   if (isDeactivated) {
     entity.setSimpleValue(type, PROP_DEACTIVATED_TRUE);
   } else {
     entity.setSimpleValue(type, PROP_DEACTIVATED_FALSE);
   }
 }
예제 #8
0
 public void createLinks() {
   // create new link to object
   String linkType = type.getReferencedCnaLinkType();
   String referencedEntityType = type.getReferencedEntityTypeId();
   type.getReferenceResolver().createLinks(referencedEntityType, linkType, entity.getUuid());
   writeLinkedObjectsToTextField();
 }
예제 #9
0
 /**
  * Get all linked objects for linktype and write their names to the text field. Uses a runtime
  * callback (reference resolver) to do this.
  */
 private void writeLinkedObjectsToTextField() {
   String referencedCnaLinkType = type.getReferencedCnaLinkType();
   String names =
       type.getReferenceResolver()
           .getTitlesOfLinkedObjects(referencedCnaLinkType, entity.getUuid());
   text.setText(names);
 }
예제 #10
0
 public void addRole(String name) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_ROLES);
   entity.createNewProperty(type, name);
   if (LOG.isDebugEnabled()) {
     LOG.debug("Role " + name + " added to account.");
   }
 }
예제 #11
0
 /**
  * Convenience method that safely checks whether the value of a given propertytype is equal to a
  * given value.
  *
  * <p>The method assumes that the property is single-valued.
  *
  * <p>The method safely handles the fact that a property might not exist at all. In this case the
  * result is always <code>false</code>
  *
  * <p>The given value shall not be <code>null</code>, otherwise a {@link NullPointerException} is
  * thrown.
  *
  * <p>The expected value is compared to the so called raw value of the property. In the Hitro UI
  * configuration this is what is provided by the "id" attribute of an <em>option</em> element.
  *
  * @param expected
  */
 private boolean isRawPropertyValueEqual(String propertyType, String expected) {
   Property p = entity.getProperties(propertyType).getProperty(0);
   if (p != null) {
     return expected.equals(p.getPropertyValue());
   }
   return false;
 }
예제 #12
0
 public void setAuditorNotificationExpirationEnabled(boolean b) {
   PropertyType type =
       getTypeFactory()
           .getPropertyType(Configuration.TYPE_ID, PROP_AUDITOR_NOTIFICATION_EXPIRATION);
   entity.setSimpleValue(
       type,
       (b ? "configuration_auditmailing_expiring_yes" : "configuration_auditmailing_expiring_no"));
 }
예제 #13
0
 public void setNotificationMeasureAssignment(boolean b) {
   PropertyType type =
       getTypeFactory()
           .getPropertyType(Configuration.TYPE_ID, PROP_NOTIFICATION_MEASURE_ASSIGNMENT);
   entity.setSimpleValue(
       type,
       (b ? PROP_NOTIFICATION_MEASURE_ASSIGNMENT_YES : PROP_NOTIFICATION_MEASURE_ASSIGNMENT_NO));
 }
예제 #14
0
 public int getAuditorNotificationExpirationDays() {
   String s = entity.getSimpleValue(PROP_AUDITOR_NOTIFICATION_EXPIRATION_DAYS);
   if (s != null && s.length() > 0) {
     return Integer.parseInt(s);
   }
   // No value set, then say there is no limit.
   return 0;
 }
예제 #15
0
 public void setNotificationMeasureModification(boolean b) {
   PropertyType type =
       getTypeFactory()
           .getPropertyType(Configuration.TYPE_ID, PROP_NOTIFICATION_MEASURE_MODIFICATION);
   entity.setSimpleValue(
       type,
       (b
           ? "configuration_mailing_measure_modification_yesno_yes"
           : "configuration_mailing_measure_modification_yesno_no"));
 }
예제 #16
0
  public boolean deleteRole(String name) {
    // cannot delete the special user role:
    if (name.equals(getUser())) {
      return false;
    }

    PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_ROLES);
    entity.remove(type, name);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Role " + name + " deleted from account.");
    }
    return true;
  }
예제 #17
0
 public void setAuditorNotificationGlobal(String value) {
   if (value != null
       && (!PROP_AUDITOR_NOTIFICATION_GLOBAL_ALL.equals(value))
       && (!PROP_AUDITOR_NOTIFICATION_GLOBAL_SELF.equals(value))) {
     throw new IllegalArgumentException(
         "Value of property "
             + PROP_AUDITOR_NOTIFICATION_GLOBAL
             + " can only set to "
             + PROP_AUDITOR_NOTIFICATION_GLOBAL_ALL
             + " or "
             + PROP_AUDITOR_NOTIFICATION_GLOBAL_SELF);
   }
   PropertyType type =
       getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_AUDITOR_NOTIFICATION_GLOBAL);
   entity.setSimpleValue(type, value);
 }
예제 #18
0
  /**
   * Returns a set of roles the person to which this configuration belongs is in.
   *
   * <p>The roles returned herein are to be used for checking whether the user has access to
   * elements of the {@link BSIModel}.
   *
   * <p>In contrast the roles of the type {@link Person} are only meant for the IT security model.
   *
   * @return
   */
  public Set<String> getRoles(boolean withUserRole) {
    List<Property> properties = entity.getProperties(Configuration.PROP_ROLES).getProperties();

    Set<String> roles = null;

    if (properties != null) {
      roles = new HashSet<String>(properties.size());
      for (Property p : properties) {
        roles.add(p.getPropertyValue());
      }
    } else {
      roles = new HashSet<String>();
    }
    if (withUserRole) {
      roles.add(getUser());
    }
    return roles;
  }
예제 #19
0
 public void update() {
   PropertyList propList = entity.getProperties(type.getId());
   Property entityProp;
   entityProp = propList != null ? propList.getProperty(0) : null;
   if (entityProp != null && !link.getText().equals(entityProp.getPropertyValue())) {
     savedProp = entityProp;
     if (Display.getCurrent() != null) {
       setLinkText();
     } else {
       Display.getDefault()
           .asyncExec(
               new Runnable() {
                 public void run() {
                   setLinkText();
                 }
               });
     }
   }
 }
예제 #20
0
  public static void hydrateEntity(IBaseDao dao, Entity entity) {
    if (dao == null) {
      Logger.getLogger(HydratorUtil.class).error("Missing DAO, cannot hydrate.");
      return;
    }
    if (entity == null) return;

    Map<String, PropertyList> lists = entity.getTypedPropertyLists();
    Set<Entry<String, PropertyList>> entrySet = lists.entrySet();
    for (Entry<String, PropertyList> entry : entrySet) {
      PropertyList list = entry.getValue();
      List<Property> propertyList = list.getProperties();
      dao.initialize(propertyList);
      // set the parent in the property since it is not mapped by hibernate anymore
      for (Property property : propertyList) {
        property.setParent(entity);
      }
    }
  }
예제 #21
0
 public void setAuditorNotificationGlobal(boolean b) {
   PropertyType type =
       getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_AUDITOR_NOTIFICATION_GLOBAL);
   entity.setSimpleValue(
       type, (b ? PROP_AUDITOR_NOTIFICATION_GLOBAL_ALL : PROP_AUDITOR_NOTIFICATION_GLOBAL_SELF));
 }
예제 #22
0
 public String getPass() {
   return entity.getSimpleValue(PROP_PASSWORD);
 }
예제 #23
0
 public void setAuditorNotificationExpirationDays(int days) {
   PropertyType type =
       getTypeFactory()
           .getPropertyType(Configuration.TYPE_ID, PROP_AUDITOR_NOTIFICATION_EXPIRATION_DAYS);
   entity.setSimpleValue(type, String.valueOf(days));
 }
예제 #24
0
 public void setPass(String pass) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_PASSWORD);
   entity.setSimpleValue(type, pass);
 }
예제 #25
0
 public void setNotificationEnabled(boolean b) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_NOTIFICATION);
   entity.setSimpleValue(
       type, (b ? "configuration_mailing_yesno_yes" : "configuration_mailing_yesno_no"));
 }
예제 #26
0
 public void setNotificationEmail(String email) {
   PropertyType type =
       getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_NOTIFICATION_EMAIL);
   entity.setSimpleValue(type, email);
 }
예제 #27
0
 public String getNotificationEmail() {
   return entity.getSimpleValue(PROP_NOTIFICATION_EMAIL);
 }
예제 #28
0
 public void setUser(String user) {
   PropertyType type = getTypeFactory().getPropertyType(Configuration.TYPE_ID, PROP_USERNAME);
   entity.setSimpleValue(type, user);
 }
예제 #29
0
 public String getUser() {
   return entity.getSimpleValue(PROP_USERNAME);
 }