Github user necouchman commented on a diff in the pull request:

    https://github.com/apache/guacamole-client/pull/319#discussion_r220393130
  
    --- Diff: 
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/usergroup/ModeledUserGroup.java
 ---
    @@ -0,0 +1,212 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.guacamole.auth.jdbc.usergroup;
    +
    +import com.google.inject.Inject;
    +import com.google.inject.Provider;
    +import java.util.Arrays;
    +import java.util.Collection;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Set;
    +import org.apache.guacamole.GuacamoleException;
    +import org.apache.guacamole.auth.jdbc.base.ModeledPermissions;
    +import org.apache.guacamole.auth.jdbc.user.ModeledAuthenticatedUser;
    +import org.apache.guacamole.form.BooleanField;
    +import org.apache.guacamole.form.Field;
    +import org.apache.guacamole.form.Form;
    +import org.apache.guacamole.net.auth.RelatedObjectSet;
    +import org.apache.guacamole.net.auth.UserGroup;
    +
    +/**
    + * An implementation of the UserGroup object which is backed by a database 
model.
    + */
    +public class ModeledUserGroup extends ModeledPermissions<UserGroupModel>
    +        implements UserGroup {
    +
    +    /**
    +     * The name of the attribute which controls whether a user group is
    +     * disabled.
    +     */
    +    public static final String DISABLED_ATTRIBUTE_NAME = "disabled";
    +
    +    /**
    +     * All attributes related to restricting user groups, within a logical
    +     * form.
    +     */
    +    public static final Form ACCOUNT_RESTRICTIONS = new 
Form("restrictions", Arrays.<Field>asList(
    +        new BooleanField(DISABLED_ATTRIBUTE_NAME, "true")
    +    ));
    +
    +    /**
    +     * All possible attributes of user groups organized as individual,
    +     * logical forms.
    +     */
    +    public static final Collection<Form> ATTRIBUTES = 
Collections.unmodifiableCollection(Arrays.asList(
    +        ACCOUNT_RESTRICTIONS
    +    ));
    +
    +    /**
    +     * The names of all attributes which are explicitly supported by this
    +     * extension's UserGroup objects.
    +     */
    +    public static final Set<String> ATTRIBUTE_NAMES =
    +            Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
    +                DISABLED_ATTRIBUTE_NAME
    +            )));
    +
    +    /**
    +     * Provider for RelatedObjectSets containing the user groups of which 
this
    +     * user group is a member.
    +     */
    +    @Inject
    +    private Provider<UserGroupParentUserGroupSet> 
parentUserGroupSetProvider;
    +
    +    /**
    +     * Provider for RelatedObjectSets containing the users that are 
members of
    +     * this user group.
    +     */
    +    @Inject
    +    private Provider<UserGroupMemberUserSet> memberUserSetProvider;
    +
    +    /**
    +     * Provider for RelatedObjectSets containing the user groups that are
    +     * members of this user group.
    +     */
    +    @Inject
    +    private Provider<UserGroupMemberUserGroupSet> 
memberUserGroupSetProvider;
    +
    +    /**
    +     * Whether attributes which control access restrictions should be 
exposed
    +     * via getAttributes() or allowed to be set via setAttributes().
    +     */
    +    private boolean exposeRestrictedAttributes = false;
    +
    +    /**
    +     * Initializes this ModeledUserGroup, associating it with the current
    +     * authenticated user and populating it with data from the given user 
group
    +     * model.
    +     *
    +     * @param currentUser
    +     *     The user that created or retrieved this object.
    +     *
    +     * @param model
    +     *     The backing model object.
    +     *
    +     * @param exposeRestrictedAttributes
    +     *     Whether attributes which control access restrictions should be
    +     *     exposed via getAttributes() or allowed to be set via
    +     *     setAttributes().
    +     */
    +    public void init(ModeledAuthenticatedUser currentUser, UserGroupModel 
model,
    +            boolean exposeRestrictedAttributes) {
    +        super.init(currentUser, model);
    +        this.exposeRestrictedAttributes = exposeRestrictedAttributes;
    +    }
    +
    +    /**
    +     * Creates a new, empty ModeledUserGroup.
    +     */
    +    public ModeledUserGroup() {
    --- End diff --
    
    For consistency's sake, should this constructor be above the `init()` 
method?  I think that's how it's done elsewhere in the code...


---

Reply via email to