You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by yourik <Ur...@gmail.com> on 2012/01/31 09:24:11 UTC

Shiro1.2: runAs feature doesn't works

Hi

Right after SecurityUtils.getSubject().runAs(new new
SimplePrincipalCollection(){...})

SecurityUtils.getSubject().getPrincipal() returns correct new Principal
SecurityUtils.getSubject()..getPreviousPrincipals() returns correct original
Principal

but DefaultSubjectDAO merge principals in method

protected void mergePrincipals(Subject subject) {
  PrincipalCollection currentPrincipals = subject.getPrincipals();
  ...
  if (session == null) {
  ...
  } else {
    PrincipalCollection existingPrincipals = (PrincipalCollection)
session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
    if (CollectionUtils.isEmpty(currentPrincipals)) {
      ...
    } else {
       if (!currentPrincipals.equals(existingPrincipals)) {
           
session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY,
currentPrincipals);
      }
   }
}


and after that 
SecurityUtils.getSubject().getPrincipal() and
SecurityUtils.getSubject().getPreviousPrincipals() both returns new
Principal - this is wrong behavior 

Your thoughts and time on this will be of much help.
Thank you

--
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro1-2-runAs-feature-doesn-t-works-tp7239255p7239255.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro1.2: runAs feature doesn't works

Posted by yourik <Ur...@gmail.com>.
done
https://issues.apache.org/jira/browse/SHIRO-344

thank you

On 31 January 2012 20:26, Les Hazlewood-2 [via Shiro User] <
ml-node+s582556n7240729h82@n2.nabble.com> wrote:

> Hi Ury,
>
> Please file a bug in Jira for this and we'll try to take care of it ASAP.
>
> Thanks,
>
> Les
>
> On Tue, Jan 31, 2012 at 12:24 AM, yourik <[hidden email]<http://user/SendEmail.jtp?type=node&node=7240729&i=0>>
> wrote:
>
> > Hi
> >
> > Right after SecurityUtils.getSubject().runAs(new new
> > SimplePrincipalCollection(){...})
> >
> > SecurityUtils.getSubject().getPrincipal() returns correct new Principal
> > SecurityUtils.getSubject()..getPreviousPrincipals() returns correct
> original
> > Principal
> >
> > but DefaultSubjectDAO merge principals in method
> >
> > protected void mergePrincipals(Subject subject) {
> >  PrincipalCollection currentPrincipals = subject.getPrincipals();
> >  ...
> >  if (session == null) {
> >  ...
> >  } else {
> >    PrincipalCollection existingPrincipals = (PrincipalCollection)
> > session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
> >    if (CollectionUtils.isEmpty(currentPrincipals)) {
> >      ...
> >    } else {
> >       if (!currentPrincipals.equals(existingPrincipals)) {
> >
> > session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY,
> > currentPrincipals);
> >      }
> >   }
> > }
> >
> >
> > and after that
> > SecurityUtils.getSubject().getPrincipal() and
> > SecurityUtils.getSubject().getPreviousPrincipals() both returns new
> > Principal - this is wrong behavior
> >
> > Your thoughts and time on this will be of much help.
> > Thank you
> >
> > --
> > View this message in context:
> http://shiro-user.582556.n2.nabble.com/Shiro1-2-runAs-feature-doesn-t-works-tp7239255p7239255.html
> > Sent from the Shiro User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://shiro-user.582556.n2.nabble.com/Shiro1-2-runAs-feature-doesn-t-works-tp7239255p7240729.html
>  To unsubscribe from Shiro1.2: runAs feature doesn't works, click here<http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7239255&code=VXJ5RGFua29AZ21haWwuY29tfDcyMzkyNTV8MTYwNzQ3ODU0Ng==>
> .
> NAML<http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
http://militarizm.od.ua/


--
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro1-2-runAs-feature-doesn-t-works-tp7239255p7240916.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro1.2: runAs feature doesn't works

Posted by Les Hazlewood <lh...@apache.org>.
Hi Ury,

Please file a bug in Jira for this and we'll try to take care of it ASAP.

Thanks,

Les

On Tue, Jan 31, 2012 at 12:24 AM, yourik <Ur...@gmail.com> wrote:
> Hi
>
> Right after SecurityUtils.getSubject().runAs(new new
> SimplePrincipalCollection(){...})
>
> SecurityUtils.getSubject().getPrincipal() returns correct new Principal
> SecurityUtils.getSubject()..getPreviousPrincipals() returns correct original
> Principal
>
> but DefaultSubjectDAO merge principals in method
>
> protected void mergePrincipals(Subject subject) {
>  PrincipalCollection currentPrincipals = subject.getPrincipals();
>  ...
>  if (session == null) {
>  ...
>  } else {
>    PrincipalCollection existingPrincipals = (PrincipalCollection)
> session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
>    if (CollectionUtils.isEmpty(currentPrincipals)) {
>      ...
>    } else {
>       if (!currentPrincipals.equals(existingPrincipals)) {
>
> session.setAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY,
> currentPrincipals);
>      }
>   }
> }
>
>
> and after that
> SecurityUtils.getSubject().getPrincipal() and
> SecurityUtils.getSubject().getPreviousPrincipals() both returns new
> Principal - this is wrong behavior
>
> Your thoughts and time on this will be of much help.
> Thank you
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro1-2-runAs-feature-doesn-t-works-tp7239255p7239255.html
> Sent from the Shiro User mailing list archive at Nabble.com.