Return-Path: X-Original-To: apmail-shiro-dev-archive@www.apache.org Delivered-To: apmail-shiro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 97E547CDE for ; Thu, 15 Dec 2011 10:23:04 +0000 (UTC) Received: (qmail 87953 invoked by uid 500); 15 Dec 2011 10:23:04 -0000 Delivered-To: apmail-shiro-dev-archive@shiro.apache.org Received: (qmail 87942 invoked by uid 500); 15 Dec 2011 10:23:04 -0000 Mailing-List: contact dev-help@shiro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@shiro.apache.org Delivered-To: mailing list dev@shiro.apache.org Received: (qmail 87854 invoked by uid 99); 15 Dec 2011 10:23:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 10:23:04 +0000 X-ASF-Spam-Status: No, hits=-2001.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 10:22:53 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 7A8BC114CC6 for ; Thu, 15 Dec 2011 10:22:31 +0000 (UTC) Date: Thu, 15 Dec 2011 10:22:31 +0000 (UTC) From: =?utf-8?Q?J=C3=A9r=C3=B4me_Leleu_=28Commented=29_=28JIRA=29?= To: dev@shiro.apache.org Message-ID: <1603084605.14983.1323944551503.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <566604729.64670.1303142225807.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (SHIRO-285) Integration with CAS MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/SHIRO-285?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D13170= 102#comment-13170102 ]=20 J=C3=A9r=C3=B4me Leleu commented on SHIRO-285: ------------------------------------ Hi, With cas client 3.2.1, the attributes of the principal is no longer a map o= f String,String but a map of String,Object. That's why compilation fails. You should update the code in the CasRealm class (at line 106) : Map attributes =3D principal.getAttribu= tes(); // refresh authentication token (user id + remember me) casToken.setUserId(userId); boolean isRemembered =3D attributes.get(rememberMeAttri= buteName) !=3D null ? Boolean .parseBoolean((String) attributes.get(rememberMeAtt= ributeName)) : false; if (isRemembered) { casToken.setRememberMe(true); } I test it and it works. Regards, J=C3=A9r=C3=B4me =20 > Integration with CAS > -------------------- > > Key: SHIRO-285 > URL: https://issues.apache.org/jira/browse/SHIRO-285 > Project: Shiro > Issue Type: New Feature > Reporter: J=C3=A9r=C3=B4me Leleu > Attachments: shiro_cas.txt, shiro_cas2.txt > > > As I wanted to test shiro with CAS, I created a CAS filter, a CAS token a= nd a CAS realm. I'm new to shiro so maybe I was mistaken on some points. > I have a demo webapp with these files : > index.jsp > error.jsp > protected/index.jsp > The idea is to protect the /protected folder. I have this shiro.ini confi= guration : > [main] > authcas =3D org.apache.shiro.cas.CasFilter > authcas.failureUrl =3D /demo2/error.jsp > defaultRealm =3D com.jle.demo2.realm.DefaultRealm > defaultRealm.name =3D demo2 > defaultRealm.casServerUrlPrefix =3D http://localhost:11380/cas/ > defaultRealm.casService =3D http://localhost:11380/demo2/shiro-cas > roles.loginUrl =3D http://localhost:11380/cas/login?service=3Dhttp://loca= lhost:11380/demo2/shiro-cas > [urls] > /protected/** =3D roles[ROLE_USER] > /shiro-cas =3D authcas > /** =3D anon > The protection on /protected/** implies to have the role ROLE_USER, if it= is not the case, the user is redirected to the CAS server according to the= property loginUrl of roles : http://localhost:11380/cas/login?service=3Dht= tp://localhost:11380/demo2/shiro-cas. > After authentication on CAS server, the user is redirected (CAS works lik= e this) to the service url : http://localhost:11380/demo2/shiro-cas. On thi= s url, there is the authcas filter defined as the DefaultRealm which inheri= ts from CasRealm : > public class DefaultRealm extends CasRealm { > =20 > @Override > protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollectio= n principals) { > Set roles =3D new HashSet(); > roles.add("ROLE_USER"); > return new SimpleAuthorizationInfo(roles); > } > } > The DefaultRealm always grants the authenticated user the ROLE_USER role = to access to the /protected folder. > The CasFilter is configured on a specific url corresponding to the CAS ur= l service : http://localhost:11380/demo2/shiro-cas, it gets the service par= ameter in url and create a CasToken with it. > The CasRealm uses the CasToken to authenticate the user, it gets the serv= ice ticket, uses the Cas20ServiceTicketValidator (from CAS client) to call = the CAS server and validates the ticket granted by CAS. > If the ticket is validated, the user is authenticated and redirected to t= he original protected url (/protected/index.jsp). If the validation fails, = the user is redirected to the CAS error page (error.jsp =3D authcas.failure= Url). > To add CasFilter, CasToken and CasRealm to the trunk, I created a CAS mod= ule inside support. > * CasRealm : > I didn't find how to set the remember me to the subject : I know if the u= ser is in rememberme mode from CAS depending on a specific attribute from t= he Assertion object but I didn't know how to pass this information to the s= ubject (there is a TODO). > During the CAS service ticket validation, I get the object Assertion and = all the attributes of the user populated by CAS are in the "attributes" pro= perty : I don't know what to do with these attributes. > During the CAS service ticket validation, I choose not to throw an Authen= ticationException, but returns null instead : is it the good way to do ? > * CasFilter : > I'm not sure I respect the spirit of shiro because my filter authcas is a= lways the last one. I add on the onLoginFailure a test, if the user is alre= ady authenticated, it doesn't failed but redirects to default success url. > I didn't know how to add my authcas filter as a default filter without co= nfiguring it in the shiro.ini file. > I have no test yet. > I join the SVN patch. > Hope it works well for you. Don't hesitate to come back to me. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira