1 9 package org.jboss.portlet; 10 11 import java.util.Map ; 12 import java.util.Set ; 13 14 import javax.portlet.PortletPreferences; 15 import javax.servlet.http.HttpServletRequest ; 16 17 import org.jboss.portal.core.impl.user.UserContextImpl; 18 import org.jboss.portal.core.model.User; 19 import org.jboss.portal.core.plugins.preferences.ProxyPreferenceSetPlugin; 20 import org.jboss.portal.core.plugins.security.ModelPlugin; 21 import org.jboss.portal.core.security.AuthorizationRealm; 22 import org.jboss.portal.core.security.NullAuthorizationRealm; 23 import org.jboss.portal.core.security.ModelAuthorizationRealm; 24 import org.jboss.portal.core.util.Parameters; 25 import org.jboss.portal.core.CoreConstants; 26 import org.jboss.portal.portlet.impl.ActionRequestImpl; 27 import org.jboss.portal.server.Component; 28 import org.jboss.portal.server.PortalRequest; 29 import org.jboss.portal.server.PortalResponse; 30 import org.jboss.portal.server.Window; 31 import org.jboss.portal.server.WindowContext; 32 import org.jboss.portal.server.PortalServer; 33 import org.jboss.portal.server.user.UserContext; 34 35 39 public class JBossActionRequest extends ActionRequestImpl 40 { 41 42 43 private AuthorizationRealm realm; 44 45 46 private Parameters parameters; 47 48 public JBossActionRequest(UserContext userContext, 49 PortletPreferences preferences, 50 Window window, 51 WindowContext windowCtx, 52 PortalRequest req, 53 PortalResponse resp, 54 HttpServletRequest dreq) 55 { 56 super(userContext, preferences, window, windowCtx, req, resp, dreq); 57 this.realm = null; 58 this.parameters = null; 59 } 60 61 64 public Map getInformations() 65 { 66 return userContext.getInformations(); 67 } 68 69 72 public User getUser() 73 { 74 return ((UserContextImpl)userContext).getUser(); 75 } 76 77 public Parameters getParameters() 78 { 79 if (parameters == null) 80 { 81 parameters = new Parameters(getParameterMap()); 82 } 83 return parameters; 84 } 85 86 public Boolean getIdempotent() 87 { 88 return req.getIdempotent(); 89 } 90 91 public void setIdempotent(Boolean idempotent) 92 { 93 req.setIdempotent(idempotent); 94 } 95 96 private Set getRoleNames() 97 { 98 User user = getUser(); 99 if (user == null) 100 { 101 return AuthorizationRealm.ANONYMOUS_ROLE_SET; 102 } 103 else 104 { 105 return user.getRoleNames(); 106 } 107 } 108 109 112 public boolean hasPermission(String domain, String permission) 113 { 114 return getAuthorizationRealm().hasPermission(domain, getRoleNames(), permission); 115 } 116 117 120 public boolean hasPermission(String permission) 121 { 122 return getAuthorizationRealm().hasPermission(getRoleNames(), permission); 123 } 124 125 128 public boolean hasPermission(String domain, String [] path, String permission) 129 { 130 return getAuthorizationRealm().hasPermission(domain, getRoleNames(), path, permission); 131 } 132 133 136 public boolean hasPermission(String [] path, String permission) 137 { 138 return getAuthorizationRealm().hasPermission(getRoleNames(), path, permission); 139 } 140 141 protected PortletPreferences createPreferences() 142 { 143 Component container = instance.getComponent(); 144 ProxyPreferenceSetPlugin plugin = (ProxyPreferenceSetPlugin)container.getPlugin("PROXY"); 145 if (plugin != null) 146 { 147 } 155 return null; 156 } 157 158 161 public AuthorizationRealm getAuthorizationRealm() 162 { 163 if (realm == null) 164 { 165 ModelPlugin plugin = (ModelPlugin)component.getPlugin(CoreConstants.REALM_KEY); 166 if (plugin != null) 167 { 168 realm = new ModelAuthorizationRealm(plugin, plugin.getSchemeStore()); 169 } 170 } 171 if (realm == null) 172 { 173 realm = NullAuthorizationRealm.instance; 174 } 175 return realm; 176 } 177 178 182 public PortalServer getServer() 183 { 184 return window.getServer(); 185 } 186 187 190 public void signOut() 191 { 192 req.getSession().invalidate(); 193 } 194 } 195 | Popular Tags |