You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2011/04/01 18:42:42 UTC
svn commit: r1087796 [26/37] - in /incubator/rave/donations/mitre-osec: ./
conf/ db/ db/data/ db/sequences/ db/tables/ lib/ lib/apache-commons/
lib/apache-taglibs/ lib/build/ lib/build/cobertura/ lib/eclipselink/
lib/freemarker/ lib/google-collections/...
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/RepositoryControllerTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/WizardControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/WizardControllerTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/WizardControllerTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/WizardControllerTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletRequest;
+import org.mitre.portal.web.model.JsonRpcResult;
+import org.mitre.portal.web.util.ModelKeys;
+import org.mitre.portal.service.exception.WizardNotFoundException;
+import org.mitre.portal.web.util.ViewNames;
+import org.mitre.portal.model.UserWizardCompleted;
+import org.mitre.portal.model.Wizard;
+import org.springframework.ui.ExtendedModelMap;
+import org.mitre.portal.model.Person;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.mitre.portal.security.UserService;
+import org.mitre.portal.service.WizardService;
+import org.springframework.ui.Model;
+import static org.easymock.EasyMock.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class WizardControllerTest {
+
+ private WizardController wizardController;
+ private WizardService wizardService;
+ private UserService userService;
+ private HttpServletRequest request;
+ private HttpSession session;
+
+ private Person user;
+ private Model model;
+ private Wizard validWizard;
+ private Wizard invalidWizard;
+ private List<Wizard> nonCompletedWizardList;
+
+ private final Long VALID_WIZARD_ID = 1L;
+ private final Long INVALID_WIZARD_ID = -1L;
+
+ @Before
+ public void setup() {
+ request = createNiceMock(HttpServletRequest.class);
+ session = createNiceMock(HttpSession.class);
+ wizardService = createNiceMock(WizardService.class);
+ userService = createNiceMock(UserService.class);
+ wizardController = new WizardController(wizardService, userService);
+
+ user = new Person();
+ user.setUserId("100");
+
+ model = new ExtendedModelMap();
+ validWizard = new Wizard(VALID_WIZARD_ID);
+ invalidWizard = new Wizard(INVALID_WIZARD_ID);
+
+ nonCompletedWizardList = new ArrayList<Wizard>();
+ nonCompletedWizardList.add(validWizard);
+ }
+
+
+ @Test
+ public void saveUserWizardCompleted_validWizardId_validModel() throws WizardNotFoundException {
+ UserWizardCompleted ucw = new UserWizardCompleted();
+ ucw.setUserId(user.getUserId());
+ ucw.setWizard(validWizard);
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(wizardService.getWizard(VALID_WIZARD_ID)).andReturn(validWizard);
+ wizardService.save(ucw);
+ expectLastCall();
+ expect(request.getSession()).andReturn(session);
+ expect(session.getAttribute(ModelKeys.NONCOMPLETED_WIZARDS)).andReturn(nonCompletedWizardList);
+ session.removeAttribute(ModelKeys.NONCOMPLETED_WIZARDS);
+ expectLastCall();
+ replay(userService);
+ replay(wizardService);
+ replay(request);
+ replay(session);
+
+ String viewName = wizardController.saveUserWizardCompleted(VALID_WIZARD_ID, model, request);
+
+ assertEquals(ViewNames.JSON, viewName);
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = (JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertTrue(result.isResult());
+ }
+
+ @Test
+ public void saveUserWizardCompleted_validWizardId_validModel_multipleNonCompletedWizards() throws WizardNotFoundException {
+ nonCompletedWizardList.add(new Wizard(2L));
+
+ UserWizardCompleted ucw = new UserWizardCompleted();
+ ucw.setUserId(user.getUserId());
+ ucw.setWizard(validWizard);
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(wizardService.getWizard(VALID_WIZARD_ID)).andReturn(validWizard);
+ wizardService.save(ucw);
+ expectLastCall();
+ expect(request.getSession()).andReturn(session);
+ expect(session.getAttribute(ModelKeys.NONCOMPLETED_WIZARDS)).andReturn(nonCompletedWizardList);
+ replay(userService);
+ replay(wizardService);
+ replay(request);
+ replay(session);
+
+ String viewName = wizardController.saveUserWizardCompleted(VALID_WIZARD_ID, model, request);
+
+ assertEquals(ViewNames.JSON, viewName);
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = (JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertTrue(result.isResult());
+ }
+
+ @Test
+ public void saveUserWizardCompleted_validWizardId_validModel_nullNonCompletedWizardList() throws WizardNotFoundException {
+ UserWizardCompleted ucw = new UserWizardCompleted();
+ ucw.setUserId(user.getUserId());
+ ucw.setWizard(validWizard);
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(wizardService.getWizard(VALID_WIZARD_ID)).andReturn(validWizard);
+ wizardService.save(ucw);
+ expectLastCall();
+ expect(request.getSession()).andReturn(session);
+ expect(session.getAttribute(ModelKeys.NONCOMPLETED_WIZARDS)).andReturn(null);
+ replay(userService);
+ replay(wizardService);
+ replay(request);
+ replay(session);
+
+ String viewName = wizardController.saveUserWizardCompleted(VALID_WIZARD_ID, model, request);
+
+ assertEquals(ViewNames.JSON, viewName);
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = (JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertTrue(result.isResult());
+ }
+
+ @Test
+ public void saveUserWizardCompleted_invalidWizardId_validModel() throws WizardNotFoundException {
+ UserWizardCompleted ucw = new UserWizardCompleted();
+ ucw.setUserId(user.getUserId());
+ ucw.setWizard(invalidWizard);
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(wizardService.getWizard(INVALID_WIZARD_ID)).andThrow(new WizardNotFoundException(INVALID_WIZARD_ID));
+ replay(userService);
+ replay(wizardService);
+
+ String viewName = wizardController.saveUserWizardCompleted(INVALID_WIZARD_ID, model, request);
+
+ assertEquals(ViewNames.JSON, viewName);
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = (JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertFalse(result.isResult());
+ }
+
+ @Test
+ public void saveUserWizardCompleted_validWizardId_validModel_runtimeException() throws WizardNotFoundException {
+ UserWizardCompleted ucw = new UserWizardCompleted();
+ ucw.setUserId(user.getUserId());
+ ucw.setWizard(validWizard);
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(wizardService.getWizard(VALID_WIZARD_ID)).andThrow(new RuntimeException("error"));
+ replay(userService);
+ replay(wizardService);
+
+ String viewName = wizardController.saveUserWizardCompleted(VALID_WIZARD_ID, model, request);
+
+ assertEquals(ViewNames.JSON, viewName);
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = (JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertFalse(result.isResult());
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/controller/WizardControllerTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/CommonModelHandlerInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/CommonModelHandlerInterceptorTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/CommonModelHandlerInterceptorTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/CommonModelHandlerInterceptorTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mitre.portal.model.Container;
+import org.mitre.portal.model.Page;
+import org.mitre.portal.model.PageLayout;
+import org.mitre.portal.model.Person;
+import org.mitre.portal.model.Region;
+import org.mitre.portal.security.UserService;
+import org.mitre.portal.service.PageService;
+
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.*;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.servlet.ModelAndView;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class CommonModelHandlerInterceptorTest {
+ private final String VALID_VIEW_NAME = "TEST";
+ private String expectedContainerUrl;
+
+ private MockHttpServletRequest request;
+ private MockHttpServletResponse response;
+ private CommonModelHandlerInterceptor commonModelHandlerInterceptor;
+ private ModelAndView modelAndView;
+ private Object handler;
+
+ private PageService pageService;
+ private UserService userService;
+ private Container container;
+ private Person user;
+ private Page page;
+ private PageLayout pageLayout;
+ private List<Region> regionList;
+ private Region region;
+
+ // test data
+ private final Long VALID_CONTAINER_ID = 1L;
+ private final String VALID_USER_ID = "acarlucci";
+ private final Long VALID_PAGE_ID = 2L;
+ private final String VALID_PAGE_NAME = "test page";
+ private final String VALID_REGION_NAME = "region_1";
+ private final Long VALID_REGION_ID = 7L;
+ private final String VALID_LAYOUT_NAME = "layout_1";
+ private final Long VALID_PAGE_LAYOUT_ID = 3L;
+ private final Long VALID_NUM_REGIONS = 1L;
+ private final String VALID_LAYOUT_DISPLAY_NAME = "Three Cols";
+ private final Long VALID_LAYOUT_RENDER_SEQ = 1L;
+
+
+ @Before
+ public void setup() {
+ user = new Person();
+ user.setUsername(VALID_USER_ID);
+
+ pageLayout = new PageLayout();
+ pageLayout.setLayoutName(VALID_LAYOUT_NAME);
+ pageLayout.setPageLayoutId(VALID_PAGE_LAYOUT_ID);
+ pageLayout.setNumRegions(VALID_NUM_REGIONS);
+ pageLayout.setDisplayName(VALID_LAYOUT_DISPLAY_NAME);
+ pageLayout.setRenderSeq(VALID_LAYOUT_RENDER_SEQ);
+
+ region = new Region(VALID_REGION_ID);
+ region.setName(VALID_REGION_NAME);
+ regionList = new ArrayList<Region>();
+ regionList.add(region);
+
+ page = new Page(VALID_PAGE_ID);
+ page.setPageLayout(pageLayout);
+ page.setName(VALID_PAGE_NAME);
+ page.setRegionList(regionList);
+
+ request = new MockHttpServletRequest();
+ response = new MockHttpServletResponse();
+ container = new Container(VALID_CONTAINER_ID);
+ pageService = createNiceMock(PageService.class);
+ userService = createNiceMock(UserService.class);
+
+ commonModelHandlerInterceptor = new CommonModelHandlerInterceptor(pageService, userService, container);
+ modelAndView = new ModelAndView();
+ handler = new Object();
+
+ expectedContainerUrl = request.getScheme() + "://" + request.getServerName();
+ if (request.getServerPort() != -1)
+ expectedContainerUrl += ":" + request.getServerPort();
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_validModelAndView() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(pageService.findDefaultPage(container, user)).andReturn(page);
+ replay(pageService);
+
+ modelAndView.setViewName(VALID_VIEW_NAME);
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ ModelMap modelMap = modelAndView.getModelMap();
+ assertNotNull(modelMap);
+ assertTrue(modelMap.containsKey(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ assertEquals(expectedContainerUrl, modelMap.get(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_validJsonModelAndView() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(pageService.findDefaultPage(container, user)).andReturn(page);
+ replay(pageService);
+
+ modelAndView.setViewName(ViewNames.JSON);
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ ModelMap modelMap = modelAndView.getModelMap();
+ assertNotNull(modelMap);
+ assertFalse(modelMap.containsKey(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_nullJsonModelAndView() throws Exception {
+ modelAndView = null;
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_validModelAndViewContainsLastVisitedPage() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(pageService.findDefaultPage(container, user)).andReturn(page);
+ replay(pageService);
+
+ modelAndView.setViewName(VALID_VIEW_NAME);
+ modelAndView.getModel().put(ModelKeys.LAST_VISITED_PAGE_ID, VALID_PAGE_ID);
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ ModelMap modelMap = modelAndView.getModelMap();
+ assertNotNull(modelMap);
+ assertTrue(modelMap.containsKey(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ assertEquals(expectedContainerUrl, modelMap.get(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_validModelAndView_sessionLastVisitedPageId() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(pageService.findDefaultPage(container, user)).andReturn(page);
+ replay(pageService);
+
+ modelAndView.setViewName(VALID_VIEW_NAME);
+ request.getSession().setAttribute("lastVisitedPageId", VALID_PAGE_ID);
+
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ ModelMap modelMap = modelAndView.getModelMap();
+ assertNotNull(modelMap);
+ assertTrue(modelMap.containsKey(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ assertEquals(expectedContainerUrl, modelMap.get(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+
+ }
+
+ @Test
+ public void postHandle_validRequest_validResponse_validHandler_validModelAndView_serverPortNegativeOne() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(pageService.findDefaultPage(container, user)).andReturn(page);
+ replay(pageService);
+
+ modelAndView.setViewName(VALID_VIEW_NAME);
+
+ request.setServerPort(-1);
+ expectedContainerUrl = request.getScheme() + "://" + request.getServerName();
+
+ commonModelHandlerInterceptor.postHandle(request, response, handler, modelAndView);
+ ModelMap modelMap = modelAndView.getModelMap();
+ assertNotNull(modelMap);
+ assertTrue(modelMap.containsKey(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+ assertEquals(expectedContainerUrl, modelMap.get(ModelKeys.CONTAINER_HOST_AND_PORT_URL));
+
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/CommonModelHandlerInterceptorTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/DefaultExceptionHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/DefaultExceptionHandlerTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/DefaultExceptionHandlerTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/DefaultExceptionHandlerTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.util;
+
+import java.net.MalformedURLException;
+import org.mitre.portal.model.Container;
+import org.mitre.portal.security.SecurityTokenService;
+import org.mitre.portal.security.UserService;
+import org.mitre.portal.service.GadgetService;
+import org.mitre.portal.service.PageService;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.springframework.web.servlet.ModelAndView;
+import static org.easymock.EasyMock.*;
+import org.mitre.portal.service.MetricsLoggingService;
+import org.mitre.portal.web.controller.PageController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+@ContextConfiguration(locations={"classpath:org/mitre/portal/system-test-config.xml"})
+public class DefaultExceptionHandlerTest extends AbstractJUnit4SpringContextTests {
+
+ @Autowired
+ private DefaultExceptionHandler defaultExceptionHandler;
+ private HttpServletRequest mockRequest;
+ private HttpServletResponse mockResponse;
+ private Object handler;
+ private AccessDeniedException accessDeniedException;
+ private RuntimeException runtimeException;
+
+ private PageService pageService;
+ private GadgetService gadgetService;
+ private UserService userService;
+ private MetricsLoggingService metricsLoggingService;
+ private SecurityTokenService securityTokenService;
+
+ private Container container;
+
+ @Before
+ public void setup() throws MalformedURLException {
+ mockRequest = createNiceMock(HttpServletRequest.class);
+ mockResponse = createNiceMock(HttpServletResponse.class);
+ pageService = createNiceMock(PageService.class);
+ gadgetService = createNiceMock(GadgetService.class);
+ metricsLoggingService = createNiceMock(MetricsLoggingService.class);
+ userService = createNiceMock(UserService.class);
+ securityTokenService = createNiceMock(SecurityTokenService.class);
+
+ container = new Container(1L);
+ accessDeniedException = new AccessDeniedException("error");
+ runtimeException = new RuntimeException("error");
+ handler = new PageController(pageService, gadgetService, userService, securityTokenService, metricsLoggingService, container);
+ }
+
+ @Test
+ public void resolveException_AccessDeniedException_validAccessDeniedView() {
+ ModelAndView modelAndView = defaultExceptionHandler.resolveException(mockRequest, mockResponse, handler, accessDeniedException);
+ assertNotNull(modelAndView);
+ assertEquals(modelAndView.getViewName(), ViewNames.Error.ACCESS_DENIED);
+ }
+
+ @Test
+ public void resolveException_RuntimeException_validDefaultErrorView() {
+ ModelAndView modelAndView = defaultExceptionHandler.resolveException(mockRequest, mockResponse, handler, runtimeException);
+ assertNotNull(modelAndView);
+ assertEquals(modelAndView.getViewName(), ViewNames.Error.DEFAULT);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/DefaultExceptionHandlerTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalAuthenticationFilterTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalAuthenticationFilterTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalAuthenticationFilterTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalAuthenticationFilterTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.util;
+
+import java.util.ArrayList;
+import org.mitre.portal.model.Wizard;
+import java.util.List;
+import org.mitre.portal.model.Person;
+import javax.servlet.http.HttpSession;
+import org.mitre.portal.service.WizardService;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.security.core.Authentication;
+import static org.easymock.EasyMock.*;
+
+/**
+ *
+ * @author ACARLUCCI
+ */
+public class PortalAuthenticationFilterTest {
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private WizardService wizardService;
+ private HttpSession session;
+ private Authentication authResult;
+ private PortalAuthenticationFilter portalAuthenticationFilter;
+ private Person person;
+ private List<Wizard> wizardList;
+
+ @Before
+ public void setup() {
+ person = new Person();
+ person.setUserId("100");
+
+ wizardList = new ArrayList<Wizard>();
+ wizardList.add(new Wizard());
+
+ request = createNiceMock(HttpServletRequest.class);
+ response = createNiceMock(HttpServletResponse.class);
+ session = createNiceMock(HttpSession.class);
+ authResult = createNiceMock(Authentication.class);
+ wizardService = createNiceMock(WizardService.class);
+
+ portalAuthenticationFilter = new PortalAuthenticationFilter(wizardService);
+ }
+
+ @Test
+ public void successfulAuthentication_validRequest_validResponse_validAuthResult() {
+ expect(request.getSession()).andReturn(session);
+ expect(authResult.getPrincipal()).andReturn(person);
+ expect(wizardService.findNonCompletedWizardsByUser(person)).andReturn(wizardList);
+ session.setAttribute(ModelKeys.NONCOMPLETED_WIZARDS, wizardList);
+ expectLastCall();
+ replay(request);
+ replay(authResult);
+ replay(wizardService);
+ replay(session);
+
+ portalAuthenticationFilter.successfulAuthentication(request, response, authResult);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalAuthenticationFilterTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalMappingJacksonJsonViewTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalMappingJacksonJsonViewTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalMappingJacksonJsonViewTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalMappingJacksonJsonViewTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+
+public class PortalMappingJacksonJsonViewTest {
+ private PortalMappingJacksonJsonView portalMappingJacksonJsonView;
+
+ @Before
+ public void setup() {
+ portalMappingJacksonJsonView = new PortalMappingJacksonJsonView();
+ }
+
+ @Test
+ public void filterModel_mapWithMultipleObjects_validMap() {
+ Map<String, Object> model = new HashMap<String, Object>();
+ model.put("obj1", new Object());
+ model.put("obj2", new Object());
+
+ Object result = portalMappingJacksonJsonView.filterModel(model);
+ assertEquals(model, result);
+ }
+
+ @Test
+ public void filterModel_mapWithSingleObject_validObject() {
+ Map<String, Object> model = new HashMap<String, Object>();
+ Object obj1 = new Object();
+ model.put("obj1", obj1);
+
+ Object result = portalMappingJacksonJsonView.filterModel(model);
+ assertEquals(obj1, result);
+ }
+
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/util/PortalMappingJacksonJsonViewTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/GadgetSearchWebServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/GadgetSearchWebServiceTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/GadgetSearchWebServiceTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/GadgetSearchWebServiceTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.webservice;
+
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.mitre.portal.model.Container;
+import org.mitre.portal.model.ContainerRegistry;
+import org.mitre.portal.model.GadgetAudience;
+import org.mitre.portal.model.GadgetRating;
+import org.mitre.portal.model.Person;
+import org.mitre.portal.model.util.GadgetStatistics;
+import org.mitre.portal.security.UserService;
+import org.mitre.portal.service.ContainerService;
+import org.mitre.portal.service.GadgetService;
+import org.mitre.portal.service.StatisticsService;
+import org.mitre.portal.service.exception.GadgetNotFoundException;
+import org.mitre.portal.web.util.ModelKeys;
+import org.mitre.portal.web.util.ViewNames;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+public class GadgetSearchWebServiceTest {
+ private ContainerService containerService;
+ private GadgetService gadgetService;
+ private Container container;
+ private UserService userService;
+ private List<ContainerRegistry> containerRegistryList;
+ private HttpServletResponse mockServletResponse;
+ private GadgetSearchWebService gadgetSearchWebService;
+ private StatisticsService statisticsService;
+
+
+ // test data
+ private final Long VALID_CONTAINER_ID = 1L;
+ private final Long VALID_GADGET_ID = 1L;
+ private final String INVALID_QUERY_STRING = "#$%&";
+ private final String VALID_QUERY_STRING = "mitre";
+ private final String VALID_TAG_NAME = "news";
+ private final String INVALID_TAG_NAME = "QQQQQQ";
+ private final Long VALID_AUDIENCE_ID = 1L;
+ private final Long INVALID_AUDIENCE_ID = -999L;
+ private final String VALID_USER_ID = "28063";
+
+ private Person user;
+ private Map<String, GadgetStatistics> gadgetRatings;
+
+ private GadgetAudience validGadgetAudience;
+ private GadgetAudience invalidGadgetAudience;
+
+ @Before
+ public void setup() {
+ user = new Person();
+ user.setUsername(VALID_USER_ID);
+ user.setUserId(VALID_USER_ID);
+
+ gadgetRatings = new HashMap<String, GadgetStatistics>();
+
+ container = new Container(VALID_CONTAINER_ID);
+ mockServletResponse = createNiceMock(HttpServletResponse.class);
+ containerService = createNiceMock(ContainerService.class);
+ gadgetService = createNiceMock(GadgetService.class);
+ statisticsService = createNiceMock(StatisticsService.class);
+ userService = createNiceMock(UserService.class);
+
+ containerRegistryList = new ArrayList<ContainerRegistry>();
+ containerRegistryList.add(new ContainerRegistry());
+
+ gadgetSearchWebService = new GadgetSearchWebService(container, containerService, gadgetService, statisticsService, userService);
+ validGadgetAudience = new GadgetAudience(VALID_AUDIENCE_ID);
+ invalidGadgetAudience = new GadgetAudience(INVALID_AUDIENCE_ID);
+
+ }
+
+
+ @Test
+ public void getGadgetByTitleOrDesc_validQueryString() throws Exception {
+ expect(containerService.findByGadgetTitleOrDesc(container, VALID_QUERY_STRING)).andReturn(containerRegistryList);
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+ replay(userService);
+ replay(containerService);
+ assertNotNull(user);
+ assertNotNull(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList));
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getByGadgetTitleOrDesc(VALID_QUERY_STRING, model, mockServletResponse);
+
+ assertTrue(model.asMap().size() == 4);
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_REPOSITORY_LIST));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TYPE));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_STRING));
+ assertTrue(model.asMap().containsKey(ModelKeys.ALL_GADGET_STATISTICS));
+ assertEquals(VALID_QUERY_STRING, ((String)model.asMap().get(ModelKeys.GADGET_SEARCH_STRING)));
+ }
+
+ @Test
+ public void getGadgetsByTag_validGadgetTag() throws Exception {
+ expect(containerService.findByTagName(container, VALID_TAG_NAME)).andReturn(containerRegistryList);
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+ replay(userService);
+ replay(containerService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetsByTag(VALID_TAG_NAME, model, mockServletResponse);
+
+ assertEquals(4, model.asMap().size());
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_REPOSITORY_LIST));
+ List<ContainerRegistry> list = (List<ContainerRegistry>) model.asMap().get(ModelKeys.GADGET_REPOSITORY_LIST);
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TYPE));
+ assertEquals("tagName", (String)model.asMap().get(ModelKeys.GADGET_SEARCH_TYPE));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TAGNAME));
+ assertEquals(VALID_TAG_NAME, ((String)model.asMap().get(ModelKeys.GADGET_SEARCH_TAGNAME)));
+ }
+
+ @Test
+ public void getGadgetsByTag_invalidGadgetTag() throws Exception {
+ expect(containerService.findByTagName(container, INVALID_TAG_NAME)).andReturn(new ArrayList<ContainerRegistry>());
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+ replay(userService);
+ replay(containerService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetsByTag(INVALID_TAG_NAME, model, mockServletResponse);
+
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_REPOSITORY_LIST));
+ List<ContainerRegistry> list = (List<ContainerRegistry>) model.asMap().get(ModelKeys.GADGET_REPOSITORY_LIST);
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TYPE));
+ assertEquals("tagName", (String)model.asMap().get(ModelKeys.GADGET_SEARCH_TYPE));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TAGNAME));
+ assertTrue(model.asMap().containsKey(ModelKeys.ALL_GADGET_STATISTICS));
+ assertEquals(INVALID_TAG_NAME, ((String)model.asMap().get(ModelKeys.GADGET_SEARCH_TAGNAME)));
+ }
+
+ @Test
+ public void getGadgetsByAudience_validGadgetAudience() throws Exception {
+ expect(containerService.findByAudience(container, validGadgetAudience)).andReturn(containerRegistryList);
+ expect(gadgetService.getGadgetAudience(VALID_AUDIENCE_ID)).andReturn(validGadgetAudience);
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+ replay(userService);
+ replay(containerService);
+ replay(gadgetService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetsByAudience(VALID_AUDIENCE_ID, model, mockServletResponse);
+
+ assertEquals(4, model.asMap().size());
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_REPOSITORY_LIST));
+ List<ContainerRegistry> list = (List<ContainerRegistry>) model.asMap().get(ModelKeys.GADGET_REPOSITORY_LIST);
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ assertTrue(model.asMap().containsKey(ModelKeys.ALL_GADGET_STATISTICS));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TYPE));
+ assertEquals("audience", (String)model.asMap().get(ModelKeys.GADGET_SEARCH_TYPE));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_AUDIENCE));
+ assertEquals(validGadgetAudience, ((GadgetAudience)model.asMap().get(ModelKeys.GADGET_SEARCH_AUDIENCE)));
+ }
+
+ @Test
+ public void getGadgetsByAudience_invalidGadgetAudience() throws Exception {
+ expect(containerService.findByAudience(container, invalidGadgetAudience)).andReturn(new ArrayList<ContainerRegistry>());
+ expect(gadgetService.getGadgetAudience(INVALID_AUDIENCE_ID)).andReturn(invalidGadgetAudience);
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+ replay(userService);
+ replay(containerService);
+ replay(gadgetService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetsByAudience(INVALID_AUDIENCE_ID, model, mockServletResponse);
+
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_REPOSITORY_LIST));
+ List<ContainerRegistry> list = (List<ContainerRegistry>) model.asMap().get(ModelKeys.GADGET_REPOSITORY_LIST);
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_TYPE));
+ assertEquals("audience", (String)model.asMap().get(ModelKeys.GADGET_SEARCH_TYPE));
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_SEARCH_AUDIENCE));
+ assertEquals(invalidGadgetAudience, ((GadgetAudience)model.asMap().get(ModelKeys.GADGET_SEARCH_AUDIENCE)));
+ }
+
+ @Test
+ public void getGadgetStatistics_validGadgetId_validModel_validHttpServletResponse() throws GadgetNotFoundException {
+ GadgetStatistics gs = new GadgetStatistics();
+
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(statisticsService.getGadgetStatistics(VALID_GADGET_ID, user.getUserId())).andReturn(gs);
+ replay(statisticsService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetStatistics(VALID_GADGET_ID, model, mockServletResponse);
+ assertTrue(model.asMap().containsKey(ModelKeys.GADGET_STATISTICS));
+ assertEquals(ViewNames.JSON, viewName);
+ }
+
+ @Test
+ public void getAllGadgetStatistics_validModel_validHttpServletResponse() throws GadgetNotFoundException {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(user);
+ replay(userService);
+ expect(containerService.findContainerRegistry(container)).andReturn(containerRegistryList);
+ replay(containerService);
+ expect(statisticsService.getAllGadgetStatistics(user.getUserId(), containerRegistryList)).andReturn(gadgetRatings);
+ replay(statisticsService);
+
+ Model model = new ExtendedModelMap();
+ String viewName = gadgetSearchWebService.getGadgetStatistics(model, mockServletResponse);
+ assertTrue(model.asMap().containsKey(ModelKeys.ALL_GADGET_STATISTICS));
+ assertEquals(ViewNames.JSON, viewName);
+ }
+}
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/GadgetSearchWebServiceTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/SecurityTokenWebServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/SecurityTokenWebServiceTest.java?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/SecurityTokenWebServiceTest.java (added)
+++ incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/SecurityTokenWebServiceTest.java Fri Apr 1 16:42:22 2011
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.mitre.portal.web.webservice;
+
+import org.apache.shindig.auth.SecurityToken;
+import org.junit.Before;
+import org.junit.Test;
+import org.mitre.portal.model.Gadget;
+import org.mitre.portal.model.Person;
+import org.mitre.portal.model.PersonGadget;
+import org.mitre.portal.security.SecurityTokenService;
+import org.mitre.portal.security.UserService;
+import org.mitre.portal.security.impl.EncryptedBlobSecurityTokenService;
+import org.mitre.portal.service.exception.SecurityTokenException;
+import org.mitre.portal.web.model.JsonRpcResult;
+import org.mitre.portal.web.model.JsonSecurityToken;
+import org.mitre.portal.web.util.ModelKeys;
+import org.mitre.portal.web.util.ViewNames;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: JCIAN
+ * Date: Aug 12, 2010
+ * Time: 3:05:37 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SecurityTokenWebServiceTest {
+ private UserService userService;
+ private SecurityTokenService securityTokenService;
+ private SecurityTokenWebService securityTokenWebService;
+ private PersonGadget personGadget;
+ private Person person;
+ private Model model;
+
+ private final Long VALID_PERSON_GADGET_ID = 82L;
+ private final String VALID_EMP_NUMBER = "100";
+ private final String VALID_SUI = "acarlucci";
+ private final String VALID_URL = "http://content.example.com/gadgets/test.xml";
+
+ @Before
+ public void setup() throws MalformedURLException {
+ userService = createNiceMock(UserService.class);
+ securityTokenService = new EncryptedBlobSecurityTokenService(userService);
+ securityTokenWebService = new SecurityTokenWebService(securityTokenService);
+
+ person = new Person();
+ person.setUsername(VALID_SUI);
+ person.setUserId(VALID_EMP_NUMBER);
+
+ Gadget gadget = new Gadget();
+ gadget.setUrl(new URL(VALID_URL));
+
+ personGadget = new PersonGadget(VALID_PERSON_GADGET_ID);
+ personGadget.setGadget(gadget);
+ personGadget.setUserId(VALID_EMP_NUMBER);
+
+ model = new ExtendedModelMap();
+ }
+
+ @Test
+ public void refreshSecurityTokens_validJson() throws Exception {
+ expect(userService.getCurrentAuthenticatedUser()).andReturn(person).anyTimes();
+ replay(userService);
+
+ String encryptedToken1 = securityTokenService.getEncryptedEncodedSecurityToken(personGadget);
+ String encryptedToken2 = securityTokenService.getEncryptedEncodedSecurityToken(personGadget);
+ String encryptedToken3 = securityTokenService.getEncryptedEncodedSecurityToken(personGadget);
+
+ String json = "[{\"gadgetId\":0,\"securityToken\":\"" + encryptedToken1 + "\"}," +
+ "{\"gadgetId\":1,\"securityToken\":\"" + encryptedToken2 + "\"}," +
+ "{\"gadgetId\":2,\"securityToken\":\"" + encryptedToken3 + "\"}]";
+
+ String viewName = securityTokenWebService.refreshSecurityTokens(json, model);
+
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonSecurityToken[] jsonSecurityTokens = (JsonSecurityToken[]) model.asMap().get(ModelKeys.JSON_RESULT);
+ assertTrue(jsonSecurityTokens.length == 3);
+ assertEquals(ViewNames.JSON, viewName);
+
+ for (JsonSecurityToken jsonSecurityToken : jsonSecurityTokens) {
+ SecurityToken securityToken = securityTokenService.getSecurityTokenFromEncodedEncryptedSecurityToken(jsonSecurityToken.getSecurityToken());
+ validateSecurityToken(securityToken);
+ }
+ }
+
+ @Test
+ public void refreshSecurityTokens_invalidJson() throws Exception {
+ String json = "[{\"gadgetId\":0,\"securityToken\":\"foo\"}," +
+ "{\"gadgetId\":1,\"securityToken\":\"foo\"}," +
+ "{\"gadgetId\":2,\"securityToken\":\"foo\"}]";
+
+ String viewName = securityTokenWebService.refreshSecurityTokens(json, model);
+
+ assertTrue(model.asMap().containsKey(ModelKeys.JSON_RESULT));
+ JsonRpcResult result = ((JsonRpcResult) model.asMap().get(ModelKeys.JSON_RESULT));
+ assertFalse(result.isResult());
+ assertEquals(SecurityTokenException.class.getName(), result.getConsoleMessage());
+ assertEquals(ViewNames.JSON, viewName);
+ }
+
+ private void validateSecurityToken(SecurityToken securityToken) {
+ assertNotNull(securityToken);
+ assertEquals(VALID_PERSON_GADGET_ID.longValue(), securityToken.getModuleId());
+ assertEquals(VALID_EMP_NUMBER, securityToken.getOwnerId());
+ assertEquals(VALID_EMP_NUMBER, securityToken.getViewerId());
+ assertEquals(VALID_URL, securityToken.getAppUrl());
+ }
+}
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/test/unit/java/org/mitre/portal/web/webservice/SecurityTokenWebServiceTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext-security.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext-security.xml?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext-security.xml (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext-security.xml Fri Apr 1 16:42:22 2011
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in
+ ~ compliance with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!--
+ This security file uses the default spring simple form login
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:security="http://www.springframework.org/schema/security"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+
+ <security:http auto-config="true" use-expressions="true" disable-url-rewriting="true">
+ <!-- hasAnyRole has a known bug used here, should be fixed in 3.0.1. workaround is to use hasRole with or -->
+ <security:intercept-url
+ pattern="/app/repository/getGadgetFromUrl"
+ access="hasRole('OFFICIAL_GADGET_DEVELOPER') or hasRole('UNOFFICIAL_GADGET_DEVELOPER')" />
+ <security:intercept-url pattern="/app/repository/addGadget"
+ access="hasRole('OFFICIAL_GADGET_DEVELOPER') or hasRole('UNOFFICIAL_GADGET_DEVELOPER')" />
+ <security:intercept-url pattern="/app/repository/editGadget"
+ access="hasRole('OFFICIAL_GADGET_DEVELOPER') or hasRole('UNOFFICIAL_GADGET_DEVELOPER')" />
+ <security:intercept-url pattern="/app/repository/delete"
+ access="hasRole('REPOSITORY_ADMIN')" />
+ <security:intercept-url pattern="/app/admin/**"
+ access="hasRole('APPLICATION_ADMIN')" />
+ <!-- all urls must be authenticated -->
+ <security:intercept-url pattern="/**"
+ access="isAuthenticated()" />
+ </security:http>
+
+ <security:authentication-manager>
+ <security:authentication-provider
+ user-service-ref="userService" />
+ </security:authentication-manager>
+
+</beans>
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext-security.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext.xml?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext.xml (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext.xml Fri Apr 1 16:42:22 2011
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in
+ ~ compliance with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:security="http://www.springframework.org/schema/security"
+ xmlns:jee="http://www.springframework.org/schema/jee"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:oxm="http://www.springframework.org/schema/oxm"
+ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
+ http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
+ default-init-method="init" default-destroy-method="destroy">
+
+ <import resource="dataSource.xml" />
+ <!-- the spring security enabler needs to be in this file because our security
+ annotations are on the service classes, which are scanned here -->
+ <security:global-method-security pre-post-annotations="enabled"/>
+
+ <!-- scan for all non-mvc related beans -->
+ <context:component-scan base-package="org.mitre.portal.model.*"/>
+ <context:component-scan base-package="org.mitre.portal.repository.*"/>
+ <context:component-scan base-package="org.mitre.portal.service.*"/>
+ <context:component-scan base-package="org.mitre.portal.security.*"/>
+
+ <!-- make the the application.properties props available to autowire injectors -->
+ <context:property-placeholder location="classpath:application.properties"/>
+
+ <!-- JPA EntityManagerFactory -->
+ <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
+ p:persistenceUnitName="portalPersistenceUnit" p:dataSource-ref="dataSource">
+ <property name="jpaVendorAdapter">
+ <bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"
+ p:databasePlatform="org.eclipse.persistence.platform.database.H2Platform"
+ p:showSql="true"/>
+ </property>
+ <property name="jpaPropertyMap">
+ <map>
+ <entry key="eclipselink.weaving" value="false"/>
+
+ <!--
+ Caching numbers are based on the following (assumed) worst case scenario:
+ 10,000 users
+ Each user has 5 pages
+ Each page has 10 gadgets
+
+ Works out to 500,000 gadget instances
+ If each instance is customized, and each gadget has 5 preferences, we end up with 2,500,000 prefs
+
+ Assuming max of 1000 gadgets in the repository
+ -->
+ <entry key="eclipselink.cache.type.default" value="Full"/>
+ <!--
+ Default size equates to assumed number of gadget instances.
+ Any class that inherits the default is either assumed to be one instance per gadget instance,
+ or there isnt an obvious way to estimate a good default number.
+ -->
+ <entry key="eclipselink.cache.size.default" value="500000"/>
+
+ <!-- ConsumerInfo: could have one per gadget -->
+ <entry key="eclipselink.cache.size.ConsumerInfo" value="1000"/>
+ <entry key="eclipselink.cache.size.Container" value="5"/>
+ <!-- ContainerRegistry: Container * Gadget -->
+ <entry key="eclipselink.cache.size.ContainerRegistry" value="5000"/>
+ <entry key="eclipselink.cache.size.Gadget" value="1000"/>
+ <entry key="eclipselink.cache.size.GadgetAudience" value="1000"/>
+ <entry key="eclipselink.cache.size.GadgetAuthorType" value="100"/>
+ <entry key="eclipselink.cache.size.GadgetSupportLinkType" value="100"/>
+ <entry key="eclipselink.cache.size.GadgetTag" value="100"/>
+ <entry key="eclipselink.cache.size.GadgetComment" value="1000"/>
+ <!-- GadgetUserPref: Gadget * Number of assumed prefs per gadget -->
+ <entry key="eclipselink.cache.size.GadgetUserPref" value="5000"/>
+ <!-- Page: Number of assumed users * Number of assumed pages -->
+ <entry key="eclipselink.cache.size.Page" value="50000"/>
+ <entry key="eclipselink.cache.size.PageLayout" value="100"/>
+ <entry key="eclipselink.cache.size.PageTemplate" value="100"/>
+ <entry key="eclipselink.cache.size.PageTemplateGadget" value="1000"/>
+ <entry key="eclipselink.cache.size.PageTemplateOwnerType" value="10"/>
+ <entry key="eclipselink.cache.size.PersonGadgetUserPref" value="2500000"/>
+ <!-- Region: Number of assumed users * Number of assumed pages * 3 (assumed) regions per page -->
+ <entry key="eclipselink.cache.size.Region" value="150000"/>
+ <entry key="eclipselink.cache.size.SecurityRole" value="100"/>
+ <entry key="eclipselink.cache.size.SecurityUserRole" value="1000"/>
+ <!-- UserWizardCompleted: Number of wizards * Number of users -->
+ <entry key="eclipselink.cache.size.Wizard" value="2"/>
+ <entry key="eclipselink.cache.size.UserWizardCompleted" value="20000"/>
+
+ <entry key="eclipselink.logging.logger"
+ value="org.eclipse.persistence.logging.CommonsLoggingSessionLog"/>
+ <entry key="eclipselink.logging.level" value="INFO"/>
+ <entry key="eclipselink.logging.level.sql" value="INFO"/>
+ </map>
+ </property>
+ </bean>
+
+ <!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
+ <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
+ p:entityManagerFactory-ref="entityManagerFactory"/>
+
+ <!-- Instruct Spring to perform declarative transaction management automatically on annotated classes. -->
+ <tx:annotation-driven transaction-manager="transactionManager"/>
+
+ <!-- create a Container bean representing this container -->
+ <bean id="portalContainer" class="org.mitre.portal.model.Container" factory-bean="containerService"
+ factory-method="findContainer">
+ <constructor-arg value="default"/>
+ </bean>
+
+ <!-- create HttpClient and PostMethodFactory beans for use in the ShindigService -->
+ <bean id="httpClient" class="org.apache.commons.httpclient.HttpClient" />
+ <bean id="postMethodFactory" class="org.mitre.portal.service.util.PostMethodFactory" />
+
+ <!-- Freemarker libraries for UI -->
+ <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
+ <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
+ <!-- application wide escaping charset for freemarker escape functions-->
+ <property name="freemarkerSettings">
+ <props>
+ <!-- set the escape character set-->
+ <prop key="url_escaping_charset">UTF-8</prop>
+ <!-- set the default number format to remove commas-->
+ <prop key="number_format">0.#######</prop>
+ </props>
+ </property>
+ </bean>
+
+ <!-- implementation of the JavaMailSender to use in our application -->
+ <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
+ <property name="host" value="${mail.smtpHost}"/>
+ </bean>
+
+ <!-- the application's exception handler, moved here from dispatcher-servlet.xml so the bean is available for junit tests -->
+ <bean id="defaultExceptionHandler" class="org.mitre.portal.web.util.DefaultExceptionHandler">
+ <property name="order" value="1"/>
+ <property name="defaultErrorView" value="templates.error.default_error"/>
+ <property name="exceptionMappings">
+ <map>
+ <entry key="org.springframework.security.access.AccessDeniedException" value="templates.error.access_denied_error"/>
+ </map>
+ </property>
+ </bean>
+
+</beans>
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/applicationContext.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/dataSource.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/dataSource.xml?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/dataSource.xml (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/dataSource.xml Fri Apr 1 16:42:22 2011
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in
+ ~ compliance with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
+ default-init-method="init" default-destroy-method="destroy">
+ <!-- Creates a datasource factory that returns a singleton DataSource and initializes a H2 database with the given scripts and TO_DATE conversion patterns -->
+ <bean id="dataSource" class="org.mitre.jdbc.datasource.H2DataSourceFactory">
+ <property name="databaseName" value="portal"/>
+ <property name="executeScriptQuery" value="SELECT container_id FROM CONTAINER" />
+ <property name="persist" value="false" />
+ <property name="scriptLocations" >
+ <list>
+ <value>classpath:db/sequences/create_all_seq.sql</value>
+ <value>classpath:db/tables/create_all_tables.sql</value>
+ <value>classpath:db/data/initial_data.sql</value>
+ </list>
+ </property>
+ <property name="dateConversionPatterns">
+ <map>
+ <entry key="yyyy/mm/dd hh24:mi:ss" value="yyyy/MM/dd HH:mm:ss" />
+ <entry key="MM/DD/YYYY HH24:MI:SS" value="MM/dd/yyyy HH:mm:ss" />
+ </map>
+ </property>
+ </bean>
+</beans>
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/dataSource.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/dispatcher-servlet.xml
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/dispatcher-servlet.xml?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/dispatcher-servlet.xml (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/dispatcher-servlet.xml Fri Apr 1 16:42:22 2011
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in
+ ~ compliance with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:security="http://www.springframework.org/schema/security"
+ xmlns:jee="http://www.springframework.org/schema/jee"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"
+ default-init-method="init" default-destroy-method="destroy">
+
+ <!-- perform a component scan of the mvc related beans -->
+ <context:component-scan base-package="org.mitre.portal.web.*"/>
+
+ <!-- make the the application.properties props available to autowire injectors -->
+ <context:property-placeholder location="classpath:application.properties"/>
+
+ <!-- import our custom views for this application -->
+ <import resource="views.xml"/>
+
+ <!-- TODO: Look at configuring the cache settings for tiles and freemarker (how often it checks for changes on disk, etc) -->
+ <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
+ <property name="definitions">
+ <list>
+ <value>/WEB-INF/tiles-defs.xml</value>
+ </list>
+ </property>
+ </bean>
+
+ <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" p:order="0">
+ <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
+ </bean>
+
+ <!-- mfranklin on 6/10/09 - added json view -->
+ <bean name="jsonViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver" p:order="1"/>
+
+ <!-- acarlucci on 6/30/09 - added HandlerInterceptor to put common objects in model for all controllers -->
+ <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
+ <property name="interceptors">
+ <list>
+ <bean class="org.mitre.portal.web.util.CommonModelHandlerInterceptor"/>
+ </list>
+ </property>
+ </bean>
+</beans>
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/dispatcher-servlet.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_audience.ftl
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_audience.ftl?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_audience.ftl (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_audience.ftl Fri Apr 1 16:42:22 2011
@@ -0,0 +1,140 @@
+<#--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements. See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership. The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in
+~ compliance with the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied. See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+ -->
+<#include "/WEB-INF/freemarker/common/globals.ftl">
+<div class="headerBuffer">
+ <div class="adminPageLocation"><a href="<@c.url value="${.globals.adminControllerPath}" />/home">${.globals.appName} Administration</a> -> Gadget Audiences</div>
+</div>
+<table class="adminEditTable">
+ <tr>
+ <td style="vertical-align:top; width: 300px;">
+ <table dojoType="dijit.form.Form" id="addGadgetAudienceForm" method="POST" action="<@c.url value="${.globals.adminControllerPath}" />/saveGadgetAudience">
+ <tr>
+ <td>
+ <input type="hidden" id="newGadgetAudienceId" name="gadgetAudienceId" value="0" />
+ <label for="code">Code:</label>
+ </td>
+ <td>
+ <input type="text"
+ id="newCode"
+ name="code"
+ style="width: 5em;"
+ dojoType="dijit.form.ValidationTextBox"
+ trim="true"
+ required="true"
+ maxlength="5"
+ invalidMessage="Enter a code (up to 5 chars)"
+ />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label for="code">Description:</label>
+ </td>
+ <td>
+ <input type="text"
+ id="newDescription"
+ name="description"
+ style="width: 10em;"
+ dojoType="dijit.form.ValidationTextBox"
+ trim="true"
+ required="true"
+ maxlength="100"
+ invalidMessage="Enter a description (up to 100 chars)"
+ />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <button dojoType="dijit.form.Button" type="submit">Add New Gadget Audience</button>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:top;">
+ <div dojoType="dijit.form.Form" id="deleteGadgetAudienceForm" method="POST" action="<@c.url value="${.globals.adminControllerPath}" />/deleteGadgetAudience" style="display: none;">
+ <input type="hidden" id="deleteGadgetAudienceId" name="gadgetAudienceId" value="" />
+ </div>
+ <table class="adminExistingData">
+ <th style="text-align: center;">Actions</th>
+ <th>Code</th>
+ <th>Description</th>
+ <#list gadgetAudienceList as gadgetAudience>
+ <tr>
+ <td>
+ <input type="hidden" id="gadgetAudienceId_${gadgetAudience_index}" name="gadgetAudienceId_${gadgetAudience_index}" value="${gadgetAudience.gadgetAudienceId}" />
+ <button dojoType="dijit.form.Button" type="button" id="editAudienceButton_${gadgetAudience_index}" onclick="portal.admin.editGadgetAudience(${gadgetAudience_index});">Edit</button>
+ <button dojoType="dijit.form.Button" type="button" id="deleteAudienceButton_${gadgetAudience_index}" onclick="portal.admin.deleteGadgetAudience(${gadgetAudience_index});">Delete</button>
+ </td>
+ <td>
+ <span id="gadgetAudienceCode_${gadgetAudience_index}">${gadgetAudience.code?xhtml}</span>
+ </td>
+ <td>
+ <span id="gadgetAudienceDescription_${gadgetAudience_index}">${gadgetAudience.description?xhtml}</span>
+ </td>
+ </tr>
+ </#list>
+ </table>
+ </td>
+ </tr>
+</table>
+<div id="editGadgetAudienceDialog" dojoType="dijit.Dialog" title="Edit Gadget Audience" style="display: none;">
+ <table dojoType="dijit.form.Form" id="editGadgetAudienceForm" method="POST" action="<@c.url value="${.globals.adminControllerPath}" />/saveGadgetAudience" class="adminExistingDialog">
+ <tr>
+ <td>
+ <input type="hidden" id="editGadgetAudienceId" name="gadgetAudienceId" value="0" />
+ <label for="code">Code:</label>
+ </td>
+ <td>
+ <input type="text"
+ id="editCode"
+ name="code"
+ style="width: 5em;"
+ dojoType="dijit.form.ValidationTextBox"
+ trim="true"
+ required="true"
+ maxlength="5"
+ invalidMessage="Enter a code (up to 5 chars)"
+ />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label for="code">Description:</label>
+ </td>
+ <td>
+ <input type="text"
+ id="editDescription"
+ name="description"
+ style="width: 10em;"
+ dojoType="dijit.form.ValidationTextBox"
+ trim="true"
+ required="true"
+ maxlength="100"
+ invalidMessage="Enter a description (up to 100 chars)"
+ />
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" style="text-align: center;">
+ <button dojoType="dijit.form.Button" type="submit">Save</button>
+ <button dojoType="dijit.form.Button" type="button" onclick="dijit.byId('editGadgetAudienceDialog').hide();">Cancel</button>
+ </td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_audience.ftl
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_pref_refresh.ftl
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_pref_refresh.ftl?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_pref_refresh.ftl (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_pref_refresh.ftl Fri Apr 1 16:42:22 2011
@@ -0,0 +1,34 @@
+<#--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements. See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership. The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in
+~ compliance with the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied. See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+ -->
+<#include "/WEB-INF/freemarker/common/globals.ftl">
+<div class="headerBuffer">
+ <div class="adminPageLocation"><a href="<@c.url value="${.globals.adminControllerPath}" />/home">${.globals.appName} Administration</a> -> Gadget UserPref Refresh</div>
+</div>
+<div style="width: 70%" class="adminEditTable" id="content">
+ <div id="refresh">
+ <p>Click the "Refresh All" button below to refresh gadget user preferences from the Gadget XML for every gadget in the container.</p>
+ <button id="refreshButton" dojoType="dijit.form.Button" onclick="portal.admin.refreshUserPrefs();">Refresh All</button>
+ </div>
+ <div id="results" class="portalHidden">
+ Results:
+ <ul id="resultList">
+
+ </ul>
+ </div>
+</div>
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/gadget_pref_refresh.ftl
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/home.ftl
URL: http://svn.apache.org/viewvc/incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/home.ftl?rev=1087796&view=auto
==============================================================================
--- incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/home.ftl (added)
+++ incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/home.ftl Fri Apr 1 16:42:22 2011
@@ -0,0 +1,46 @@
+<#--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements. See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership. The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in
+~ compliance with the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied. See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+ -->
+<#include "/WEB-INF/freemarker/common/globals.ftl">
+<div class="headerBuffer adminHeader">${.globals.appName} Administration</div>
+<table class="adminLinksWrapper">
+ <tr>
+ <td>
+ <ul class="adminLinks">
+ <li><a href="<@c.url value="${.globals.adminControllerPath}" />/viewGadgetAudience">Gadget Audiences</a></li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <ul class="adminLinks">
+ <li><a href="<@c.url value="${.globals.adminControllerPath}" />/viewSecurityUserRole">Security User Role</a></li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <ul class="adminLinks">
+ <li><a href="<@c.url value="${.globals.adminControllerPath}" />/refreshUserPrefsFromSpec">Refresh Gadget User Prefs</a></li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td style="padding-top: 20px;"><a href="<@c.url value='/' />"><< Back to ${.globals.appName}</td>
+ </tr>
+</table>
\ No newline at end of file
Propchange: incubator/rave/donations/mitre-osec/web/WEB-INF/freemarker/admin/home.ftl
------------------------------------------------------------------------------
svn:executable = *