本文整理汇总了Java中javax.portlet.PortletSecurityException类的典型用法代码示例。如果您正苦于以下问题:Java PortletSecurityException类的具体用法?Java PortletSecurityException怎么用?Java PortletSecurityException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PortletSecurityException类属于javax.portlet包,在下文中一共展示了PortletSecurityException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: portletModeMappingViewRenderRequestWithUnauthorizedUserRole
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Test
public void portletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
request.setPortletMode(PortletMode.VIEW);
request.addUserRole("role3");
request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.doDispatch(request, response);
Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception");
assertNotNull(exception);
assertTrue(exception.getClass().equals(PortletSecurityException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("failed-default-1", view.getBeanName());
}
示例2: testUnauthorizedUser
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void testUnauthorizedUser() throws Exception {
UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
String validRole = "allowed";
interceptor.setAuthorizedRoles(new String[] {validRole});
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
Object handler = new Object();
request.addUserRole("someOtherRole");
assertFalse(request.isUserInRole(validRole));
try {
interceptor.preHandle(request, response, handler);
fail("should have thrown PortletSecurityException");
}
catch (PortletSecurityException ex) {
// expected
}
}
示例3: testRequestWithNoUserRoles
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void testRequestWithNoUserRoles() throws Exception {
UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
String validRole = "allowed";
interceptor.setAuthorizedRoles(new String[] {validRole});
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
Object handler = new Object();
assertFalse(request.isUserInRole(validRole));
try {
interceptor.preHandle(request, response, handler);
fail("should have thrown PortletSecurityException");
}
catch (PortletSecurityException ex) {
// expected
}
}
示例4: unauthorizedUser
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Test(expected = PortletSecurityException.class)
public void unauthorizedUser() throws Exception {
String validRole = "allowed";
interceptor.setAuthorizedRoles(new String[] {validRole});
request.addUserRole("someOtherRole");
assertFalse(request.isUserInRole(validRole));
interceptor.preHandle(request, response, new Object());
}
示例5: requestWithNoUserRoles
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Test(expected = PortletSecurityException.class)
public void requestWithNoUserRoles() throws Exception {
String validRole = "allowed";
interceptor.setAuthorizedRoles(new String[] {validRole});
assertFalse(request.isUserInRole(validRole));
interceptor.preHandle(request, response, new Object());
}
示例6: portletModeMappingEditActionRequestWithUnauthorizedUserRole
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Test
public void portletModeMappingEditActionRequestWithUnauthorizedUserRole() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setPortletMode(PortletMode.EDIT);
request.addUserRole("role3");
request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.processAction(request, response);
String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
assertNotNull(exception);
String name = PortletSecurityException.class.getName();
assertTrue(exception.startsWith(name));
}
示例7: processAction
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Override
public void processAction(ActionRequest req, ActionResponse res) throws PortletException, PortletSecurityException, IOException
{
Application.setInPortalServer(true);
try
{
super.processAction(req, res);
}
finally
{
Application.setInPortalServer(false);
}
}
示例8: render
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Override
public void render(RenderRequest req, RenderResponse res) throws PortletException, PortletSecurityException, IOException
{
Application.setInPortalServer(true);
try
{
super.render(req, res);
}
finally
{
Application.setInPortalServer(false);
}
}
示例9: testInterceptorWithNoAuthorizedRoles
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void testInterceptorWithNoAuthorizedRoles() throws Exception {
UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
Object handler = new Object();
request.addUserRole("someRole");
try {
interceptor.preHandle(request, response, handler);
fail("should have thrown PortletSecurityException");
}
catch (PortletSecurityException ex) {
// expected
}
}
示例10: testPortletModeMappingEditActionRequestWithUnauthorizedUserRole
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void testPortletModeMappingEditActionRequestWithUnauthorizedUserRole() throws Exception {
MockActionRequest request = new MockActionRequest();
MockActionResponse response = new MockActionResponse();
request.setPortletMode(PortletMode.EDIT);
request.addUserRole("role3");
request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.processAction(request, response);
String exception = response.getRenderParameter(DispatcherPortlet.ACTION_EXCEPTION_RENDER_PARAMETER);
assertNotNull(exception);
String name = PortletSecurityException.class.getName();
assertTrue(exception.startsWith(name));
}
示例11: testPortletModeMappingViewRenderRequestWithUnauthorizedUserRole
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void testPortletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
MockRenderRequest request = new MockRenderRequest();
MockRenderResponse response = new MockRenderResponse();
request.setPortletMode(PortletMode.VIEW);
request.addUserRole("role3");
request.setParameter("action", "not mapped");
request.setParameter("myParam", "not mapped");
complexDispatcherPortlet.doDispatch(request, response);
Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
Exception exception = (Exception) model.get("exception");
assertNotNull(exception);
assertTrue(exception.getClass().equals(PortletSecurityException.class));
InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
assertEquals("failed-default-1", view.getBeanName());
}
示例12: handleSecureFlag
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
/**
* Sets the secure flag on the URl as required
*
* @throws JspException
*/
protected void handleSecureFlag() throws JspException {
BaseURL url = getUrl();
if (secure != null && !secure.equalsIgnoreCase("true") && !secure.equalsIgnoreCase("false")) {
StringBuilder txt = new StringBuilder(128);
txt.append("Invalid secure option: ").append(secure);
txt.append(", valid options: true, false");
throw new JspException(txt.toString());
}
if(url == null){
throw new IllegalStateException("internal error: url not set");
}
if (var != null) {
pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
}
if (secure != null) {
try {
url.setSecure(isSecure());
} catch (PortletSecurityException e) {
// ignore exception as Pluto doesn't support setSecure
// throw new JspException(e);
}
}
}
示例13: interceptorWithNoAuthorizedRoles
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Test(expected = PortletSecurityException.class)
public void interceptorWithNoAuthorizedRoles() throws Exception {
request.addUserRole("someRole");
interceptor.preHandle(request, response, new Object());
}
示例14: setSecure
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
@Override
public void setSecure(boolean secure) throws PortletSecurityException {
this.secure = secure;
}
示例15: setSecure
import javax.portlet.PortletSecurityException; //导入依赖的package包/类
public void setSecure(boolean secure) throws PortletSecurityException {
this.secure = secure;
}