You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by oc...@apache.org on 2007/02/20 03:41:40 UTC
svn commit: r509415 [3/3] - in /maven/continuum/trunk:
continuum-security/src/main/java/org/apache/maven/continuum/security/profile/
continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/
continuum-webapp/src/main/java/org/apache/maven/c...
Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/notifier/DeleteProjectNotifierAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/notifier/DeleteProjectNotifierAction.java?view=diff&rev=509415&r1=509414&r2=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/notifier/DeleteProjectNotifierAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/notifier/DeleteProjectNotifierAction.java Mon Feb 19 18:41:37 2007
@@ -20,10 +20,14 @@
*/
import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.security.ContinuumRoleConstants;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.web.action.ContinuumActionSupport;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import java.util.Map;
@@ -36,6 +40,7 @@
*/
public class DeleteProjectNotifierAction
extends ContinuumActionSupport
+ implements SecureAction
{
private int projectId;
@@ -53,9 +58,12 @@
private boolean fromGroupPage = false;
+ private String projectGroupName = "";
+
public String execute()
throws ContinuumException
{
+
getContinuum().removeNotifier( projectId, notifierId );
if ( fromGroupPage )
@@ -69,6 +77,7 @@
public String doDefault()
throws ContinuumException
{
+
ProjectNotifier notifier = getContinuum().getNotifier( projectId, notifierId );
Map configuration = notifier.getConfiguration();
@@ -93,6 +102,7 @@
recipient = recipient + ":" + (String) configuration.get( "channel" );
}
+
return "delete";
}
@@ -156,4 +166,39 @@
this.fromGroupPage = fromGroupPage;
}
+ public String getProjectGroupName()
+ throws ContinuumException
+ {
+ if ( projectGroupName == null || "".equals( projectGroupName ) )
+ {
+ if( projectGroupId != 0 )
+ {
+ projectGroupName = getContinuum().getProjectGroup( projectGroupId ).getName();
+ }
+ else
+ {
+ projectGroupName = getContinuum().getProjectGroupByProjectId( projectId ).getName();
+ }
+ }
+
+ return projectGroupName;
+ }
+
+ public SecureActionBundle getSecureActionBundle()
+ throws SecureActionException {
+ SecureActionBundle bundle = new SecureActionBundle();
+ bundle.setRequiresAuthentication( true );
+
+ try
+ {
+ bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_REMOVE_PROJECT_NOTIFIER_OPERATION,
+ getProjectGroupName() );
+ }
+ catch ( ContinuumException e )
+ {
+ throw new SecureActionException( e.getMessage() );
+ }
+
+ return bundle;
+ }
}
Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthenticationRequiredException.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthenticationRequiredException.java?view=auto&rev=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthenticationRequiredException.java (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthenticationRequiredException.java Mon Feb 19 18:41:37 2007
@@ -0,0 +1,41 @@
+package org.apache.maven.continuum.web.exception;
+
+/*
+ * 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.
+ */
+
+/**
+ * Used when authentication is checked during authorization
+ * checks within action classes
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class AuthenticationRequiredException
+ extends Exception
+{
+ public AuthenticationRequiredException( String string )
+ {
+ super( string );
+ }
+
+ public AuthenticationRequiredException( String string, Throwable throwable )
+ {
+ super( string, throwable );
+ }
+}
Added: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthorizationRequiredException.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthorizationRequiredException.java?view=auto&rev=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthorizationRequiredException.java (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/AuthorizationRequiredException.java Mon Feb 19 18:41:37 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.continuum.web.exception;
+
+/*
+ * 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.
+ */
+
+/**
+ * Thrown when authorization check fails
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @version
+ */
+public class AuthorizationRequiredException
+ extends Exception
+{
+ public AuthorizationRequiredException( String string )
+ {
+ super( string );
+ }
+
+ public AuthorizationRequiredException( String string, Throwable throwable )
+ {
+ super( string, throwable );
+ }
+}
Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/ContinuumActionException.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/ContinuumActionException.java?view=diff&rev=509415&r1=509414&r2=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/ContinuumActionException.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/exception/ContinuumActionException.java Mon Feb 19 18:41:37 2007
@@ -18,7 +18,7 @@
* under the License.
*/
-/**
+/**
* ContinuumActionException:
*
* @author Jesse McConnell <jm...@apache.org>
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?view=diff&rev=509415&r1=509414&r2=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Mon Feb 19 18:41:37 2007
@@ -78,8 +78,10 @@
<result name="error">/WEB-INF/jsp/error/error.jsp</result>
<result name="internal-error">/WEB-INF/jsp/error/error.jsp</result>
<result name="internalError" type="redirect">/WEB-INF/jsp/error/error.jsp</result>
+ <result name="requires-authorization">/WEB-INF/jsp/error/authorizationError.jsp</result>
- <result name="continuum-configuration-required" type="redirect-action">
+
+ <result name="continuum-configuration-required" type="redirect-action">
<param name="actionName">configuration</param>
<param name="namespace">/admin</param>
<param name="method">input</param>
Added: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/authorizationError.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/authorizationError.jsp?view=auto&rev=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/authorizationError.jsp (added)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/authorizationError.jsp Mon Feb 19 18:41:37 2007
@@ -0,0 +1,43 @@
+<%--
+ ~ 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.
+ --%>
+
+<%@ taglib prefix="ww" uri="/webwork" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+<html>
+<head>
+ <title>Authorization Error</title>
+</head>
+
+<body>
+ <div id="h3">
+ <h3>Authorization Error</h3>
+ <div class="errors">
+ <ww:if test="hasActionErrors()">
+ <ww:actionerror/>
+ </ww:if>
+
+ <ww:else>
+ You are not authorized to access this page.
+ Please contact your administrator to be granted the appropriate permissions.
+ </ww:else>
+ </div>
+ </div>
+</body>
+</html>
Modified: maven/continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/ReleasePrepareActionTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/ReleasePrepareActionTest.java?view=diff&rev=509415&r1=509414&r2=509415
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/ReleasePrepareActionTest.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/test/java/org/apache/maven/continuum/web/action/ReleasePrepareActionTest.java Mon Feb 19 18:41:37 2007
@@ -21,8 +21,16 @@
import org.apache.maven.continuum.Continuum;
import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
+import org.codehaus.plexus.security.system.SecuritySession;
+import org.codehaus.plexus.security.system.SecuritySystemConstants;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import com.opensymphony.xwork.ActionContext;
/**
* Test for {@link ReleasePrepareAction}
@@ -38,10 +46,18 @@
private Mock continuumMock;
+ private Mock securitySessionMock;
+
+ private Mock actionContextMock;
+
public ReleasePrepareActionTest()
{
action = new ReleasePrepareAction();
continuumMock = new Mock( Continuum.class );
+ //securitySessionMock = new Mock( SecuritySession.class );
+ //Map map = new HashMap();
+ //map.put( SecuritySystemConstants.SECURITY_SESSION_KEY, securitySessionMock );
+ //action.setSession( map );
action.setContinuum( (Continuum) continuumMock.proxy() );
}
@@ -53,8 +69,12 @@
public void testScmTagBaseSvn()
throws Exception
{
+ //commented out because of problems in authorization checks
+
String svnUrl = "https://svn.apache.org/repos/asf/maven/continuum";
String scmUrl = "scm:svn:" + svnUrl + "/trunk/";
+ //ProjectGroup projectGroup = new ProjectGroup();
+ //continuumMock.expects( once() ).method( "getProjectGroupByProjectId" ).will( returnValue( projectGroup ) );
Project project = new Project();
project.setScmUrl( scmUrl );
project.setWorkingDirectory(".");
@@ -72,6 +92,8 @@
public void testScmTagBaseNonSvn()
throws Exception
{
+ //commented out because of problems in authorization checks
+
Project project = new Project();
project.setScmUrl( "scm:cvs:xxx" );
project.setWorkingDirectory(".");
@@ -80,4 +102,4 @@
assertEquals( "", action.getScmTagBase() );
continuumMock.verify();
}
-}
\ No newline at end of file
+}