a question about nifi's source code

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

a question about nifi's source code

YuNing
Hello,everyone
        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
        Am i right?  can anyone help me, thanks alot !

Best Regards
YuNing

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about nifi's source code

Andy LoPresto
Hi YuNing,

The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.

Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: a question about nifi's source code

YuNing
   Hi Andy,
    The concrete class I am using is FileAuthorizer, and updateGroup of abstract policy authorizer  method is listed below. i didn't know why it needs to check th group's existence, and i didn't know how to add a user to a group.  
    thanks for your reply.

Best Regards 
YuNing
 
Date: 2017-08-02 14:01
Subject: Re: a question about nifi's source code
Hi YuNing,
 
The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.
 
Andy LoPresto
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
 
> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: a question about nifi's source code

YuNing
In reply to this post by Andy LoPresto
png pciture can't be seen, i copy it there.
  /**
     * Adds a new group.
     *
     * @param group the Group to add
     * @return the added Group
     * @throws AuthorizationAccessException if there was an unexpected error performing the operation
     * @throws IllegalStateException if a group with the same name already exists
     */
    public final synchronized Group addGroup(Group group) throws AuthorizationAccessException {
        if (tenantExists(group.getIdentifier(), group.getName())) {
            throw new IllegalStateException(String.format("User/user group already exists with the identity '%s'.", group.getName()));
        }
        return doAddGroup(group);
    }

 
From: Andy LoPresto
Date: 2017-08-02 14:01
To: dev
Subject: Re: a question about nifi's source code
Hi YuNing,
 
The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.
 
Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
 
> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: a question about nifi's source code

YuNing
In reply to this post by Andy LoPresto
this is the updateGroup Method , and doUpdateGroup method;

    /**
     * The group represented by the provided instance will be updated based on the provided instance.
     *
     * @param group an updated group instance
     * @return the updated group instance, or null if no matching group was found
     * @throws AuthorizationAccessException if there was an unexpected error performing the operation
     * @throws IllegalStateException if there is already a group with the same name
     */
    public final synchronized Group updateGroup(Group group) throws AuthorizationAccessException {
        if (tenantExists(group.getIdentifier(), group.getName())) {
            throw new IllegalStateException(String.format("User/user group already exists with the identity '%s'.", group.getName()));
        }
        return doUpdateGroup(group);
    }
    /**
     * The group represented by the provided instance will be updated based on the provided instance.
     *
     * @param group an updated group instance
     * @return the updated group instance, or null if no matching group was found
     * @throws AuthorizationAccessException if there was an unexpected error performing the operation
     */
    public abstract Group doUpdateGroup(Group group) throws AuthorizationAccessException;



[hidden email]
 
From: Andy LoPresto
Date: 2017-08-02 14:01
To: dev
Subject: Re: a question about nifi's source code
Hi YuNing,
 
The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.
 
Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
 
> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: a question about nifi's source code

YuNing
In reply to this post by Andy LoPresto
Hi,Andy
    It seems I found the problems, I compare the sourcecode which i am viewing to the sourcecode on github, it appears to be different, and i am confused, because i didn't change it myslf, i will keep this update as long as i found the reason.
    thanks you very much.



Best Regards
YuNing
 
From: Andy LoPresto
Date: 2017-08-02 14:01
To: dev
Subject: Re: a question about nifi's source code
Hi YuNing,
 
The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.
 
Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
 
> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: a question about nifi's source code

YuNing
    I fround the problem, recently. there is no existance check of tenants before doUpdateGroup() at the most recent version on github. but it checks at  nifi-1.3.0 release version. you can see this at https://github.com/apache/nifi/blob/rel/nifi-1.3.0/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java 
and it doesn't seams to be a bug ,because everything just works fine.



Best Regards
YuNing
 
From: YuNing
Date: 2017-08-02 14:43
To: dev
Subject: Re: Re: a question about nifi's source code
Hi,Andy
    It seems I found the problems, I compare the sourcecode which i am viewing to the sourcecode on github, it appears to be different, and i am confused, because i didn't change it myslf, i will keep this update as long as i found the reason.
    thanks you very much.



Best Regards
YuNing
 
From: Andy LoPresto
Date: 2017-08-02 14:01
To: dev
Subject: Re: a question about nifi's source code
Hi YuNing,
 
The Abstract policy authorizer delegates the updateGroup action to doUpdateGroup, which is implemented by the extending concrete class. I'm not sure where you are seeing that it checks for the absence of the group, but there is an addGroup method for adding a new group.
 
Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
 
> On Aug 1, 2017, at 19:48, YuNing <[hidden email]> wrote:
>
> Hello,everyone
>        I am work on reading nifi's source code . it confuse me when i read the class "AbstractPolicyBasedAuthorizer", I found there is no method to add a user to an existing group. I noticed there is an "updateGroup" method ,which i don't think can be used to add users to existing group, because it checks the input group to make sure it didn't exist.
>        Am i right?  can anyone help me, thanks alot !
>
> Best Regards
> YuNing
>
Loading...