[Security & JAAS/JBoss] - Re: JAAS doAs()
by danlee
I am happy to report that my "quick & dirty" implementation of the custom JBoss client login module and doAs() works like a charm. My implementation is based on the JBoss source code and comprises of mainly two classes: MyClientLoginModule and MySecurityAssociation. MyClientLoginModule is the new client login module that replaces the original ClientLoginModule in the JAAS configuration. MySecurityAssociation complements the original SecurityAssociation class with the new doAs() implementation.
- I tried to create the cache for cridentials in the new login module, but it didn't work when the doAs() was called in the server side. Our server seems to login only once and reuse the same subject over and over again. However, in some of the server threads, the cridential cache doesn't get copied; copying of the cridential cache is supposed to work only in the child threads, but some of our threads may not be a direct child, but independent. Anyway, I ended up caching the cridential in the subject itself. This is somewhat risky when the cridential is a clear text password.
- The JBoss doAs() simply calls the JBoss pushSubjectContext with the criential before the Subject.doAs() call and it calls the JBoss popSubjectContext afterwards.
This should be something that RedHat/JBoss could easily implement. I am not sure why it should be done by the user.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994322#3994322
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994322
19 years, 4 months
[JBoss Seam] - Re: Referencing global view-id variables from .jpdl.xml
by spambob
Thanks Gavin, now it's working like a charm :)
In case anyone is interested my solution is the following:
package com.example.usecases.web;
|
| import java.io.File;
| import java.util.HashMap;
| import java.util.Iterator;
|
| import javax.faces.context.FacesContext;
| import javax.servlet.ServletContext;
|
| import org.dom4j.Document;
| import org.dom4j.DocumentException;
| import org.dom4j.Element;
| import org.dom4j.io.SAXReader;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.core.Pageflow;
| import org.jboss.seam.pageflow.Page;
|
| @Name("org.jboss.seam.core.pageflow")
| public class MyPageflow extends Pageflow {
|
| private static final long serialVersionUID = -7905951040207871423L;
| private static HashMap<String, String> viewMap = null;
|
| @In(value = "org.jboss.seam.core.facesContext", required = false)
| private FacesContext facesContext;
|
| @Override
| protected String getViewId(Page page) {
| if(!page.getViewId().startsWith("/") && facesContext != null) {
| if(viewMap == null) {
| viewMap = createViewMap(((ServletContext) facesContext.getExternalContext().getContext()).getRealPath(""));
| }
| return viewMap.get(page.getViewId());
| }
| return super.getViewId(page);
| }
|
| private HashMap<String, String> createViewMap(String realPathPrefix) {
| String[] configFiles = {
| "WEB-INF" + File.separator + "faces-config.xml",
| "WEB-INF" + File.separator + "navigation.xml" };
| HashMap<String, String> viewMap = new HashMap<String, String>();
| for (int i = 0; i < configFiles.length; i++) {
| Document doc = null;
| File file = null;
| try {
| file = new File(realPathPrefix + File.separator + configFiles[ i ]);
| doc = new SAXReader().read(file);
| } catch (DocumentException e) {
| System.out.println("Can't read navigation rules from file: " + file.getAbsolutePath());
| continue;
| }
| Element rootElement = doc.getRootElement();
| Iterator rootIterator = rootElement.elementIterator("navigation-rule");
| while (rootIterator.hasNext()) {
| Element element = (Element) rootIterator.next();
| if (element.element("from-view-id") == null
| || element.element("from-view-id").getText().equals("*")) {
| Element navigationCase = element.element("navigation-case");
| viewMap.put(navigationCase.element("from-outcome").getText(),
| navigationCase.element("to-view-id").getText());
| }
| }
| }
| return viewMap;
| }
| }
The only drawback is that the path on the filesystem is read from the servletcontext - therefore it doesn't work upon first request.
If someone knows a more elegant solution i would be glad to hear it ;)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994319#3994319
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994319
19 years, 4 months