General Actions:
Log-in
Register
Wiki:
jguard
▼
:
Document Index
»
Space:
Doc
▼
:
Document Index
»
Page:
Servlets
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to the jGuard's wiki
»
jGuard Documentation
»
Integrate jGuard with Servlets and other
Wiki source code of
Integrate jGuard with Servlets and other
Last modified by RaffaelloPelagalli on 2007/01/29 22:13
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
1 Integrate jGuard with Servlets and other "web" classes (Struts Actions, etc.) 1.1 Getting the Subject Object * in __1.0.x__ release {code} HttpAuthenticationUtils auth= (HttpAuthenticationUtils)request.getSession(true).getAttribute(HttpConstants.AUTHN_UTILS); Subject subject = auth.getSubject(); {code} * in __0.80__ release {code} AuthenticationUtils authUtils = (AuthenticationUtils)request.getSession().getAttribute(HttpConstants.AUTH_UTILS); Subject subject = authUtils.getSubject(); {code} * in __0.70__ release {code} Subject subj = (Subject)request.getSession().getAttribute(HttpConstants.SUBJECT_ID); {code} * in release __prior to 0.70__ release: In releases __prior__ to jGuard 0.70, you can obtain the Subject with the following code ('Constants' is used instead of 'HttpConstants'): {code} Subject subj = (Subject)request.getSession().getAttribute(Constants.SUBJECT_ID); {code} 1.1 Getting the 'identity' credential the 'identity' credential is the credential(i.e user attribute) which identify uniquely the user. * in __1.0.x__ release {code} //get the Subject AuthenticationUtils authUtils = (AuthenticationUtils)request.getSession().getAttribute(HttpConstants.AUTH_UTILS); Subject subject = authUtils.getSubject(); //get the SubjectTemplate AuthenticationManager am = (AuthenticationManager) request.getSession().getServletContext().getAttribute(SecurityConstants.AUTHENTICATION_MANAGER); SubjectTemplate defaultTemplate = am.getDefaultSubjectTemplate(); JGuardCredential identityCredential = SubjectUtils.getIdentityCredential(subject,defaultTemplate); {code}
Menu
Overview
Documentation
Quick start
Architecture
jGuard on JEE
Reference doc
HTML
PDF
Step-by-step tutorial
HTML
PDF
MyEclipse tutorial
jGuard Maven Site
Download
Stable release
Beta release
FAQ
Others
jGuard on sf.net
Team
RoadMap
Logo Contest
Development
Forum
Links