RequestSecurityManagerImpl implements RequestSecurityManager { public LinkSecurity checkPageSecurity(String pageName) { if (!securityEnabled) { return request.isSecure() ? LinkSecurity.SECURE : LinkSecurity.INSECURE; } boolean securePage = isSecure(pageName); if (request.isSecure() == securePage) { return securePage ? LinkSecurity.SECURE : LinkSecurity.INSECURE; } return securePage ? LinkSecurity.FORCE_SECURE : LinkSecurity.FORCE_INSECURE; } RequestSecurityManagerImpl(Request request, Response response,
                                      ComponentEventLinkEncoder componentEventLinkEncoder, MetaDataLocator locator, @Symbol(SymbolConstants.SECURE_ENABLED)
    boolean securityEnabled); boolean checkForInsecureComponentEventRequest(ComponentEventRequestParameters parameters); boolean checkForInsecurePageRenderRequest(PageRenderRequestParameters parameters); LinkSecurity checkPageSecurity(String pageName);  }
@Test(dataProvider = "check_page_security_data") public void check_page_security(boolean secureRequest, boolean securePage, LinkSecurity expectedLinkSecurity) { Request request = mockRequest(); Response response = mockResponse(); MetaDataLocator locator = mockMetaDataLocator(); ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class); train_isSecure(request, secureRequest); train_isSecure(locator, PAGE_NAME, securePage); replay(); RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true); assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity); verify(); }
@Test(dataProvider = "security_disabled_data") public void link_security_when_security_is_disabled(boolean secureRequest, LinkSecurity expectedLinkSecurity) { Request request = mockRequest(); Response response = mockResponse(); MetaDataLocator locator = mockMetaDataLocator(); train_isSecure(request, secureRequest); replay(); RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, null, locator, false); assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity); verify(); }