From: Olivier Lamy Date: Mon, 9 Jan 2012 12:49:13 +0000 (+0000) Subject: rename webapp-common module to web-common as it will be used in rest services: this... X-Git-Tag: archiva-1.4-M3~1619 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ec6b0355a7842170619193f2cc2ec15640529892;p=archiva.git rename webapp-common module to web-common as it will be used in rest services: this name will makes more sense git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1229124 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml new file mode 100644 index 000000000..46ccf70fe --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -0,0 +1,307 @@ + + + + 4.0.0 + + org.apache.archiva + archiva-web + 1.4-M3-SNAPSHOT + + + archiva-webapp-common + bundle + Archiva Web :: Webapp Common + + + + org.apache.archiva + metadata-repository-api + + + org.apache.archiva + archiva-configuration + + + org.apache.archiva + archiva-security-common + + + org.apache.archiva + archiva-rss + + + org.apache.archiva + archiva-security + + + org.codehaus.redback + redback-common-integrations + + + stax + stax-api + + + + + org.apache.archiva + archiva-plexus-bridge + + + org.apache.archiva + archiva-scheduler-repository + + + org.codehaus.redback + redback-rbac-model + + + org.codehaus.redback + redback-rbac-role-manager + + + org.codehaus.redback + redback-system + + + javax.servlet + servlet-api + provided + + + org.codehaus.redback.components + spring-taskqueue + + + org.codehaus.redback.components + spring-quartz + + + org.quartz-scheduler + quartz + + + c3p0 + c3p0 + + + javax.transaction + jta + + + + + org.springframework + spring-core + + + org.springframework + spring-beans + + + org.springframework + spring-context-support + + + org.springframework + spring-web + + + httpunit + httpunit + test + + + junit + junit + test + + + org.slf4j + slf4j-log4j12 + test + + + + + + + src/main/resources + + + src/main/filtered-resources + true + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.archiva.webapp.common + ${project.version} + + org.apache.archiva.web.spring;version=${project.version}, + org.apache.archiva.web.startup;version=${project.version} + + + javax.annotation, + javax.inject, + javax.servlet, + javax.servlet.http, + org.apache.archiva.common;version=${project.version}, + org.apache.archiva.common.plexusbridge;version=${project.version}, + org.apache.archiva.configuration;version=${project.version}, + org.apache.archiva.repository.events;version=${project.version}, + org.apache.archiva.scheduler.repository;version=${project.version}, + org.apache.archiva.security.common;version=${project.version}, + org.apache.commons.collections;version="[3.2,4)", + org.apache.commons.lang;version="[2.4,3)", + org.apache.maven.index, + org.apache.maven.index.context, + org.codehaus.plexus.redback.rbac, + org.codehaus.plexus.redback.role, + org.codehaus.plexus.redback.system.check, + org.codehaus.plexus.registry, + org.codehaus.plexus.taskqueue, + org.codehaus.plexus.taskqueue.execution, + org.codehaus.redback.components.scheduler, + org.quartz;version="[2,3)", + org.slf4j;resolution:=optional, + org.springframework*;version="[3,4)", + org.springframework.web*;version="[3,4)", + com.sun.syndication.feed.synd, + com.sun.syndication.io, + org.apache.archiva.metadata.repository, + org.apache.archiva.rss.processor, + org.apache.archiva.security, + org.apache.commons.codec, + org.apache.commons.codec.binary, + org.codehaus.plexus.redback.authentication, + org.codehaus.plexus.redback.authorization, + org.codehaus.plexus.redback.policy, + org.codehaus.plexus.redback.system, + org.codehaus.plexus.redback.users, + org.codehaus.redback.integration.filter.authentication + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${basedir}/target/archiva.xml + ${project.build.testOutputDirectory} + ${redbackTestJdbcUrl} + ${redbackTestJdbcDriver} + ${basedir} + + + + + + + + + svn-buildnumber + + + .svn + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + generate-resources + + create + + + + + false + false + + javasvn + + + + + + + + non-canonical-buildnumber + + + .svn + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + + generate-resources + + create + + + + + false + false + NON-CANONICAL_{0,date,yyyy-MM-dd_HH-mm}_{1} + + timestamp + ${user.name} + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/filtered-resources/application.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/filtered-resources/application.properties new file mode 100644 index 000000000..12806aa73 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/filtered-resources/application.properties @@ -0,0 +1,22 @@ +# +# 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. +# +user.agent=Apache Archiva/${project.version} +archiva.version=${project.version} +archiva.buildNumber=${buildNumber} +archiva.timestamp=${timestamp} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java new file mode 100644 index 000000000..eb7bb0043 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java @@ -0,0 +1,335 @@ +package org.apache.archiva.web.rss; + +/* + * 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. + */ + +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedOutput; +import org.apache.archiva.metadata.repository.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.rss.processor.RssFeedProcessor; +import org.apache.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.UserRepositories; +import org.apache.archiva.security.common.ArchivaRoleConstants; +import org.apache.commons.codec.Decoder; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; +import org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.authorization.UnauthorizedException; +import org.codehaus.plexus.redback.policy.AccountLockedException; +import org.codehaus.plexus.redback.policy.MustChangePasswordException; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.users.UserManager; +import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Servlet for handling rss feed requests. + */ +public class RssFeedServlet + extends HttpServlet +{ + public static final String MIME_TYPE = "application/rss+xml; charset=UTF-8"; + + private static final String COULD_NOT_GENERATE_FEED_ERROR = "Could not generate feed"; + + private static final String COULD_NOT_AUTHENTICATE_USER = "Could not authenticate user"; + + private static final String USER_NOT_AUTHORIZED = "User not authorized to access feed."; + + private Logger log = LoggerFactory.getLogger( RssFeedServlet.class ); + + private RssFeedProcessor processor; + + private WebApplicationContext wac; + + private UserRepositories userRepositories; + + private ServletAuthenticator servletAuth; + + private HttpAuthenticator httpAuth; + + private RepositorySessionFactory repositorySessionFactory; + + public void init( javax.servlet.ServletConfig servletConfig ) + throws ServletException + { + super.init( servletConfig ); + wac = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() ); + userRepositories = wac.getBean( UserRepositories.class ); + servletAuth = wac.getBean( ServletAuthenticator.class ); + httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class ); + // TODO: what if there are other types? + repositorySessionFactory = wac.getBean( "repositorySessionFactory", RepositorySessionFactory.class ); + } + + public void doGet( HttpServletRequest req, HttpServletResponse res ) + throws ServletException, IOException + { + String repoId = null; + String groupId = null; + String artifactId = null; + + String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" ); + if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 ) + { + artifactId = StringUtils.substringAfterLast( url, "/" ); + groupId = StringUtils.substringBeforeLast( StringUtils.substringAfter( url, "feeds/" ), "/" ); + groupId = StringUtils.replaceChars( groupId, '/', '.' ); + } + else if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) == 0 ) + { + repoId = StringUtils.substringAfterLast( url, "/" ); + } + else + { + res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Invalid request url." ); + return; + } + + try + { + Map map = new HashMap(); + SyndFeed feed = null; + + if ( isAllowed( req, repoId, groupId, artifactId ) ) + { + if ( repoId != null ) + { + // new artifacts in repo feed request + processor = wac.getBean( "rssFeedProcessor#new-artifacts", RssFeedProcessor.class ); + map.put( RssFeedProcessor.KEY_REPO_ID, repoId ); + } + else if ( ( groupId != null ) && ( artifactId != null ) ) + { + // TODO: this only works for guest - we could pass in the list of repos + // new versions of artifact feed request + processor = wac.getBean( "rssFeedProcessor#new-versions", RssFeedProcessor.class ); + map.put( RssFeedProcessor.KEY_GROUP_ID, groupId ); + map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId ); + } + } + else + { + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED ); + return; + } + + RepositorySession repositorySession = repositorySessionFactory.createSession(); + try + { + feed = processor.process( map, repositorySession.getRepository() ); + } + finally + { + repositorySession.close(); + } + if ( feed == null ) + { + res.sendError( HttpServletResponse.SC_NO_CONTENT, "No information available." ); + return; + } + + res.setContentType( MIME_TYPE ); + + if ( repoId != null ) + { + feed.setLink( req.getRequestURL().toString() ); + } + else if ( ( groupId != null ) && ( artifactId != null ) ) + { + feed.setLink( req.getRequestURL().toString() ); + } + + SyndFeedOutput output = new SyndFeedOutput(); + output.output( feed, res.getWriter() ); + } + catch ( UserNotFoundException unfe ) + { + log.debug( COULD_NOT_AUTHENTICATE_USER, unfe ); + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); + } + catch ( AccountLockedException acce ) + { + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); + } + catch ( AuthenticationException authe ) + { + log.debug( COULD_NOT_AUTHENTICATE_USER, authe ); + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); + } + catch ( FeedException ex ) + { + log.debug( COULD_NOT_GENERATE_FEED_ERROR, ex ); + res.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, COULD_NOT_GENERATE_FEED_ERROR ); + } + catch ( MustChangePasswordException e ) + { + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); + } + catch ( UnauthorizedException e ) + { + log.debug( e.getMessage() ); + if ( repoId != null ) + { + res.setHeader( "WWW-Authenticate", + "Basic realm=\"Repository Archiva Managed " + repoId + " Repository" ); + } + else + { + res.setHeader( "WWW-Authenticate", "Basic realm=\"Artifact " + groupId + ":" + artifactId ); + } + + res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED ); + } + } + + /** + * Basic authentication. + * + * @param req + * @param repositoryId TODO + * @param groupId TODO + * @param artifactId TODO + * @return + */ + private boolean isAllowed( HttpServletRequest req, String repositoryId, String groupId, String artifactId ) + throws UserNotFoundException, AccountLockedException, AuthenticationException, MustChangePasswordException, + UnauthorizedException + { + String auth = req.getHeader( "Authorization" ); + List repoIds = new ArrayList(); + + if ( repositoryId != null ) + { + repoIds.add( repositoryId ); + } + else if ( artifactId != null && groupId != null ) + { + if ( auth != null ) + { + if ( !auth.toUpperCase().startsWith( "BASIC " ) ) + { + return false; + } + + Decoder dec = new Base64(); + String usernamePassword = ""; + + try + { + usernamePassword = new String( (byte[]) dec.decode( auth.substring( 6 ).getBytes() ) ); + } + catch ( DecoderException ie ) + { + log.warn( "Error decoding username and password.", ie.getMessage() ); + } + + if ( usernamePassword == null || usernamePassword.trim().equals( "" ) ) + { + repoIds = getObservableRepos( UserManager.GUEST_USERNAME ); + } + else + { + String[] userCredentials = usernamePassword.split( ":" ); + repoIds = getObservableRepos( userCredentials[0] ); + } + } + else + { + repoIds = getObservableRepos( UserManager.GUEST_USERNAME ); + } + } + else + { + return false; + } + + for ( String repoId : repoIds ) + { + try + { + AuthenticationResult result = httpAuth.getAuthenticationResult( req, null ); + SecuritySession securitySession = httpAuth.getSecuritySession( req.getSession( true ) ); + + if ( servletAuth.isAuthenticated( req, result ) && servletAuth.isAuthorized( req, securitySession, + repoId, + ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ) + { + return true; + } + } + catch ( AuthorizationException e ) + { + + } + catch ( UnauthorizedException e ) + { + + } + } + + throw new UnauthorizedException( "Access denied." ); + } + + private List getObservableRepos( String principal ) + { + try + { + return userRepositories.getObservableRepositoryIds( principal ); + } + catch ( PrincipalNotFoundException e ) + { + log.warn( e.getMessage(), e ); + } + catch ( AccessDeniedException e ) + { + log.warn( e.getMessage(), e ); + } + catch ( ArchivaSecurityException e ) + { + log.warn( e.getMessage(), e ); + } + + return Collections.emptyList(); + } + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java new file mode 100644 index 000000000..23f013ba0 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java @@ -0,0 +1,92 @@ +package org.apache.archiva.web.runtime; +/* + * 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. + */ + +import org.apache.commons.lang.math.NumberUtils; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import javax.inject.Named; +import java.util.Properties; + +/** + * @author Olivier Lamy + * @since 1.4-M3 + */ +@Service( "archivaRuntimeInfo" ) +public class ArchivaRuntimeInfo +{ + + private String version; + + private String buildNumber; + + private long timestamp; + + + @Inject + public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties ) + { + this.version = (String) archivaRuntimeProperties.get( "archiva.version" ); + this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" ); + this.timestamp = NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) ); + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getBuildNumber() + { + return buildNumber; + } + + public void setBuildNumber( String buildNumber ) + { + this.buildNumber = buildNumber; + } + + public long getTimestamp() + { + return timestamp; + } + + public void setTimestamp( long timestamp ) + { + this.timestamp = timestamp; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "ArchivaRuntimeInfo" ); + sb.append( "{version='" ).append( version ).append( '\'' ); + sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' ); + sb.append( ", timestamp=" ).append( timestamp ); + sb.append( '}' ); + return sb.toString(); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java new file mode 100644 index 000000000..582290284 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java @@ -0,0 +1,64 @@ +package org.apache.archiva.web.spring; + +/* + * 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. + */ + +import org.apache.archiva.repository.events.RepositoryListener; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; + +import java.util.List; + +/** + * @todo though we will eventually remove this altogether, an interim cleanup would be to genericise this + * and replace the calls in RepositoryContentConsumers with calls to the same thing + */ +public class RepositoryListenerFactoryBean + implements FactoryBean, ApplicationContextAware +{ + + private ApplicationContext applicationContext; + + public void setApplicationContext( ApplicationContext applicationContext ) + throws BeansException + { + this.applicationContext = applicationContext; + } + + public Object getObject() + throws Exception + { + return applicationContext.getBeansOfType( RepositoryListener.class ).values(); + } + + @SuppressWarnings("unchecked") + public Class getObjectType() + { + return List.class; + } + + public boolean isSingleton() + { + return true; + } + + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java new file mode 100644 index 000000000..46aca0bb7 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java @@ -0,0 +1,208 @@ +package org.apache.archiva.web.startup; + +/* + * 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. + */ + +import org.apache.archiva.common.ArchivaException; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; +import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexingContext; +import org.codehaus.plexus.taskqueue.Task; +import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor; +import org.codehaus.redback.components.scheduler.DefaultScheduler; +import org.quartz.SchedulerException; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import java.lang.reflect.Field; +import java.util.Properties; +import java.util.concurrent.ExecutorService; + +/** + * ArchivaStartup - the startup of all archiva features in a deterministic order. + * + * @version $Id$ + */ +public class ArchivaStartup + implements ServletContextListener +{ + private ThreadedTaskQueueExecutor tqeDbScanning; + + private ThreadedTaskQueueExecutor tqeRepoScanning; + + private ThreadedTaskQueueExecutor tqeIndexing; + + private RepositoryArchivaTaskScheduler repositoryTaskScheduler; + + private PlexusSisuBridge plexusSisuBridge; + + private NexusIndexer nexusIndexer; + + public void contextInitialized( ServletContextEvent contextEvent ) + { + WebApplicationContext wac = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + + SecuritySynchronization securitySync = wac.getBean( SecuritySynchronization.class ); + + repositoryTaskScheduler = + wac.getBean( "archivaTaskScheduler#repository", RepositoryArchivaTaskScheduler.class ); + + Properties archivaRuntimeProperties = wac.getBean( "archivaRuntimeProperties", Properties.class ); + + tqeRepoScanning = wac.getBean( "taskQueueExecutor#repository-scanning", ThreadedTaskQueueExecutor.class ); + + tqeIndexing = wac.getBean( "taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class ); + + plexusSisuBridge = wac.getBean( PlexusSisuBridge.class ); + + try + { + nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); + } + catch ( PlexusSisuBridgeException e ) + { + throw new RuntimeException( "Unable to get NexusIndexer: " + e.getMessage(), e ); + } + try + { + securitySync.startup(); + repositoryTaskScheduler.startup(); + Banner.display( (String) archivaRuntimeProperties.get( "archiva.version" ) ); + } + catch ( ArchivaException e ) + { + throw new RuntimeException( "Unable to properly startup archiva: " + e.getMessage(), e ); + } + } + + public void contextDestroyed( ServletContextEvent contextEvent ) + { + WebApplicationContext applicationContext = + WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); + + // TODO check this stop + + /* + if ( applicationContext != null && applicationContext instanceof ClassPathXmlApplicationContext ) + { + ( (ClassPathXmlApplicationContext) applicationContext ).close(); + } */ + + if ( applicationContext != null ) //&& applicationContext instanceof PlexusWebApplicationContext ) + { + // stop task queue executors + stopTaskQueueExecutor( tqeDbScanning ); + stopTaskQueueExecutor( tqeRepoScanning ); + stopTaskQueueExecutor( tqeIndexing ); + + // stop the DefaultArchivaTaskScheduler and its scheduler + if ( repositoryTaskScheduler != null ) + { + try + { + repositoryTaskScheduler.stop(); + } + catch ( SchedulerException e ) + { + e.printStackTrace(); + } + + try + { + // shutdown the scheduler, otherwise Quartz scheduler and Threads still exists + Field schedulerField = repositoryTaskScheduler.getClass().getDeclaredField( "scheduler" ); + schedulerField.setAccessible( true ); + + DefaultScheduler scheduler = (DefaultScheduler) schedulerField.get( repositoryTaskScheduler ); + scheduler.stop(); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + + // close the application context + //applicationContext.close(); + // TODO fix close call + //applicationContext. + } + + // closing correctly indexer to close correctly lock and file + for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() ) + { + try + { + indexingContext.close( false ); + } + catch ( Exception e ) + { + contextEvent.getServletContext().log( "skip error closing indexingContext " + e.getMessage() ); + } + } + + } + + private void stopTaskQueueExecutor( ThreadedTaskQueueExecutor taskQueueExecutor ) + { + if ( taskQueueExecutor != null ) + { + Task currentTask = taskQueueExecutor.getCurrentTask(); + if ( currentTask != null ) + { + taskQueueExecutor.cancelTask( currentTask ); + } + + try + { + taskQueueExecutor.stop(); + ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor ); + if ( service != null ) + { + service.shutdown(); + } + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + } + + private ExecutorService getExecutorServiceForTTQE( ThreadedTaskQueueExecutor ttqe ) + { + ExecutorService service = null; + try + { + Field executorServiceField = ttqe.getClass().getDeclaredField( "executorService" ); + executorServiceField.setAccessible( true ); + service = (ExecutorService) executorServiceField.get( ttqe ); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + return service; + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/Banner.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/Banner.java new file mode 100644 index 000000000..343358f19 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/Banner.java @@ -0,0 +1,229 @@ +package org.apache.archiva.web.startup; + +/* + * 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. + */ + +import org.apache.commons.lang.StringUtils; +import org.slf4j.LoggerFactory; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Banner + * + * @version $Id$ + */ +public class Banner +{ + private static final String eol = System.getProperty("line.separator"); + + public static String encode( String raw ) + { + // Canonicalize line ends to make them easier to process + raw = raw.replace("\r\n", "\n").replace("\r", "\n"); + + StringBuilder encoded = new StringBuilder(); + int rawlen = raw.length(); + + for ( int i = 0; i < rawlen; i++ ) + { + char c = raw.charAt( i ); + if ( c == '\\' ) + { + encoded.append( "$." ); + } + else if ( c == '$' ) + { + encoded.append( "$$" ); + } + else if ( c == '\n' ) + { + encoded.append( "$n" ); + } + else if ( Character.isDigit( c ) ) + { + encoded.append( c ); + } + else if ( Character.isLetter( c ) ) + { + encoded.append( rot13( c ) ); + } + else if ( i < raw.length() - 1 ) + { + char nc; + boolean done = false; + int count = 0; + for ( int n = i; !done; n++ ) + { + if ( n >= rawlen ) + { + break; + } + + nc = raw.charAt( n ); + + if ( nc != c ) + { + done = true; + } + else + { + count++; + } + } + if ( count < 3 ) + { + encoded.append( c ); + } + else + { + encoded.append( "$" ).append( String.valueOf( count ) ).append( c ); + i += count - 1; + } + } + else + { + encoded.append( c ); + } + } + + return encoded.toString(); + } + + public static String decode( String encoded ) + { + StringBuilder decoded = new StringBuilder(); + int enlen = encoded.length(); + for ( int i = 0; i < enlen; i++ ) + { + char c = encoded.charAt( i ); + if ( c == '$' ) + { + char nc = encoded.charAt( i + 1 ); + if ( nc == '$' ) + { + decoded.append( '$' ); + i++; + } + else if ( nc == '.' ) + { + decoded.append( '\\' ); + i++; + } + else if ( nc == 'n' ) + { + decoded.append( eol ); + i++; + } + else if ( Character.isDigit( nc ) ) + { + int count = 0; + int nn = i + 1; + while ( Character.isDigit( nc ) ) + { + count = ( count * 10 ); + count += ( nc - '0' ); + nc = encoded.charAt( ++nn ); + } + for ( int d = 0; d < count; d++ ) + { + decoded.append( nc ); + } + i = nn; + } + } + else if ( Character.isLetter( c ) ) + { + decoded.append( rot13( c ) ); + } + else + { + decoded.append( c ); + } + } + + return decoded.toString(); + } + + private static char rot13( char c ) + { + if ( ( c >= 'a' ) && ( c <= 'z' ) ) + { + char dc = c += 13; + if ( dc > 'z' ) + { + dc -= 26; + } + return dc; + } + else if ( ( c >= 'A' ) && ( c <= 'Z' ) ) + { + char dc = c += 13; + if ( dc > 'Z' ) + { + dc -= 26; + } + return dc; + } + else + { + return c; + } + } + + public static String injectVersion( String text, String version ) + { + Pattern pat = Pattern.compile( "#{2,}" ); + Matcher mat = pat.matcher( text ); + StringBuilder ret = new StringBuilder(); + int off = 0; + + while ( mat.find( off ) ) + { + ret.append( text.substring( off, mat.start() ) ); + String repl = mat.group(); + ret.append( StringUtils.center( version, repl.length() ) ); + off = mat.end(); + } + + ret.append( text.substring( off ) ); + + return ret.toString(); + } + + public static String getBanner( String version ) + { + String encodedBanner = "$26 $34_$n$15 /$._$7 /$34 $.$n$14 /`/@),$4 | Ba" + + " orunys bs nyy bs gur nycnpnf |$n$14 | (~' __| gbvyvat njnl ba " + + "gur Ncnpur Nepuvin |$n$6 _,--.$3_/ |$4 $.$5 cebwrpg grnz, V jbhyq y" + + "vxr gb$3 |$n$4 ,' ,$5 ($3 |$5 $.$5 jrypbzr lbh gb Nepuvin$6 |$" + + "n$4 | ($6 $. /$6 | $32# |$n$5 $. )$._/ ,_/$7 |$36 |$n$5 / /$3 " + + "( |/$9 | uggc://nepuvin.ncnpur.bet/ |$n$4 ( |$4 ( |$10 | hf" + + "ref@nepuvin.ncnpur.bet$7 |$n$5 $.|$5 $.|$11 $.$34_/$n$n"; + + return injectVersion( decode( encodedBanner ), version ); + } + + public static void display( String version ) + { + String banner = getBanner( version ); + LoggerFactory.getLogger( Banner.class ).info( StringUtils.repeat( "_", 25 ) + eol + banner ); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java new file mode 100644 index 000000000..76d81feef --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java @@ -0,0 +1,245 @@ +package org.apache.archiva.web.startup; + +/* + * 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. + */ + +import org.apache.archiva.common.ArchivaException; +import org.apache.archiva.configuration.ArchivaConfiguration; +import org.apache.archiva.configuration.ConfigurationNames; +import org.apache.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.archiva.security.common.ArchivaRoleConstants; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.codehaus.plexus.redback.rbac.RBACManager; +import org.codehaus.plexus.redback.rbac.RbacManagerException; +import org.codehaus.plexus.redback.rbac.UserAssignment; +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.role.RoleManagerException; +import org.codehaus.plexus.redback.system.check.EnvironmentCheck; +import org.codehaus.plexus.redback.users.UserManager; +import org.codehaus.plexus.registry.Registry; +import org.codehaus.plexus.registry.RegistryListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import javax.inject.Inject; +import javax.inject.Named; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * ConfigurationSynchronization + * + * @version $Id$ + */ +@Service +public class SecuritySynchronization + implements RegistryListener +{ + private Logger log = LoggerFactory.getLogger( SecuritySynchronization.class ); + + @Inject + private RoleManager roleManager; + + @Inject + @Named( value = "rBACManager#cached" ) + private RBACManager rbacManager; + + private Map checkers; + + @Inject + private ArchivaConfiguration archivaConfiguration; + + @Inject + private ApplicationContext applicationContext; + + @PostConstruct + public void initialize() + { + checkers = getBeansOfType( EnvironmentCheck.class ); + } + + protected Map getBeansOfType( Class clazz ) + { + //TODO do some caching here !!! + // olamy : with plexus we get only roleHint + // as per convention we named spring bean role#hint remove role# if exists + Map springBeans = applicationContext.getBeansOfType( clazz ); + + Map beans = new HashMap( springBeans.size() ); + + for ( Entry entry : springBeans.entrySet() ) + { + String key = StringUtils.substringAfterLast( entry.getKey(), "#" ); + beans.put( key, entry.getValue() ); + } + return beans; + } + + public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + if ( ConfigurationNames.isManagedRepositories( propertyName ) ) + { + synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() ); + } + } + + public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + /* do nothing */ + } + + private void synchConfiguration( List repos ) + { + // NOTE: Remote Repositories do not have roles or security placed around them. + + for ( ManagedRepositoryConfiguration repoConfig : repos ) + { + // manage roles for repositories + try + { + if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, + repoConfig.getId() ) ) + { + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, + repoConfig.getId() ); + } + else + { + roleManager.verifyTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, + repoConfig.getId() ); + } + + if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, + repoConfig.getId() ) ) + { + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, + repoConfig.getId() ); + } + else + { + roleManager.verifyTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, + repoConfig.getId() ); + } + } + catch ( RoleManagerException e ) + { + // Log error. + log.error( "Unable to create roles for configured repositories: " + e.getMessage(), e ); + } + } + } + + public void startup() + throws ArchivaException + { + executeEnvironmentChecks(); + + synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() ); + archivaConfiguration.addChangeListener( this ); + + if ( archivaConfiguration.isDefaulted() ) + { + assignRepositoryObserverToGuestUser( archivaConfiguration.getConfiguration().getManagedRepositories() ); + } + } + + private void executeEnvironmentChecks() + throws ArchivaException + { + if ( ( checkers == null ) || CollectionUtils.isEmpty( checkers.values() ) ) + { + throw new ArchivaException( + "Unable to initialize the Redback Security Environment, " + "no Environment Check components found." ); + } + + List violations = new ArrayList(); + + for ( Entry entry : checkers.entrySet() ) + { + EnvironmentCheck check = entry.getValue(); + List v = new ArrayList(); + check.validateEnvironment( v ); + log.info( "Environment Check: " + entry.getKey() + " -> " + v.size() + " violation(s)" ); + for ( String s : v ) + { + violations.add( "[" + entry.getKey() + "] " + s ); + } + } + + if ( CollectionUtils.isNotEmpty( violations ) ) + { + StringBuilder msg = new StringBuilder(); + msg.append( "EnvironmentCheck Failure.\n" ); + msg.append( "======================================================================\n" ); + msg.append( " ENVIRONMENT FAILURE !! \n" ); + msg.append( "\n" ); + + for ( String violation : violations ) + { + msg.append( violation ).append( "\n" ); + } + + msg.append( "\n" ); + msg.append( "======================================================================" ); + log.error( msg.toString() ); + + throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size() + + "] violation(s) encountered, See log for details." ); + } + } + + private void assignRepositoryObserverToGuestUser( List repos ) + { + for ( ManagedRepositoryConfiguration repoConfig : repos ) + { + String repoId = repoConfig.getId(); + + String principal = UserManager.GUEST_USERNAME; + + try + { + UserAssignment ua; + + if ( rbacManager.userAssignmentExists( principal ) ) + { + ua = rbacManager.getUserAssignment( principal ); + } + else + { + ua = rbacManager.createUserAssignment( principal ); + } + + ua.addRoleName( ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) ); + rbacManager.saveUserAssignment( ua ); + } + catch ( RbacManagerException e ) + { + log.warn( "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) + "] to " + + principal + " user.", e ); + } + } + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml new file mode 100755 index 000000000..261b88532 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/META-INF/spring-context.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties new file mode 100644 index 000000000..22d52654e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -0,0 +1,21 @@ +# +# 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. +# +# -------------------------------------------------------------------- +# Archiva webapp i18n default en file +# -------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties new file mode 100644 index 000000000..9ad0368a2 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties @@ -0,0 +1,21 @@ +# +# 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. +# +# -------------------------------------------------------------------- +# Archiva webapp i18n fr file +# -------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security.properties new file mode 100644 index 000000000..2074ef020 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security.properties @@ -0,0 +1,27 @@ +# +# 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. +# + +# -------------------------------------------------------------------- +# Email Settings + +# The subject line for the email message. +email.validation.subject=Welcome to Archiva + +# Feedback page +email.feedback.path=http://archiva.apache.org/mail-lists.html diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security_en.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security_en.properties new file mode 100644 index 000000000..661b0cba7 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/security_en.properties @@ -0,0 +1,20 @@ +# +# 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. +# + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java new file mode 100644 index 000000000..3e8cf50a4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java @@ -0,0 +1,77 @@ +package org.apache.archiva.security; + +/* + * 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. + */ + +import java.util.Collections; +import java.util.List; + +/** + * UserRepositories stub used for testing. + * + * @version $Id$ + */ +public class UserRepositoriesStub + implements UserRepositories +{ + private List repoIds = Collections.singletonList( "test-repo" ); + + public void createMissingRepositoryRoles( String repoId ) + throws ArchivaSecurityException + { + } + + public List getObservableRepositoryIds( String principal ) + throws ArchivaSecurityException + { + return repoIds; + } + + public void setObservableRepositoryIds( List repoIds ) + { + this.repoIds = repoIds; + } + + public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) + throws ArchivaSecurityException + { + return false; + } + + public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) + { + return false; + } + + public List getManagableRepositoryIds( String principal ) + throws ArchivaSecurityException + { + return null; + } + + public List getRepoIds() + { + return repoIds; + } + + public void setRepoIds( List repoIds ) + { + this.repoIds = repoIds; + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java new file mode 100644 index 000000000..90a5be6d5 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java @@ -0,0 +1,125 @@ +package org.apache.archiva.web.rss; +/* + * 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. + */ + +import org.apache.archiva.metadata.repository.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.UserRepositories; +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.role.RoleManagerException; +import org.codehaus.plexus.redback.role.model.RedbackRoleModel; +import org.springframework.stereotype.Service; + +import java.net.URL; +import java.util.Collections; +import java.util.List; + +/** + * @author Olivier Lamy + */ +@Service("RoleManagerStub") +public class RoleManagerStub + implements RoleManager +{ + public void loadRoleModel( URL resourceLocation ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void loadRoleModel( RedbackRoleModel model ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void createTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRole( String templateId, String oldResource, String newResource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignTemplatedRole( String templateId, String resource, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean roleExists( String roleId ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean templatedRoleExists( String templateId, String resource ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public RedbackRoleModel getModel() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void verifyTemplatedRole( String templateID, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java new file mode 100644 index 000000000..9a55321c9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java @@ -0,0 +1,222 @@ +package org.apache.archiva.web.rss; + +/* + * 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. + */ + +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.HttpException; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; +import com.meterware.servletunit.ServletRunner; +import com.meterware.servletunit.ServletUnitClient; +import junit.framework.TestCase; +import org.apache.commons.codec.Encoder; +import org.apache.commons.codec.binary.Base64; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; + +@RunWith( BlockJUnit4ClassRunner.class ) +public class RssFeedServletTest + extends TestCase +{ + private ServletRunner sr; + + private ServletUnitClient client; + + static String PREVIOUS_ARCHIVA_PATH; + + @BeforeClass + public static void initConfigurationPath() + throws Exception + { + PREVIOUS_ARCHIVA_PATH = System.getProperty( "archiva.user.configFileName" ); + System.setProperty( "archiva.user.configFileName", + System.getProperty( "test.resources.path/" ) + "empty-archiva.xml" ); + } + + @AfterClass + public static void restoreConfigurationPath() + throws Exception + { + System.setProperty( "archiva.user.configFileName", PREVIOUS_ARCHIVA_PATH ); + } + + @Before + public void setUp() + throws Exception + { + sr = new ServletRunner( new File( "src/test/webapp/WEB-INF/feedServletTest-web.xml" ) ); + client = sr.newClient(); + } + + @After + public void tearDown() + throws Exception + { + if ( client != null ) + { + client.clearContents(); + } + + if ( sr != null ) + { + sr.shutDown(); + } + + super.tearDown(); + } + + @Test + public void testRetrieveServlet() + throws Exception + { + + RssFeedServlet servlet = + (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet(); + assertNotNull( servlet ); + } + + @Test + public void testRequestNewArtifactsInRepo() + throws Exception + { + RssFeedServlet servlet = + (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet(); + assertNotNull( servlet ); + + WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" ); + + Base64 encoder = new Base64( 0, new byte[0] ); + String userPass = "user1:password1"; + String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); + request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); + + WebResponse response = client.getResponse( request ); + assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) ); + assertNotNull( "Should have recieved a response", response ); + assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() ); + + } + + @Test + public void testRequestNewVersionsOfArtifact() + throws Exception + { + RssFeedServlet servlet = (RssFeedServlet) client.newInvocation( + "http://localhost/feeds/org/apache/archiva/artifact-two" ).getServlet(); + assertNotNull( servlet ); + + WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" ); + + Base64 encoder = new Base64( 0, new byte[0] ); + String userPass = "user1:password1"; + String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); + request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); + + WebResponse response = client.getResponse( request ); + assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) ); + assertNotNull( "Should have recieved a response", response ); + assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() ); + } + + @Ignore + public void XXX_testInvalidRequest() + throws Exception + { + RssFeedServlet servlet = + (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet(); + assertNotNull( servlet ); + + try + { + WebResponse resp = client.getResponse( "http://localhost/feeds?invalid_param=xxx" ); + assertEquals( HttpServletResponse.SC_BAD_REQUEST, resp.getResponseCode() ); + } + catch ( HttpException he ) + { + assertEquals( "Should have been a bad request response code.", HttpServletResponse.SC_BAD_REQUEST, + he.getResponseCode() ); + } + } + + @Ignore + public void XXX_testInvalidAuthenticationRequest() + throws Exception + { + RssFeedServlet servlet = + (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet(); + assertNotNull( servlet ); + + WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" ); + + Encoder encoder = new Base64(); + String userPass = "unauthUser:unauthPass"; + String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) ); + request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); + + try + { + WebResponse resp = client.getResponse( request ); + assertEquals( HttpServletResponse.SC_UNAUTHORIZED, resp.getResponseCode() ); + } + catch ( HttpException he ) + { + assertEquals( "Should have been a unauthorized response.", HttpServletResponse.SC_UNAUTHORIZED, + he.getResponseCode() ); + } + } + + @Ignore + public void XXX_testUnauthorizedRequest() + throws Exception + { + RssFeedServlet servlet = + (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet(); + assertNotNull( servlet ); + + WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" ); + + Base64 encoder = new Base64( 0, new byte[0] ); + String userPass = "user1:password1"; + String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); + request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); + + try + { + WebResponse resp = client.getResponse( request ); + assertEquals( HttpServletResponse.SC_UNAUTHORIZED, resp.getResponseCode() ); + } + catch ( HttpException he ) + { + assertEquals( "Should have been a unauthorized response.", HttpServletResponse.SC_UNAUTHORIZED, + he.getResponseCode() ); + } + } + + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java new file mode 100644 index 000000000..918816df5 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java @@ -0,0 +1,588 @@ +package org.apache.archiva.web.rss; + +/* + * 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. + */ + +import org.codehaus.plexus.redback.authentication.AuthenticationDataSource; +import org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.authorization.AuthorizationResult; +import org.codehaus.plexus.redback.keys.KeyManager; +import org.codehaus.plexus.redback.policy.AccountLockedException; +import org.codehaus.plexus.redback.policy.UserSecurityPolicy; +import org.codehaus.plexus.redback.system.DefaultSecuritySession; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserManager; +import org.codehaus.plexus.redback.users.UserManagerListener; +import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.codehaus.plexus.redback.users.UserQuery; +import org.codehaus.plexus.redback.users.jdo.JdoUser; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * SecuritySystem stub used for testing. + * + * @version $Id$ + */ +public class SecuritySystemStub + implements SecuritySystem +{ + Map users = new HashMap(); + + List repoIds = new ArrayList(); + + public SecuritySystemStub() + { + users.put( "user1", "password1" ); + users.put( "user2", "password2" ); + users.put( "user3", "password3" ); + + repoIds.add( "test-repo" ); + } + + public SecuritySession authenticate( AuthenticationDataSource source ) + throws AuthenticationException, UserNotFoundException, AccountLockedException + { + AuthenticationResult result = null; + SecuritySession session = null; + + if ( users.get( source.getPrincipal() ) != null ) + { + result = new AuthenticationResult( true, source.getPrincipal(), null ); + + User user = new JdoUser(); + user.setUsername( source.getPrincipal() ); + user.setPassword( users.get( source.getPrincipal() ) ); + + session = new DefaultSecuritySession( result, user ); + } + else + { + result = new AuthenticationResult( false, source.getPrincipal(), null ); + session = new DefaultSecuritySession( result ); + } + return session; + } + + public AuthorizationResult authorize( SecuritySession arg0, Object arg1 ) + throws AuthorizationException + { + return null; + } + + public AuthorizationResult authorize( SecuritySession arg0, Object arg1, Object arg2 ) + throws AuthorizationException + { + AuthorizationResult result = new AuthorizationResult( true, arg1, null ); + + return result; + } + + public String getAuthenticatorId() + { + return null; + } + + public String getAuthorizerId() + { + return null; + } + + public KeyManager getKeyManager() + { + return null; + } + + public UserSecurityPolicy getPolicy() + { + return null; + } + + public String getUserManagementId() + { + return null; + } + + public UserManager getUserManager() + { + return new UserManager() + { + public boolean isReadOnly() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getId() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void addUserManagerListener( UserManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeUserManagerListener( UserManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public User createUser( String username, String fullName, String emailAddress ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User createGuestUser() + { + return new User() + { + public Object getPrincipal() + { + return "guest"; + } + + public String getUsername() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setUsername( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getFullName() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFullName( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEmail() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEmail( String address ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPassword( String rawPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEncodedPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastPasswordChange() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastPasswordChange( Date passwordChangeDate ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getPreviousEncodedPasswords() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPreviousEncodedPasswords( List encodedPasswordList ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addPreviousEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPermanent() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPermanent( boolean permanent ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isLocked() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLocked( boolean locked ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPasswordChangeRequired() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPasswordChangeRequired( boolean changeRequired ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isValidated() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setValidated( boolean valid ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getCountFailedLoginAttempts() + { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setCountFailedLoginAttempts( int count ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getAccountCreationDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setAccountCreationDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastLoginDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastLoginDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + + public UserQuery createUserQuery() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getUsers() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getUsers( boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User addUser( User user ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User updateUser( User user ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User findUser( String username ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User getGuestUser() + throws UserNotFoundException + { + return new User() + { + public Object getPrincipal() + { + return "guest"; + } + + public String getUsername() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setUsername( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getFullName() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFullName( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEmail() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEmail( String address ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPassword( String rawPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEncodedPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastPasswordChange() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastPasswordChange( Date passwordChangeDate ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getPreviousEncodedPasswords() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPreviousEncodedPasswords( List encodedPasswordList ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addPreviousEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPermanent() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPermanent( boolean permanent ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isLocked() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLocked( boolean locked ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPasswordChangeRequired() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPasswordChangeRequired( boolean changeRequired ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isValidated() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setValidated( boolean valid ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getCountFailedLoginAttempts() + { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setCountFailedLoginAttempts( int count ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getAccountCreationDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setAccountCreationDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastLoginDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastLoginDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + + public List findUsersByUsernameKey( String usernameKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByFullNameKey( String fullNameKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByEmailKey( String emailKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByQuery( UserQuery query ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User findUser( Object principal ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean userExists( Object principal ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void deleteUser( Object principal ) + throws UserNotFoundException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void deleteUser( String username ) + throws UserNotFoundException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addUserUnchecked( User user ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void eraseDatabase() + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public User updateUser( User user, boolean passwordChangeRequired ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + + public boolean isAuthenticated( AuthenticationDataSource arg0 ) + throws AuthenticationException, UserNotFoundException, AccountLockedException + { + return false; + } + + public boolean isAuthorized( SecuritySession arg0, Object arg1 ) + throws AuthorizationException + { + return false; + } + + public boolean isAuthorized( SecuritySession arg0, Object arg1, Object arg2 ) + throws AuthorizationException + { + if ( repoIds.contains( arg2 ) ) + { + return true; + } + + return false; + } + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java new file mode 100644 index 000000000..482637f91 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java @@ -0,0 +1,224 @@ +package org.apache.archiva.webtest.memory; + +/* + * 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. + */ + +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.MetadataFacet; +import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; +import org.apache.archiva.metadata.repository.MetadataRepository; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +public class TestMetadataRepository + implements MetadataRepository +{ + private static final String TEST_REPO = "test-repo"; + + private static final String TEST_NAMESPACE = "org.apache.archiva"; + + private List artifacts = new ArrayList(); + + private List versions = new ArrayList(); + + public TestMetadataRepository() + { + Date whenGathered = new Date( 123456789 ); + + addArtifact( "artifact-one", "1.0", whenGathered ); + addArtifact( "artifact-one", "1.1", whenGathered ); + addArtifact( "artifact-one", "2.0", whenGathered ); + addArtifact( "artifact-two", "1.0.1", whenGathered ); + addArtifact( "artifact-two", "1.0.2", whenGathered ); + addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered ); + addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered ); + addArtifact( "artifact-four", "1.1-beta-2", whenGathered ); + } + + private void addArtifact( String projectId, String projectVersion, Date whenGathered ) + { + ArtifactMetadata artifact = new ArtifactMetadata(); + artifact.setFileLastModified( System.currentTimeMillis() ); + artifact.setNamespace( TEST_NAMESPACE ); + artifact.setProjectVersion( projectVersion ); + artifact.setVersion( projectVersion ); + artifact.setId( projectId + "-" + projectVersion + ".jar" ); + artifact.setProject( projectId ); + artifact.setRepositoryId( TEST_REPO ); + artifact.setWhenGathered( whenGathered ); + artifacts.add( artifact ); + + versions.add( projectVersion ); + } + + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + { + throw new UnsupportedOperationException(); + } + + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + { + throw new UnsupportedOperationException(); + } + + public Collection getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + { + throw new UnsupportedOperationException(); + } + + public Collection getProjectReferences( String repoId, String namespace, String projectId, + String projectVersion ) + { + throw new UnsupportedOperationException(); + } + + public Collection getRootNamespaces( String repoId ) + { + throw new UnsupportedOperationException(); + } + + public Collection getNamespaces( String repoId, String namespace ) + { + throw new UnsupportedOperationException(); + } + + public Collection getProjects( String repoId, String namespace ) + { + throw new UnsupportedOperationException(); + } + + public Collection getProjectVersions( String repoId, String namespace, String projectId ) + { + return versions; + } + + public void updateProject( String repoId, ProjectMetadata project ) + { + throw new UnsupportedOperationException(); + } + + public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion, + ArtifactMetadata artifactMeta ) + { + throw new UnsupportedOperationException(); + } + + public void updateProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) + { + throw new UnsupportedOperationException(); + } + + public void updateNamespace( String repoId, String namespace ) + { + throw new UnsupportedOperationException(); + } + + public List getMetadataFacets( String repodId, String facetId ) + { + return Collections.emptyList(); + } + + public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name ) + { + throw new UnsupportedOperationException(); + } + + public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet ) + { + throw new UnsupportedOperationException(); + } + + public void removeMetadataFacets( String repositoryId, String facetId ) + { + throw new UnsupportedOperationException(); + } + + public void removeMetadataFacet( String repoId, String facetId, String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getArtifactsByDateRange( String repoId, Date startTime, Date endTime ) + { + return artifacts; + } + + public Collection getRepositories() + { + return Collections.singletonList( TEST_REPO ); + } + + public List getArtifactsByChecksum( String repoId, String checksum ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeRepository( String repoId ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + { + return artifacts; + } + + public void save() + { + } + + public void close() + { + } + + public void revert() + { + throw new UnsupportedOperationException(); + } + + public boolean canObtainAccess( Class aClass ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Object obtainAccess( Class aClass ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getArtifacts( String repositoryId ) + { + return artifacts; + } +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java new file mode 100644 index 000000000..2a5ba06c6 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java @@ -0,0 +1,160 @@ +package org.apache.archiva.webtest.memory; + +/* + * 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. + */ + +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; +import org.apache.archiva.metadata.repository.MetadataResolver; +import org.apache.archiva.metadata.repository.RepositorySession; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class TestMetadataResolver + implements MetadataResolver +{ + private Map projectVersions = new HashMap(); + + private Map> artifacts = new HashMap>(); + + private Map> references = + new HashMap>(); + + private Map> namespaces = new HashMap>(); + + private Map> projectsInNamespace = new HashMap>(); + + private Map> versionsInProject = new HashMap>(); + + public ProjectVersionMetadata resolveProjectVersion( RepositorySession repositorySession, String repoId, + String namespace, String projectId, String projectVersion ) + { + return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); + } + + public Collection resolveProjectReferences( RepositorySession repositorySession, + String repoId, String namespace, + String projectId, String projectVersion ) + { + Collection projectVersionReferences = + references.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); + return projectVersionReferences; + } + + public Collection resolveRootNamespaces( RepositorySession repositorySession, String repoId ) + { + return resolveNamespaces( repositorySession, repoId, null ); + } + + public Collection resolveNamespaces( RepositorySession repositorySession, String repoId, + String baseNamespace ) + { + Set namespaces = new LinkedHashSet(); + int fromIndex = baseNamespace != null ? baseNamespace.length() + 1 : 0; + for ( String namespace : this.namespaces.get( repoId ) ) + { + if ( baseNamespace == null || namespace.startsWith( baseNamespace + "." ) ) + { + int i = namespace.indexOf( '.', fromIndex ); + if ( i >= 0 ) + { + namespaces.add( namespace.substring( fromIndex, i ) ); + } + else + { + namespaces.add( namespace.substring( fromIndex ) ); + } + } + } + return namespaces; + } + + public Collection resolveProjects( RepositorySession repositorySession, String repoId, String namespace ) + { + Collection list = projectsInNamespace.get( namespace ); + return list != null ? list : Collections.emptyList(); + } + + public Collection resolveProjectVersions( RepositorySession repositorySession, String repoId, + String namespace, String projectId ) + { + Collection list = versionsInProject.get( namespace + ":" + projectId ); + return list != null ? list : Collections.emptyList(); + } + + public Collection resolveArtifacts( RepositorySession repositorySession, String repoId, + String namespace, String projectId, String projectVersion ) + { + List artifacts = + this.artifacts.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); + return ( artifacts != null ? artifacts : Collections.emptyList() ); + } + + public void setProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) + { + projectVersions.put( createMapKey( repoId, namespace, projectId, versionMetadata.getId() ), versionMetadata ); + + Collection projects = projectsInNamespace.get( namespace ); + if ( projects == null ) + { + projects = new LinkedHashSet(); + projectsInNamespace.put( namespace, projects ); + } + projects.add( projectId ); + + String key = namespace + ":" + projectId; + Collection versions = versionsInProject.get( key ); + if ( versions == null ) + { + versions = new LinkedHashSet(); + versionsInProject.put( key, versions ); + } + versions.add( versionMetadata.getId() ); + } + + public void setArtifacts( String repoId, String namespace, String projectId, String projectVersion, + List artifacts ) + { + this.artifacts.put( createMapKey( repoId, namespace, projectId, projectVersion ), artifacts ); + } + + private String createMapKey( String repoId, String namespace, String projectId, String projectVersion ) + { + return repoId + ":" + namespace + ":" + projectId + ":" + projectVersion; + } + + public void setProjectReferences( String repoId, String namespace, String projectId, String projectVersion, + List references ) + { + this.references.put( createMapKey( repoId, namespace, projectId, projectVersion ), references ); + } + + public void setNamespaces( String repoId, List namespaces ) + { + this.namespaces.put( repoId, namespaces ); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java new file mode 100644 index 000000000..f311d97d3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java @@ -0,0 +1,42 @@ +package org.apache.archiva.webtest.memory; + +/* + * 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. + */ + +import org.apache.archiva.metadata.repository.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.springframework.stereotype.Service; + +@Service("repositorySessionFactory#test") +public class TestRepositorySessionFactory + implements RepositorySessionFactory +{ + private RepositorySession repositorySession; + + public void setRepositorySession( RepositorySession repositorySession ) + { + this.repositorySession = repositorySession; + } + + public RepositorySession createSession() + { + return repositorySession != null ? repositorySession : new RepositorySession( new TestMetadataRepository(), + new TestMetadataResolver() ); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/empty-archiva.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/empty-archiva.xml new file mode 100644 index 000000000..997d62b00 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/empty-archiva.xml @@ -0,0 +1,111 @@ + + + + + + 2 + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + + indexable-content + + **/*.txt + **/*.TXT + **/*.block + **/*.config + **/*.pom + **/*.xml + **/*.xsd + **/*.dtd + **/*.tld + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + + + update-db-artifact + create-missing-checksums + update-db-repository-metadata + validate-checksum + validate-signature + index-content + auto-remove + auto-rename + + + update-db-bad-content + + + + + 0 0 * * * ? + + index-artifact + update-db-project + validate-repository-metadata + index-archive-toc + update-db-bytecode-stats + index-public-methods + + + not-present-remove-db-artifact + not-present-remove-db-project + not-present-remove-indexed + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j.xml new file mode 100644 index 000000000..aecb237a7 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/log4j.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml new file mode 100644 index 000000000..6e3dc3ec3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/webapp/WEB-INF/feedServletTest-web.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/webapp/WEB-INF/feedServletTest-web.xml new file mode 100644 index 000000000..ad7386b15 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/webapp/WEB-INF/feedServletTest-web.xml @@ -0,0 +1,54 @@ + + + + + + Apache Archiva + + + org.springframework.web.context.ContextLoaderListener + + + + contextClass + org.codehaus.redback.components.springutils.CachingWebApplicationContext + + + + RssFeedServlet + org.apache.archiva.web.rss.RssFeedServlet + + + + RssFeedServlet + /feeds/* + + + + contextConfigLocation + + classpath*:/META-INF/spring-context.xml + classpath*:/spring-context-rss-servlet.xml + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp-common/pom.xml b/archiva-modules/archiva-web/archiva-webapp-common/pom.xml deleted file mode 100644 index 7f19d81f2..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/pom.xml +++ /dev/null @@ -1,307 +0,0 @@ - - - - 4.0.0 - - org.apache.archiva - archiva-web - 1.4-M3-SNAPSHOT - - - archiva-webapp-common - bundle - Archiva Web :: Webapp Common - - - - org.apache.archiva - metadata-repository-api - - - org.apache.archiva - archiva-configuration - - - org.apache.archiva - archiva-security-common - - - org.apache.archiva - archiva-rss - - - org.apache.archiva - archiva-security - - - org.codehaus.redback - redback-common-integrations - - - stax - stax-api - - - - - org.apache.archiva - archiva-plexus-bridge - - - org.apache.archiva - archiva-scheduler-repository - - - org.codehaus.redback - redback-rbac-model - - - org.codehaus.redback - redback-rbac-role-manager - - - org.codehaus.redback - redback-system - - - javax.servlet - servlet-api - provided - - - org.codehaus.redback.components - spring-taskqueue - - - org.codehaus.redback.components - spring-quartz - - - org.quartz-scheduler - quartz - - - c3p0 - c3p0 - - - javax.transaction - jta - - - - - org.springframework - spring-core - - - org.springframework - spring-beans - - - org.springframework - spring-context-support - - - org.springframework - spring-web - - - httpunit - httpunit - test - - - junit - junit - test - - - org.slf4j - slf4j-log4j12 - test - - - - - - - src/main/resources - - - src/main/filtered-resources - true - - - - - org.apache.felix - maven-bundle-plugin - - - org.apache.archiva.webapp.common - ${project.version} - - org.apache.archiva.web.spring;version=${project.version}, - org.apache.archiva.web.startup;version=${project.version} - - - javax.annotation, - javax.inject, - javax.servlet, - javax.servlet.http, - org.apache.archiva.common;version=${project.version}, - org.apache.archiva.common.plexusbridge;version=${project.version}, - org.apache.archiva.configuration;version=${project.version}, - org.apache.archiva.repository.events;version=${project.version}, - org.apache.archiva.scheduler.repository;version=${project.version}, - org.apache.archiva.security.common;version=${project.version}, - org.apache.commons.collections;version="[3.2,4)", - org.apache.commons.lang;version="[2.4,3)", - org.apache.maven.index, - org.apache.maven.index.context, - org.codehaus.plexus.redback.rbac, - org.codehaus.plexus.redback.role, - org.codehaus.plexus.redback.system.check, - org.codehaus.plexus.registry, - org.codehaus.plexus.taskqueue, - org.codehaus.plexus.taskqueue.execution, - org.codehaus.redback.components.scheduler, - org.quartz;version="[2,3)", - org.slf4j;resolution:=optional, - org.springframework*;version="[3,4)", - org.springframework.web*;version="[3,4)", - com.sun.syndication.feed.synd, - com.sun.syndication.io, - org.apache.archiva.metadata.repository, - org.apache.archiva.rss.processor, - org.apache.archiva.security, - org.apache.commons.codec, - org.apache.commons.codec.binary, - org.codehaus.plexus.redback.authentication, - org.codehaus.plexus.redback.authorization, - org.codehaus.plexus.redback.policy, - org.codehaus.plexus.redback.system, - org.codehaus.plexus.redback.users, - org.codehaus.redback.integration.filter.authentication - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${basedir}/target/archiva.xml - ${project.build.testOutputDirectory} - ${redbackTestJdbcUrl} - ${redbackTestJdbcDriver} - ${basedir} - - - - - - - - - svn-buildnumber - - - .svn - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - generate-resources - - create - - - - - false - false - - javasvn - - - - - - - - non-canonical-buildnumber - - - .svn - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - - - generate-resources - - create - - - - - false - false - NON-CANONICAL_{0,date,yyyy-MM-dd_HH-mm}_{1} - - timestamp - ${user.name} - - - - - - - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/filtered-resources/application.properties b/archiva-modules/archiva-web/archiva-webapp-common/src/main/filtered-resources/application.properties deleted file mode 100644 index 12806aa73..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/filtered-resources/application.properties +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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. -# -user.agent=Apache Archiva/${project.version} -archiva.version=${project.version} -archiva.buildNumber=${buildNumber} -archiva.timestamp=${timestamp} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java deleted file mode 100644 index eb7bb0043..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java +++ /dev/null @@ -1,335 +0,0 @@ -package org.apache.archiva.web.rss; - -/* - * 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. - */ - -import com.sun.syndication.feed.synd.SyndFeed; -import com.sun.syndication.io.FeedException; -import com.sun.syndication.io.SyndFeedOutput; -import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; -import org.apache.archiva.rss.processor.RssFeedProcessor; -import org.apache.archiva.security.AccessDeniedException; -import org.apache.archiva.security.ArchivaSecurityException; -import org.apache.archiva.security.PrincipalNotFoundException; -import org.apache.archiva.security.ServletAuthenticator; -import org.apache.archiva.security.UserRepositories; -import org.apache.archiva.security.common.ArchivaRoleConstants; -import org.apache.commons.codec.Decoder; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; -import org.codehaus.plexus.redback.authentication.AuthenticationException; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.AuthorizationException; -import org.codehaus.plexus.redback.authorization.UnauthorizedException; -import org.codehaus.plexus.redback.policy.AccountLockedException; -import org.codehaus.plexus.redback.policy.MustChangePasswordException; -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.users.UserManager; -import org.codehaus.plexus.redback.users.UserNotFoundException; -import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Servlet for handling rss feed requests. - */ -public class RssFeedServlet - extends HttpServlet -{ - public static final String MIME_TYPE = "application/rss+xml; charset=UTF-8"; - - private static final String COULD_NOT_GENERATE_FEED_ERROR = "Could not generate feed"; - - private static final String COULD_NOT_AUTHENTICATE_USER = "Could not authenticate user"; - - private static final String USER_NOT_AUTHORIZED = "User not authorized to access feed."; - - private Logger log = LoggerFactory.getLogger( RssFeedServlet.class ); - - private RssFeedProcessor processor; - - private WebApplicationContext wac; - - private UserRepositories userRepositories; - - private ServletAuthenticator servletAuth; - - private HttpAuthenticator httpAuth; - - private RepositorySessionFactory repositorySessionFactory; - - public void init( javax.servlet.ServletConfig servletConfig ) - throws ServletException - { - super.init( servletConfig ); - wac = WebApplicationContextUtils.getRequiredWebApplicationContext( servletConfig.getServletContext() ); - userRepositories = wac.getBean( UserRepositories.class ); - servletAuth = wac.getBean( ServletAuthenticator.class ); - httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class ); - // TODO: what if there are other types? - repositorySessionFactory = wac.getBean( "repositorySessionFactory", RepositorySessionFactory.class ); - } - - public void doGet( HttpServletRequest req, HttpServletResponse res ) - throws ServletException, IOException - { - String repoId = null; - String groupId = null; - String artifactId = null; - - String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" ); - if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 ) - { - artifactId = StringUtils.substringAfterLast( url, "/" ); - groupId = StringUtils.substringBeforeLast( StringUtils.substringAfter( url, "feeds/" ), "/" ); - groupId = StringUtils.replaceChars( groupId, '/', '.' ); - } - else if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) == 0 ) - { - repoId = StringUtils.substringAfterLast( url, "/" ); - } - else - { - res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Invalid request url." ); - return; - } - - try - { - Map map = new HashMap(); - SyndFeed feed = null; - - if ( isAllowed( req, repoId, groupId, artifactId ) ) - { - if ( repoId != null ) - { - // new artifacts in repo feed request - processor = wac.getBean( "rssFeedProcessor#new-artifacts", RssFeedProcessor.class ); - map.put( RssFeedProcessor.KEY_REPO_ID, repoId ); - } - else if ( ( groupId != null ) && ( artifactId != null ) ) - { - // TODO: this only works for guest - we could pass in the list of repos - // new versions of artifact feed request - processor = wac.getBean( "rssFeedProcessor#new-versions", RssFeedProcessor.class ); - map.put( RssFeedProcessor.KEY_GROUP_ID, groupId ); - map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId ); - } - } - else - { - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED ); - return; - } - - RepositorySession repositorySession = repositorySessionFactory.createSession(); - try - { - feed = processor.process( map, repositorySession.getRepository() ); - } - finally - { - repositorySession.close(); - } - if ( feed == null ) - { - res.sendError( HttpServletResponse.SC_NO_CONTENT, "No information available." ); - return; - } - - res.setContentType( MIME_TYPE ); - - if ( repoId != null ) - { - feed.setLink( req.getRequestURL().toString() ); - } - else if ( ( groupId != null ) && ( artifactId != null ) ) - { - feed.setLink( req.getRequestURL().toString() ); - } - - SyndFeedOutput output = new SyndFeedOutput(); - output.output( feed, res.getWriter() ); - } - catch ( UserNotFoundException unfe ) - { - log.debug( COULD_NOT_AUTHENTICATE_USER, unfe ); - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); - } - catch ( AccountLockedException acce ) - { - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); - } - catch ( AuthenticationException authe ) - { - log.debug( COULD_NOT_AUTHENTICATE_USER, authe ); - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); - } - catch ( FeedException ex ) - { - log.debug( COULD_NOT_GENERATE_FEED_ERROR, ex ); - res.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, COULD_NOT_GENERATE_FEED_ERROR ); - } - catch ( MustChangePasswordException e ) - { - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, COULD_NOT_AUTHENTICATE_USER ); - } - catch ( UnauthorizedException e ) - { - log.debug( e.getMessage() ); - if ( repoId != null ) - { - res.setHeader( "WWW-Authenticate", - "Basic realm=\"Repository Archiva Managed " + repoId + " Repository" ); - } - else - { - res.setHeader( "WWW-Authenticate", "Basic realm=\"Artifact " + groupId + ":" + artifactId ); - } - - res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED ); - } - } - - /** - * Basic authentication. - * - * @param req - * @param repositoryId TODO - * @param groupId TODO - * @param artifactId TODO - * @return - */ - private boolean isAllowed( HttpServletRequest req, String repositoryId, String groupId, String artifactId ) - throws UserNotFoundException, AccountLockedException, AuthenticationException, MustChangePasswordException, - UnauthorizedException - { - String auth = req.getHeader( "Authorization" ); - List repoIds = new ArrayList(); - - if ( repositoryId != null ) - { - repoIds.add( repositoryId ); - } - else if ( artifactId != null && groupId != null ) - { - if ( auth != null ) - { - if ( !auth.toUpperCase().startsWith( "BASIC " ) ) - { - return false; - } - - Decoder dec = new Base64(); - String usernamePassword = ""; - - try - { - usernamePassword = new String( (byte[]) dec.decode( auth.substring( 6 ).getBytes() ) ); - } - catch ( DecoderException ie ) - { - log.warn( "Error decoding username and password.", ie.getMessage() ); - } - - if ( usernamePassword == null || usernamePassword.trim().equals( "" ) ) - { - repoIds = getObservableRepos( UserManager.GUEST_USERNAME ); - } - else - { - String[] userCredentials = usernamePassword.split( ":" ); - repoIds = getObservableRepos( userCredentials[0] ); - } - } - else - { - repoIds = getObservableRepos( UserManager.GUEST_USERNAME ); - } - } - else - { - return false; - } - - for ( String repoId : repoIds ) - { - try - { - AuthenticationResult result = httpAuth.getAuthenticationResult( req, null ); - SecuritySession securitySession = httpAuth.getSecuritySession( req.getSession( true ) ); - - if ( servletAuth.isAuthenticated( req, result ) && servletAuth.isAuthorized( req, securitySession, - repoId, - ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ) ) - { - return true; - } - } - catch ( AuthorizationException e ) - { - - } - catch ( UnauthorizedException e ) - { - - } - } - - throw new UnauthorizedException( "Access denied." ); - } - - private List getObservableRepos( String principal ) - { - try - { - return userRepositories.getObservableRepositoryIds( principal ); - } - catch ( PrincipalNotFoundException e ) - { - log.warn( e.getMessage(), e ); - } - catch ( AccessDeniedException e ) - { - log.warn( e.getMessage(), e ); - } - catch ( ArchivaSecurityException e ) - { - log.warn( e.getMessage(), e ); - } - - return Collections.emptyList(); - } - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java deleted file mode 100644 index 23f013ba0..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.apache.archiva.web.runtime; -/* - * 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. - */ - -import org.apache.commons.lang.math.NumberUtils; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; -import javax.inject.Named; -import java.util.Properties; - -/** - * @author Olivier Lamy - * @since 1.4-M3 - */ -@Service( "archivaRuntimeInfo" ) -public class ArchivaRuntimeInfo -{ - - private String version; - - private String buildNumber; - - private long timestamp; - - - @Inject - public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties ) - { - this.version = (String) archivaRuntimeProperties.get( "archiva.version" ); - this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" ); - this.timestamp = NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) ); - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getBuildNumber() - { - return buildNumber; - } - - public void setBuildNumber( String buildNumber ) - { - this.buildNumber = buildNumber; - } - - public long getTimestamp() - { - return timestamp; - } - - public void setTimestamp( long timestamp ) - { - this.timestamp = timestamp; - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "ArchivaRuntimeInfo" ); - sb.append( "{version='" ).append( version ).append( '\'' ); - sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' ); - sb.append( ", timestamp=" ).append( timestamp ); - sb.append( '}' ); - return sb.toString(); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java deleted file mode 100644 index 582290284..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/spring/RepositoryListenerFactoryBean.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.archiva.web.spring; - -/* - * 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. - */ - -import org.apache.archiva.repository.events.RepositoryListener; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -import java.util.List; - -/** - * @todo though we will eventually remove this altogether, an interim cleanup would be to genericise this - * and replace the calls in RepositoryContentConsumers with calls to the same thing - */ -public class RepositoryListenerFactoryBean - implements FactoryBean, ApplicationContextAware -{ - - private ApplicationContext applicationContext; - - public void setApplicationContext( ApplicationContext applicationContext ) - throws BeansException - { - this.applicationContext = applicationContext; - } - - public Object getObject() - throws Exception - { - return applicationContext.getBeansOfType( RepositoryListener.class ).values(); - } - - @SuppressWarnings("unchecked") - public Class getObjectType() - { - return List.class; - } - - public boolean isSingleton() - { - return true; - } - - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java deleted file mode 100644 index 46aca0bb7..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/ArchivaStartup.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.apache.archiva.web.startup; - -/* - * 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. - */ - -import org.apache.archiva.common.ArchivaException; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; -import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; -import org.apache.maven.index.NexusIndexer; -import org.apache.maven.index.context.IndexingContext; -import org.codehaus.plexus.taskqueue.Task; -import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor; -import org.codehaus.redback.components.scheduler.DefaultScheduler; -import org.quartz.SchedulerException; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import java.lang.reflect.Field; -import java.util.Properties; -import java.util.concurrent.ExecutorService; - -/** - * ArchivaStartup - the startup of all archiva features in a deterministic order. - * - * @version $Id$ - */ -public class ArchivaStartup - implements ServletContextListener -{ - private ThreadedTaskQueueExecutor tqeDbScanning; - - private ThreadedTaskQueueExecutor tqeRepoScanning; - - private ThreadedTaskQueueExecutor tqeIndexing; - - private RepositoryArchivaTaskScheduler repositoryTaskScheduler; - - private PlexusSisuBridge plexusSisuBridge; - - private NexusIndexer nexusIndexer; - - public void contextInitialized( ServletContextEvent contextEvent ) - { - WebApplicationContext wac = - WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); - - SecuritySynchronization securitySync = wac.getBean( SecuritySynchronization.class ); - - repositoryTaskScheduler = - wac.getBean( "archivaTaskScheduler#repository", RepositoryArchivaTaskScheduler.class ); - - Properties archivaRuntimeProperties = wac.getBean( "archivaRuntimeProperties", Properties.class ); - - tqeRepoScanning = wac.getBean( "taskQueueExecutor#repository-scanning", ThreadedTaskQueueExecutor.class ); - - tqeIndexing = wac.getBean( "taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class ); - - plexusSisuBridge = wac.getBean( PlexusSisuBridge.class ); - - try - { - nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); - } - catch ( PlexusSisuBridgeException e ) - { - throw new RuntimeException( "Unable to get NexusIndexer: " + e.getMessage(), e ); - } - try - { - securitySync.startup(); - repositoryTaskScheduler.startup(); - Banner.display( (String) archivaRuntimeProperties.get( "archiva.version" ) ); - } - catch ( ArchivaException e ) - { - throw new RuntimeException( "Unable to properly startup archiva: " + e.getMessage(), e ); - } - } - - public void contextDestroyed( ServletContextEvent contextEvent ) - { - WebApplicationContext applicationContext = - WebApplicationContextUtils.getRequiredWebApplicationContext( contextEvent.getServletContext() ); - - // TODO check this stop - - /* - if ( applicationContext != null && applicationContext instanceof ClassPathXmlApplicationContext ) - { - ( (ClassPathXmlApplicationContext) applicationContext ).close(); - } */ - - if ( applicationContext != null ) //&& applicationContext instanceof PlexusWebApplicationContext ) - { - // stop task queue executors - stopTaskQueueExecutor( tqeDbScanning ); - stopTaskQueueExecutor( tqeRepoScanning ); - stopTaskQueueExecutor( tqeIndexing ); - - // stop the DefaultArchivaTaskScheduler and its scheduler - if ( repositoryTaskScheduler != null ) - { - try - { - repositoryTaskScheduler.stop(); - } - catch ( SchedulerException e ) - { - e.printStackTrace(); - } - - try - { - // shutdown the scheduler, otherwise Quartz scheduler and Threads still exists - Field schedulerField = repositoryTaskScheduler.getClass().getDeclaredField( "scheduler" ); - schedulerField.setAccessible( true ); - - DefaultScheduler scheduler = (DefaultScheduler) schedulerField.get( repositoryTaskScheduler ); - scheduler.stop(); - } - catch ( Exception e ) - { - e.printStackTrace(); - } - } - - // close the application context - //applicationContext.close(); - // TODO fix close call - //applicationContext. - } - - // closing correctly indexer to close correctly lock and file - for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() ) - { - try - { - indexingContext.close( false ); - } - catch ( Exception e ) - { - contextEvent.getServletContext().log( "skip error closing indexingContext " + e.getMessage() ); - } - } - - } - - private void stopTaskQueueExecutor( ThreadedTaskQueueExecutor taskQueueExecutor ) - { - if ( taskQueueExecutor != null ) - { - Task currentTask = taskQueueExecutor.getCurrentTask(); - if ( currentTask != null ) - { - taskQueueExecutor.cancelTask( currentTask ); - } - - try - { - taskQueueExecutor.stop(); - ExecutorService service = getExecutorServiceForTTQE( taskQueueExecutor ); - if ( service != null ) - { - service.shutdown(); - } - } - catch ( Exception e ) - { - e.printStackTrace(); - } - } - } - - private ExecutorService getExecutorServiceForTTQE( ThreadedTaskQueueExecutor ttqe ) - { - ExecutorService service = null; - try - { - Field executorServiceField = ttqe.getClass().getDeclaredField( "executorService" ); - executorServiceField.setAccessible( true ); - service = (ExecutorService) executorServiceField.get( ttqe ); - } - catch ( Exception e ) - { - e.printStackTrace(); - } - return service; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/Banner.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/Banner.java deleted file mode 100644 index 343358f19..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/Banner.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.apache.archiva.web.startup; - -/* - * 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. - */ - -import org.apache.commons.lang.StringUtils; -import org.slf4j.LoggerFactory; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Banner - * - * @version $Id$ - */ -public class Banner -{ - private static final String eol = System.getProperty("line.separator"); - - public static String encode( String raw ) - { - // Canonicalize line ends to make them easier to process - raw = raw.replace("\r\n", "\n").replace("\r", "\n"); - - StringBuilder encoded = new StringBuilder(); - int rawlen = raw.length(); - - for ( int i = 0; i < rawlen; i++ ) - { - char c = raw.charAt( i ); - if ( c == '\\' ) - { - encoded.append( "$." ); - } - else if ( c == '$' ) - { - encoded.append( "$$" ); - } - else if ( c == '\n' ) - { - encoded.append( "$n" ); - } - else if ( Character.isDigit( c ) ) - { - encoded.append( c ); - } - else if ( Character.isLetter( c ) ) - { - encoded.append( rot13( c ) ); - } - else if ( i < raw.length() - 1 ) - { - char nc; - boolean done = false; - int count = 0; - for ( int n = i; !done; n++ ) - { - if ( n >= rawlen ) - { - break; - } - - nc = raw.charAt( n ); - - if ( nc != c ) - { - done = true; - } - else - { - count++; - } - } - if ( count < 3 ) - { - encoded.append( c ); - } - else - { - encoded.append( "$" ).append( String.valueOf( count ) ).append( c ); - i += count - 1; - } - } - else - { - encoded.append( c ); - } - } - - return encoded.toString(); - } - - public static String decode( String encoded ) - { - StringBuilder decoded = new StringBuilder(); - int enlen = encoded.length(); - for ( int i = 0; i < enlen; i++ ) - { - char c = encoded.charAt( i ); - if ( c == '$' ) - { - char nc = encoded.charAt( i + 1 ); - if ( nc == '$' ) - { - decoded.append( '$' ); - i++; - } - else if ( nc == '.' ) - { - decoded.append( '\\' ); - i++; - } - else if ( nc == 'n' ) - { - decoded.append( eol ); - i++; - } - else if ( Character.isDigit( nc ) ) - { - int count = 0; - int nn = i + 1; - while ( Character.isDigit( nc ) ) - { - count = ( count * 10 ); - count += ( nc - '0' ); - nc = encoded.charAt( ++nn ); - } - for ( int d = 0; d < count; d++ ) - { - decoded.append( nc ); - } - i = nn; - } - } - else if ( Character.isLetter( c ) ) - { - decoded.append( rot13( c ) ); - } - else - { - decoded.append( c ); - } - } - - return decoded.toString(); - } - - private static char rot13( char c ) - { - if ( ( c >= 'a' ) && ( c <= 'z' ) ) - { - char dc = c += 13; - if ( dc > 'z' ) - { - dc -= 26; - } - return dc; - } - else if ( ( c >= 'A' ) && ( c <= 'Z' ) ) - { - char dc = c += 13; - if ( dc > 'Z' ) - { - dc -= 26; - } - return dc; - } - else - { - return c; - } - } - - public static String injectVersion( String text, String version ) - { - Pattern pat = Pattern.compile( "#{2,}" ); - Matcher mat = pat.matcher( text ); - StringBuilder ret = new StringBuilder(); - int off = 0; - - while ( mat.find( off ) ) - { - ret.append( text.substring( off, mat.start() ) ); - String repl = mat.group(); - ret.append( StringUtils.center( version, repl.length() ) ); - off = mat.end(); - } - - ret.append( text.substring( off ) ); - - return ret.toString(); - } - - public static String getBanner( String version ) - { - String encodedBanner = "$26 $34_$n$15 /$._$7 /$34 $.$n$14 /`/@),$4 | Ba" + - " orunys bs nyy bs gur nycnpnf |$n$14 | (~' __| gbvyvat njnl ba " + - "gur Ncnpur Nepuvin |$n$6 _,--.$3_/ |$4 $.$5 cebwrpg grnz, V jbhyq y" + - "vxr gb$3 |$n$4 ,' ,$5 ($3 |$5 $.$5 jrypbzr lbh gb Nepuvin$6 |$" + - "n$4 | ($6 $. /$6 | $32# |$n$5 $. )$._/ ,_/$7 |$36 |$n$5 / /$3 " + - "( |/$9 | uggc://nepuvin.ncnpur.bet/ |$n$4 ( |$4 ( |$10 | hf" + - "ref@nepuvin.ncnpur.bet$7 |$n$5 $.|$5 $.|$11 $.$34_/$n$n"; - - return injectVersion( decode( encodedBanner ), version ); - } - - public static void display( String version ) - { - String banner = getBanner( version ); - LoggerFactory.getLogger( Banner.class ).info( StringUtils.repeat( "_", 25 ) + eol + banner ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java deleted file mode 100644 index 76d81feef..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java +++ /dev/null @@ -1,245 +0,0 @@ -package org.apache.archiva.web.startup; - -/* - * 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. - */ - -import org.apache.archiva.common.ArchivaException; -import org.apache.archiva.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.ConfigurationNames; -import org.apache.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.security.common.ArchivaRoleConstants; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.codehaus.plexus.redback.rbac.RBACManager; -import org.codehaus.plexus.redback.rbac.RbacManagerException; -import org.codehaus.plexus.redback.rbac.UserAssignment; -import org.codehaus.plexus.redback.role.RoleManager; -import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.redback.system.check.EnvironmentCheck; -import org.codehaus.plexus.redback.users.UserManager; -import org.codehaus.plexus.registry.Registry; -import org.codehaus.plexus.registry.RegistryListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * ConfigurationSynchronization - * - * @version $Id$ - */ -@Service -public class SecuritySynchronization - implements RegistryListener -{ - private Logger log = LoggerFactory.getLogger( SecuritySynchronization.class ); - - @Inject - private RoleManager roleManager; - - @Inject - @Named( value = "rBACManager#cached" ) - private RBACManager rbacManager; - - private Map checkers; - - @Inject - private ArchivaConfiguration archivaConfiguration; - - @Inject - private ApplicationContext applicationContext; - - @PostConstruct - public void initialize() - { - checkers = getBeansOfType( EnvironmentCheck.class ); - } - - protected Map getBeansOfType( Class clazz ) - { - //TODO do some caching here !!! - // olamy : with plexus we get only roleHint - // as per convention we named spring bean role#hint remove role# if exists - Map springBeans = applicationContext.getBeansOfType( clazz ); - - Map beans = new HashMap( springBeans.size() ); - - for ( Entry entry : springBeans.entrySet() ) - { - String key = StringUtils.substringAfterLast( entry.getKey(), "#" ); - beans.put( key, entry.getValue() ); - } - return beans; - } - - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - if ( ConfigurationNames.isManagedRepositories( propertyName ) ) - { - synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() ); - } - } - - public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - /* do nothing */ - } - - private void synchConfiguration( List repos ) - { - // NOTE: Remote Repositories do not have roles or security placed around them. - - for ( ManagedRepositoryConfiguration repoConfig : repos ) - { - // manage roles for repositories - try - { - if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, - repoConfig.getId() ) ) - { - roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, - repoConfig.getId() ); - } - else - { - roleManager.verifyTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, - repoConfig.getId() ); - } - - if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, - repoConfig.getId() ) ) - { - roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, - repoConfig.getId() ); - } - else - { - roleManager.verifyTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, - repoConfig.getId() ); - } - } - catch ( RoleManagerException e ) - { - // Log error. - log.error( "Unable to create roles for configured repositories: " + e.getMessage(), e ); - } - } - } - - public void startup() - throws ArchivaException - { - executeEnvironmentChecks(); - - synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() ); - archivaConfiguration.addChangeListener( this ); - - if ( archivaConfiguration.isDefaulted() ) - { - assignRepositoryObserverToGuestUser( archivaConfiguration.getConfiguration().getManagedRepositories() ); - } - } - - private void executeEnvironmentChecks() - throws ArchivaException - { - if ( ( checkers == null ) || CollectionUtils.isEmpty( checkers.values() ) ) - { - throw new ArchivaException( - "Unable to initialize the Redback Security Environment, " + "no Environment Check components found." ); - } - - List violations = new ArrayList(); - - for ( Entry entry : checkers.entrySet() ) - { - EnvironmentCheck check = entry.getValue(); - List v = new ArrayList(); - check.validateEnvironment( v ); - log.info( "Environment Check: " + entry.getKey() + " -> " + v.size() + " violation(s)" ); - for ( String s : v ) - { - violations.add( "[" + entry.getKey() + "] " + s ); - } - } - - if ( CollectionUtils.isNotEmpty( violations ) ) - { - StringBuilder msg = new StringBuilder(); - msg.append( "EnvironmentCheck Failure.\n" ); - msg.append( "======================================================================\n" ); - msg.append( " ENVIRONMENT FAILURE !! \n" ); - msg.append( "\n" ); - - for ( String violation : violations ) - { - msg.append( violation ).append( "\n" ); - } - - msg.append( "\n" ); - msg.append( "======================================================================" ); - log.error( msg.toString() ); - - throw new ArchivaException( "Unable to initialize Redback Security Environment, [" + violations.size() - + "] violation(s) encountered, See log for details." ); - } - } - - private void assignRepositoryObserverToGuestUser( List repos ) - { - for ( ManagedRepositoryConfiguration repoConfig : repos ) - { - String repoId = repoConfig.getId(); - - String principal = UserManager.GUEST_USERNAME; - - try - { - UserAssignment ua; - - if ( rbacManager.userAssignmentExists( principal ) ) - { - ua = rbacManager.getUserAssignment( principal ); - } - else - { - ua = rbacManager.createUserAssignment( principal ); - } - - ua.addRoleName( ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) ); - rbacManager.saveUserAssignment( ua ); - } - catch ( RbacManagerException e ) - { - log.warn( "Unable to add role [" + ArchivaRoleConstants.toRepositoryObserverRoleName( repoId ) + "] to " - + principal + " user.", e ); - } - } - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml deleted file mode 100755 index 261b88532..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default.properties deleted file mode 100644 index 22d52654e..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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. -# -# -------------------------------------------------------------------- -# Archiva webapp i18n default en file -# -------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties b/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties deleted file mode 100644 index 9ad0368a2..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/i18n/default_fr.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# 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. -# -# -------------------------------------------------------------------- -# Archiva webapp i18n fr file -# -------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security.properties b/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security.properties deleted file mode 100644 index 2074ef020..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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. -# - -# -------------------------------------------------------------------- -# Email Settings - -# The subject line for the email message. -email.validation.subject=Welcome to Archiva - -# Feedback page -email.feedback.path=http://archiva.apache.org/mail-lists.html diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security_en.properties b/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security_en.properties deleted file mode 100644 index 661b0cba7..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/org/apache/archiva/security_en.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# 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. -# - - diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java deleted file mode 100644 index 3e8cf50a4..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.archiva.security; - -/* - * 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. - */ - -import java.util.Collections; -import java.util.List; - -/** - * UserRepositories stub used for testing. - * - * @version $Id$ - */ -public class UserRepositoriesStub - implements UserRepositories -{ - private List repoIds = Collections.singletonList( "test-repo" ); - - public void createMissingRepositoryRoles( String repoId ) - throws ArchivaSecurityException - { - } - - public List getObservableRepositoryIds( String principal ) - throws ArchivaSecurityException - { - return repoIds; - } - - public void setObservableRepositoryIds( List repoIds ) - { - this.repoIds = repoIds; - } - - public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) - throws ArchivaSecurityException - { - return false; - } - - public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) - { - return false; - } - - public List getManagableRepositoryIds( String principal ) - throws ArchivaSecurityException - { - return null; - } - - public List getRepoIds() - { - return repoIds; - } - - public void setRepoIds( List repoIds ) - { - this.repoIds = repoIds; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java deleted file mode 100644 index 90a5be6d5..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.archiva.web.rss; -/* - * 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. - */ - -import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; -import org.apache.archiva.security.ArchivaSecurityException; -import org.apache.archiva.security.UserRepositories; -import org.codehaus.plexus.redback.role.RoleManager; -import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.redback.role.model.RedbackRoleModel; -import org.springframework.stereotype.Service; - -import java.net.URL; -import java.util.Collections; -import java.util.List; - -/** - * @author Olivier Lamy - */ -@Service("RoleManagerStub") -public class RoleManagerStub - implements RoleManager -{ - public void loadRoleModel( URL resourceLocation ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void loadRoleModel( RedbackRoleModel model ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void createTemplatedRole( String templateId, String resource ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void removeTemplatedRole( String templateId, String resource ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void updateRole( String templateId, String oldResource, String newResource ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void assignRole( String roleId, String principal ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void assignRoleByName( String roleName, String principal ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void assignTemplatedRole( String templateId, String resource, String principal ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void unassignRole( String roleId, String principal ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void unassignRoleByName( String roleName, String principal ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean roleExists( String roleId ) - throws RoleManagerException - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean templatedRoleExists( String templateId, String resource ) - throws RoleManagerException - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public RedbackRoleModel getModel() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void verifyTemplatedRole( String templateID, String resource ) - throws RoleManagerException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java deleted file mode 100644 index 9a55321c9..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java +++ /dev/null @@ -1,222 +0,0 @@ -package org.apache.archiva.web.rss; - -/* - * 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. - */ - -import com.meterware.httpunit.GetMethodWebRequest; -import com.meterware.httpunit.HttpException; -import com.meterware.httpunit.WebRequest; -import com.meterware.httpunit.WebResponse; -import com.meterware.servletunit.ServletRunner; -import com.meterware.servletunit.ServletUnitClient; -import junit.framework.TestCase; -import org.apache.commons.codec.Encoder; -import org.apache.commons.codec.binary.Base64; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.BlockJUnit4ClassRunner; - -import javax.servlet.http.HttpServletResponse; -import java.io.File; - -@RunWith( BlockJUnit4ClassRunner.class ) -public class RssFeedServletTest - extends TestCase -{ - private ServletRunner sr; - - private ServletUnitClient client; - - static String PREVIOUS_ARCHIVA_PATH; - - @BeforeClass - public static void initConfigurationPath() - throws Exception - { - PREVIOUS_ARCHIVA_PATH = System.getProperty( "archiva.user.configFileName" ); - System.setProperty( "archiva.user.configFileName", - System.getProperty( "test.resources.path/" ) + "empty-archiva.xml" ); - } - - @AfterClass - public static void restoreConfigurationPath() - throws Exception - { - System.setProperty( "archiva.user.configFileName", PREVIOUS_ARCHIVA_PATH ); - } - - @Before - public void setUp() - throws Exception - { - sr = new ServletRunner( new File( "src/test/webapp/WEB-INF/feedServletTest-web.xml" ) ); - client = sr.newClient(); - } - - @After - public void tearDown() - throws Exception - { - if ( client != null ) - { - client.clearContents(); - } - - if ( sr != null ) - { - sr.shutDown(); - } - - super.tearDown(); - } - - @Test - public void testRetrieveServlet() - throws Exception - { - - RssFeedServlet servlet = - (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet(); - assertNotNull( servlet ); - } - - @Test - public void testRequestNewArtifactsInRepo() - throws Exception - { - RssFeedServlet servlet = - (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet(); - assertNotNull( servlet ); - - WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" ); - - Base64 encoder = new Base64( 0, new byte[0] ); - String userPass = "user1:password1"; - String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); - request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); - - WebResponse response = client.getResponse( request ); - assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) ); - assertNotNull( "Should have recieved a response", response ); - assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() ); - - } - - @Test - public void testRequestNewVersionsOfArtifact() - throws Exception - { - RssFeedServlet servlet = (RssFeedServlet) client.newInvocation( - "http://localhost/feeds/org/apache/archiva/artifact-two" ).getServlet(); - assertNotNull( servlet ); - - WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" ); - - Base64 encoder = new Base64( 0, new byte[0] ); - String userPass = "user1:password1"; - String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); - request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); - - WebResponse response = client.getResponse( request ); - assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) ); - assertNotNull( "Should have recieved a response", response ); - assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() ); - } - - @Ignore - public void XXX_testInvalidRequest() - throws Exception - { - RssFeedServlet servlet = - (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet(); - assertNotNull( servlet ); - - try - { - WebResponse resp = client.getResponse( "http://localhost/feeds?invalid_param=xxx" ); - assertEquals( HttpServletResponse.SC_BAD_REQUEST, resp.getResponseCode() ); - } - catch ( HttpException he ) - { - assertEquals( "Should have been a bad request response code.", HttpServletResponse.SC_BAD_REQUEST, - he.getResponseCode() ); - } - } - - @Ignore - public void XXX_testInvalidAuthenticationRequest() - throws Exception - { - RssFeedServlet servlet = - (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet(); - assertNotNull( servlet ); - - WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" ); - - Encoder encoder = new Base64(); - String userPass = "unauthUser:unauthPass"; - String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) ); - request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); - - try - { - WebResponse resp = client.getResponse( request ); - assertEquals( HttpServletResponse.SC_UNAUTHORIZED, resp.getResponseCode() ); - } - catch ( HttpException he ) - { - assertEquals( "Should have been a unauthorized response.", HttpServletResponse.SC_UNAUTHORIZED, - he.getResponseCode() ); - } - } - - @Ignore - public void XXX_testUnauthorizedRequest() - throws Exception - { - RssFeedServlet servlet = - (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet(); - assertNotNull( servlet ); - - WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" ); - - Base64 encoder = new Base64( 0, new byte[0] ); - String userPass = "user1:password1"; - String encodedUserPass = encoder.encodeToString( userPass.getBytes() ); - request.setHeaderField( "Authorization", "BASIC " + encodedUserPass ); - - try - { - WebResponse resp = client.getResponse( request ); - assertEquals( HttpServletResponse.SC_UNAUTHORIZED, resp.getResponseCode() ); - } - catch ( HttpException he ) - { - assertEquals( "Should have been a unauthorized response.", HttpServletResponse.SC_UNAUTHORIZED, - he.getResponseCode() ); - } - } - - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java deleted file mode 100644 index 918816df5..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java +++ /dev/null @@ -1,588 +0,0 @@ -package org.apache.archiva.web.rss; - -/* - * 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. - */ - -import org.codehaus.plexus.redback.authentication.AuthenticationDataSource; -import org.codehaus.plexus.redback.authentication.AuthenticationException; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.AuthorizationException; -import org.codehaus.plexus.redback.authorization.AuthorizationResult; -import org.codehaus.plexus.redback.keys.KeyManager; -import org.codehaus.plexus.redback.policy.AccountLockedException; -import org.codehaus.plexus.redback.policy.UserSecurityPolicy; -import org.codehaus.plexus.redback.system.DefaultSecuritySession; -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.system.SecuritySystem; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserManager; -import org.codehaus.plexus.redback.users.UserManagerListener; -import org.codehaus.plexus.redback.users.UserNotFoundException; -import org.codehaus.plexus.redback.users.UserQuery; -import org.codehaus.plexus.redback.users.jdo.JdoUser; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * SecuritySystem stub used for testing. - * - * @version $Id$ - */ -public class SecuritySystemStub - implements SecuritySystem -{ - Map users = new HashMap(); - - List repoIds = new ArrayList(); - - public SecuritySystemStub() - { - users.put( "user1", "password1" ); - users.put( "user2", "password2" ); - users.put( "user3", "password3" ); - - repoIds.add( "test-repo" ); - } - - public SecuritySession authenticate( AuthenticationDataSource source ) - throws AuthenticationException, UserNotFoundException, AccountLockedException - { - AuthenticationResult result = null; - SecuritySession session = null; - - if ( users.get( source.getPrincipal() ) != null ) - { - result = new AuthenticationResult( true, source.getPrincipal(), null ); - - User user = new JdoUser(); - user.setUsername( source.getPrincipal() ); - user.setPassword( users.get( source.getPrincipal() ) ); - - session = new DefaultSecuritySession( result, user ); - } - else - { - result = new AuthenticationResult( false, source.getPrincipal(), null ); - session = new DefaultSecuritySession( result ); - } - return session; - } - - public AuthorizationResult authorize( SecuritySession arg0, Object arg1 ) - throws AuthorizationException - { - return null; - } - - public AuthorizationResult authorize( SecuritySession arg0, Object arg1, Object arg2 ) - throws AuthorizationException - { - AuthorizationResult result = new AuthorizationResult( true, arg1, null ); - - return result; - } - - public String getAuthenticatorId() - { - return null; - } - - public String getAuthorizerId() - { - return null; - } - - public KeyManager getKeyManager() - { - return null; - } - - public UserSecurityPolicy getPolicy() - { - return null; - } - - public String getUserManagementId() - { - return null; - } - - public UserManager getUserManager() - { - return new UserManager() - { - public boolean isReadOnly() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public String getId() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void addUserManagerListener( UserManagerListener listener ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void removeUserManagerListener( UserManagerListener listener ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public User createUser( String username, String fullName, String emailAddress ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User createGuestUser() - { - return new User() - { - public Object getPrincipal() - { - return "guest"; - } - - public String getUsername() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setUsername( String name ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getFullName() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setFullName( String name ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getEmail() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setEmail( String address ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getPassword() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPassword( String rawPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getEncodedPassword() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setEncodedPassword( String encodedPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getLastPasswordChange() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLastPasswordChange( Date passwordChangeDate ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public List getPreviousEncodedPasswords() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPreviousEncodedPasswords( List encodedPasswordList ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void addPreviousEncodedPassword( String encodedPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isPermanent() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPermanent( boolean permanent ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isLocked() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLocked( boolean locked ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isPasswordChangeRequired() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPasswordChangeRequired( boolean changeRequired ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isValidated() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setValidated( boolean valid ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public int getCountFailedLoginAttempts() - { - return 0; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setCountFailedLoginAttempts( int count ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getAccountCreationDate() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setAccountCreationDate( Date date ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getLastLoginDate() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLastLoginDate( Date date ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - }; - } - - public UserQuery createUserQuery() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getUsers() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getUsers( boolean orderAscending ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User addUser( User user ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User updateUser( User user ) - throws UserNotFoundException - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User findUser( String username ) - throws UserNotFoundException - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User getGuestUser() - throws UserNotFoundException - { - return new User() - { - public Object getPrincipal() - { - return "guest"; - } - - public String getUsername() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setUsername( String name ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getFullName() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setFullName( String name ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getEmail() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setEmail( String address ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getPassword() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPassword( String rawPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public String getEncodedPassword() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setEncodedPassword( String encodedPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getLastPasswordChange() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLastPasswordChange( Date passwordChangeDate ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public List getPreviousEncodedPasswords() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPreviousEncodedPasswords( List encodedPasswordList ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void addPreviousEncodedPassword( String encodedPassword ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isPermanent() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPermanent( boolean permanent ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isLocked() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLocked( boolean locked ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isPasswordChangeRequired() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setPasswordChangeRequired( boolean changeRequired ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean isValidated() - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setValidated( boolean valid ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public int getCountFailedLoginAttempts() - { - return 0; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setCountFailedLoginAttempts( int count ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getAccountCreationDate() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setAccountCreationDate( Date date ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Date getLastLoginDate() - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void setLastLoginDate( Date date ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - }; - } - - public List findUsersByUsernameKey( String usernameKey, boolean orderAscending ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List findUsersByFullNameKey( String fullNameKey, boolean orderAscending ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List findUsersByEmailKey( String emailKey, boolean orderAscending ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List findUsersByQuery( UserQuery query ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public User findUser( Object principal ) - throws UserNotFoundException - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public boolean userExists( Object principal ) - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public void deleteUser( Object principal ) - throws UserNotFoundException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void deleteUser( String username ) - throws UserNotFoundException - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void addUserUnchecked( User user ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void eraseDatabase() - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public User updateUser( User user, boolean passwordChangeRequired ) - throws UserNotFoundException - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - }; - } - - public boolean isAuthenticated( AuthenticationDataSource arg0 ) - throws AuthenticationException, UserNotFoundException, AccountLockedException - { - return false; - } - - public boolean isAuthorized( SecuritySession arg0, Object arg1 ) - throws AuthorizationException - { - return false; - } - - public boolean isAuthorized( SecuritySession arg0, Object arg1, Object arg2 ) - throws AuthorizationException - { - if ( repoIds.contains( arg2 ) ) - { - return true; - } - - return false; - } - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java deleted file mode 100644 index 482637f91..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataRepository.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.apache.archiva.webtest.memory; - -/* - * 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. - */ - -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.MetadataFacet; -import org.apache.archiva.metadata.model.ProjectMetadata; -import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; -import org.apache.archiva.metadata.repository.MetadataRepository; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -public class TestMetadataRepository - implements MetadataRepository -{ - private static final String TEST_REPO = "test-repo"; - - private static final String TEST_NAMESPACE = "org.apache.archiva"; - - private List artifacts = new ArrayList(); - - private List versions = new ArrayList(); - - public TestMetadataRepository() - { - Date whenGathered = new Date( 123456789 ); - - addArtifact( "artifact-one", "1.0", whenGathered ); - addArtifact( "artifact-one", "1.1", whenGathered ); - addArtifact( "artifact-one", "2.0", whenGathered ); - addArtifact( "artifact-two", "1.0.1", whenGathered ); - addArtifact( "artifact-two", "1.0.2", whenGathered ); - addArtifact( "artifact-two", "1.0.3-SNAPSHOT", whenGathered ); - addArtifact( "artifact-three", "2.0-SNAPSHOT", whenGathered ); - addArtifact( "artifact-four", "1.1-beta-2", whenGathered ); - } - - private void addArtifact( String projectId, String projectVersion, Date whenGathered ) - { - ArtifactMetadata artifact = new ArtifactMetadata(); - artifact.setFileLastModified( System.currentTimeMillis() ); - artifact.setNamespace( TEST_NAMESPACE ); - artifact.setProjectVersion( projectVersion ); - artifact.setVersion( projectVersion ); - artifact.setId( projectId + "-" + projectVersion + ".jar" ); - artifact.setProject( projectId ); - artifact.setRepositoryId( TEST_REPO ); - artifact.setWhenGathered( whenGathered ); - artifacts.add( artifact ); - - versions.add( projectVersion ); - } - - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - { - throw new UnsupportedOperationException(); - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) - { - throw new UnsupportedOperationException(); - } - - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - { - throw new UnsupportedOperationException(); - } - - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) - { - throw new UnsupportedOperationException(); - } - - public Collection getRootNamespaces( String repoId ) - { - throw new UnsupportedOperationException(); - } - - public Collection getNamespaces( String repoId, String namespace ) - { - throw new UnsupportedOperationException(); - } - - public Collection getProjects( String repoId, String namespace ) - { - throw new UnsupportedOperationException(); - } - - public Collection getProjectVersions( String repoId, String namespace, String projectId ) - { - return versions; - } - - public void updateProject( String repoId, ProjectMetadata project ) - { - throw new UnsupportedOperationException(); - } - - public void updateArtifact( String repoId, String namespace, String projectId, String projectVersion, - ArtifactMetadata artifactMeta ) - { - throw new UnsupportedOperationException(); - } - - public void updateProjectVersion( String repoId, String namespace, String projectId, - ProjectVersionMetadata versionMetadata ) - { - throw new UnsupportedOperationException(); - } - - public void updateNamespace( String repoId, String namespace ) - { - throw new UnsupportedOperationException(); - } - - public List getMetadataFacets( String repodId, String facetId ) - { - return Collections.emptyList(); - } - - public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name ) - { - throw new UnsupportedOperationException(); - } - - public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet ) - { - throw new UnsupportedOperationException(); - } - - public void removeMetadataFacets( String repositoryId, String facetId ) - { - throw new UnsupportedOperationException(); - } - - public void removeMetadataFacet( String repoId, String facetId, String name ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public List getArtifactsByDateRange( String repoId, Date startTime, Date endTime ) - { - return artifacts; - } - - public Collection getRepositories() - { - return Collections.singletonList( TEST_REPO ); - } - - public List getArtifactsByChecksum( String repoId, String checksum ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void removeRepository( String repoId ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) - { - return artifacts; - } - - public void save() - { - } - - public void close() - { - } - - public void revert() - { - throw new UnsupportedOperationException(); - } - - public boolean canObtainAccess( Class aClass ) - { - return false; //To change body of implemented methods use File | Settings | File Templates. - } - - public Object obtainAccess( Class aClass ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public List getArtifacts( String repositoryId ) - { - return artifacts; - } -} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java deleted file mode 100644 index 2a5ba06c6..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestMetadataResolver.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.apache.archiva.webtest.memory; - -/* - * 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. - */ - -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; -import org.apache.archiva.metadata.repository.MetadataResolver; -import org.apache.archiva.metadata.repository.RepositorySession; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class TestMetadataResolver - implements MetadataResolver -{ - private Map projectVersions = new HashMap(); - - private Map> artifacts = new HashMap>(); - - private Map> references = - new HashMap>(); - - private Map> namespaces = new HashMap>(); - - private Map> projectsInNamespace = new HashMap>(); - - private Map> versionsInProject = new HashMap>(); - - public ProjectVersionMetadata resolveProjectVersion( RepositorySession repositorySession, String repoId, - String namespace, String projectId, String projectVersion ) - { - return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); - } - - public Collection resolveProjectReferences( RepositorySession repositorySession, - String repoId, String namespace, - String projectId, String projectVersion ) - { - Collection projectVersionReferences = - references.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); - return projectVersionReferences; - } - - public Collection resolveRootNamespaces( RepositorySession repositorySession, String repoId ) - { - return resolveNamespaces( repositorySession, repoId, null ); - } - - public Collection resolveNamespaces( RepositorySession repositorySession, String repoId, - String baseNamespace ) - { - Set namespaces = new LinkedHashSet(); - int fromIndex = baseNamespace != null ? baseNamespace.length() + 1 : 0; - for ( String namespace : this.namespaces.get( repoId ) ) - { - if ( baseNamespace == null || namespace.startsWith( baseNamespace + "." ) ) - { - int i = namespace.indexOf( '.', fromIndex ); - if ( i >= 0 ) - { - namespaces.add( namespace.substring( fromIndex, i ) ); - } - else - { - namespaces.add( namespace.substring( fromIndex ) ); - } - } - } - return namespaces; - } - - public Collection resolveProjects( RepositorySession repositorySession, String repoId, String namespace ) - { - Collection list = projectsInNamespace.get( namespace ); - return list != null ? list : Collections.emptyList(); - } - - public Collection resolveProjectVersions( RepositorySession repositorySession, String repoId, - String namespace, String projectId ) - { - Collection list = versionsInProject.get( namespace + ":" + projectId ); - return list != null ? list : Collections.emptyList(); - } - - public Collection resolveArtifacts( RepositorySession repositorySession, String repoId, - String namespace, String projectId, String projectVersion ) - { - List artifacts = - this.artifacts.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); - return ( artifacts != null ? artifacts : Collections.emptyList() ); - } - - public void setProjectVersion( String repoId, String namespace, String projectId, - ProjectVersionMetadata versionMetadata ) - { - projectVersions.put( createMapKey( repoId, namespace, projectId, versionMetadata.getId() ), versionMetadata ); - - Collection projects = projectsInNamespace.get( namespace ); - if ( projects == null ) - { - projects = new LinkedHashSet(); - projectsInNamespace.put( namespace, projects ); - } - projects.add( projectId ); - - String key = namespace + ":" + projectId; - Collection versions = versionsInProject.get( key ); - if ( versions == null ) - { - versions = new LinkedHashSet(); - versionsInProject.put( key, versions ); - } - versions.add( versionMetadata.getId() ); - } - - public void setArtifacts( String repoId, String namespace, String projectId, String projectVersion, - List artifacts ) - { - this.artifacts.put( createMapKey( repoId, namespace, projectId, projectVersion ), artifacts ); - } - - private String createMapKey( String repoId, String namespace, String projectId, String projectVersion ) - { - return repoId + ":" + namespace + ":" + projectId + ":" + projectVersion; - } - - public void setProjectReferences( String repoId, String namespace, String projectId, String projectVersion, - List references ) - { - this.references.put( createMapKey( repoId, namespace, projectId, projectVersion ), references ); - } - - public void setNamespaces( String repoId, List namespaces ) - { - this.namespaces.put( repoId, namespaces ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java b/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java deleted file mode 100644 index f311d97d3..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.archiva.webtest.memory; - -/* - * 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. - */ - -import org.apache.archiva.metadata.repository.RepositorySession; -import org.apache.archiva.metadata.repository.RepositorySessionFactory; -import org.springframework.stereotype.Service; - -@Service("repositorySessionFactory#test") -public class TestRepositorySessionFactory - implements RepositorySessionFactory -{ - private RepositorySession repositorySession; - - public void setRepositorySession( RepositorySession repositorySession ) - { - this.repositorySession = repositorySession; - } - - public RepositorySession createSession() - { - return repositorySession != null ? repositorySession : new RepositorySession( new TestMetadataRepository(), - new TestMetadataResolver() ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/empty-archiva.xml b/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/empty-archiva.xml deleted file mode 100644 index 997d62b00..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/empty-archiva.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - 2 - - - - - artifacts - - **/*.pom - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.dtd - **/*.tld - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - - - - indexable-content - - **/*.txt - **/*.TXT - **/*.block - **/*.config - **/*.pom - **/*.xml - **/*.xsd - **/*.dtd - **/*.tld - - - - auto-remove - - **/*.bak - **/*~ - **/*- - - - - ignored - - **/.htaccess - **/KEYS - **/*.rb - **/*.sh - **/.svn/** - **/.DAV/** - - - - - update-db-artifact - create-missing-checksums - update-db-repository-metadata - validate-checksum - validate-signature - index-content - auto-remove - auto-rename - - - update-db-bad-content - - - - - 0 0 * * * ? - - index-artifact - update-db-project - validate-repository-metadata - index-archive-toc - update-db-bytecode-stats - index-public-methods - - - not-present-remove-db-artifact - not-present-remove-db-project - not-present-remove-indexed - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/log4j.xml b/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/log4j.xml deleted file mode 100644 index aecb237a7..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/log4j.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/spring-context-rss-servlet.xml deleted file mode 100644 index 6e3dc3ec3..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/resources/spring-context-rss-servlet.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ]]> - - - - - - - \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-common/src/test/webapp/WEB-INF/feedServletTest-web.xml b/archiva-modules/archiva-web/archiva-webapp-common/src/test/webapp/WEB-INF/feedServletTest-web.xml deleted file mode 100644 index ad7386b15..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-common/src/test/webapp/WEB-INF/feedServletTest-web.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - Apache Archiva - - - org.springframework.web.context.ContextLoaderListener - - - - contextClass - org.codehaus.redback.components.springutils.CachingWebApplicationContext - - - - RssFeedServlet - org.apache.archiva.web.rss.RssFeedServlet - - - - RssFeedServlet - /feeds/* - - - - contextConfigLocation - - classpath*:/META-INF/spring-context.xml - classpath*:/spring-context-rss-servlet.xml - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml index a5335b804..ba159a8f4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml @@ -1,627 +1,627 @@ - - - - 4.0.0 - - org.apache.archiva - archiva-web - 1.4-M3-SNAPSHOT - - archiva-webapp-js - war - - Archiva Web :: Javascript Application - - - ${basedir}/src/test/tomcat/tomcat-context.xml - - - - - org.apache.archiva - generic-metadata-support - - - org.apache.archiva - npanday-support - - - org.apache.archiva - repository-statistics - - - org.apache.archiva - problem-reports - - - org.apache.archiva - audit - - - org.apache.archiva - archiva-scheduler-repository - - - org.apache.archiva - archiva-indexer - - - - org.apache.archiva - archiva-repository-admin-api - - - - - org.apache.archiva - archiva-repository-admin-default - - - - org.apache.archiva - metadata-repository-api - - - org.apache.archiva - metadata-store-jcr - runtime - - - org.apache.jackrabbit - jackrabbit-core - - - commons-logging - commons-logging - - - - - - org.apache.velocity - velocity - - - org.apache.velocity - velocity-tools - 1.3 - runtime - - - commons-logging - commons-logging - - - velocity - velocity-dep - - - velocity - velocity - - - struts - struts - - - - - org.apache.archiva - - maven2-repository - - - - org.codehaus.plexus - plexus-slf4j-logging - runtime - - - org.codehaus.plexus - plexus-component-api - - - - - org.codehaus.plexus - plexus-utils - - - org.apache.maven.indexer - indexer-core - - - org.codehaus.plexus - plexus-container-default - - - classworlds - classworlds - - - commons-logging - commons-logging - - - velocity - velocity-dep - - - org.apache.maven - maven-plugin-registry - - - org.apache.maven - maven-settings - - - com.google.code.atinject - atinject - - - - - org.apache.archiva - archiva-proxy - - - org.apache.archiva - archiva-repository-layer - - - org.apache.archiva - archiva-xml-tools - - - xerces - xercesImpl - - - - - org.apache.archiva - archiva-security - - - org.apache.archiva - archiva-core-consumers - - - org.apache.archiva - archiva-configuration - - - - org.apache.archiva - archiva-metadata-consumer - runtime - - - org.apache.archiva - archiva-lucene-consumers - - - org.apache.lucene - lucene-core - - - org.apache.lucene - lucene-queries - - - org.apache.archiva - stage-repository-merge - - - org.apache.archiva - archiva-signature-consumers - - - org.apache.archiva - archiva-applet - - provided - - - org.apache.archiva - archiva-rss - - - - - org.apache.archiva - archiva-rest-services - - - org.eclipse.jetty - jetty-server - - - org.eclipse.jetty - jetty-continuation - - - org.eclipse.jetty - jetty-http - - - org.eclipse.jetty - jetty-io - - - org.eclipse.jetty - jetty-util - - - org.eclipse.jetty - jetty-security - - - commons-logging - commons-logging - - - org.apache.geronimo.specs - geronimo-servlet_3.0_spec - - - org.apache.geronimo.specs - geronimo-javamail_1.4_spec - - - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - - - - - org.apache.archiva - archiva-rest-api - - - org.eclipse.jetty - jetty-server - - - org.eclipse.jetty - jetty-continuation - - - org.eclipse.jetty - jetty-http - - - org.eclipse.jetty - jetty-io - - - org.eclipse.jetty - jetty-util - - - org.eclipse.jetty - jetty-security - - - commons-logging - commons-logging - - - org.apache.geronimo.specs - geronimo-servlet_3.0_spec - - - org.apache.geronimo.specs - geronimo-javamail_1.4_spec - - - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - - - - - javax.servlet - servlet-api - provided - - - - org.apache.archiva - archiva-webapp-common - - - - org.apache.archiva - archiva-webdav - - - - jpox - jpox - - - javax.transaction - jta - - - - - jpox - jpox-ehcache - - - commons-logging - commons-logging - - - ehcache - ehcache - - - - - - org.codehaus.redback.components.cache - spring-cache-ehcache - - - commons-logging - commons-logging - - - - - net.sf.ehcache - ehcache-core - - - commons-logging - commons-logging - - - - - - org.codehaus.redback.components - spring-quartz - - - org.quartz-scheduler - quartz - - - c3p0 - c3p0 - - - javax.transaction - jta - - - - - - org.codehaus.redback - redback-rest-services - - - org.codehaus.redback - redback-common-integrations - - - stax - stax-api - - - - - org.codehaus.redback - redback-integrations-security - - - org.slf4j - slf4j-log4j12 - runtime - - - org.slf4j - jcl-over-slf4j - runtime - - - org.apache.cxf - cxf-bundle-jaxrs - - - org.eclipse.jetty - jetty-server - - - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - - - org.apache.geronimo.specs - geronimo-javamail_1.4_spec - - - - - org.springframework - spring-core - - - org.springframework - spring-web - - - - - - - - - src/main/resources - - - src/main/filtered-resources - true - - - - - - - org.codehaus.mojo - tomcat-maven-plugin - - 9091 - /archiva - ${tomcatContextXml} - - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-home - ${project.build.directory}/appserver-base/logs - ${basedir}/target/auto-admin-creation.properties - ${project.build.directory} - - - - - org.apache.derby - derby - ${derbyVersion} - - - javax.mail - mail - ${javaxMailVersion} - - - - - - - - - - dev - - - - maven-antrun-plugin - - - override-log4j-with-console-output - process-resources - - run - - - - - - - - - - - - - - - - tdev - - - - org.apache.tomcat.maven - tomcat6-maven-plugin - - 9090 - / - ${tomcatContextXml} - - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-home - ${project.build.directory}/appserver-base/logs - ${basedir}/target/auto-admin-creation.properties - - ${project.build.directory} - - - - - org.apache.derby - derby - ${derbyVersion} - - - javax.mail - mail - 1.4 - - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.0-SNAPSHOT - - 9090 - / - ${tomcatContextXml} - - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-base - ${project.build.directory}/appserver-home - ${project.build.directory}/appserver-base/logs - ${basedir}/target/auto-admin-creation.properties - - ${project.build.directory} - - - - - org.apache.derby - derby - ${derbyVersion} - - - javax.mail - mail - 1.4 - - - - - - - - - + + + + 4.0.0 + + org.apache.archiva + archiva-web + 1.4-M3-SNAPSHOT + + archiva-webapp-js + war + + Archiva Web :: Javascript Application + + + ${basedir}/src/test/tomcat/tomcat-context.xml + + + + + org.apache.archiva + generic-metadata-support + + + org.apache.archiva + npanday-support + + + org.apache.archiva + repository-statistics + + + org.apache.archiva + problem-reports + + + org.apache.archiva + audit + + + org.apache.archiva + archiva-scheduler-repository + + + org.apache.archiva + archiva-indexer + + + + org.apache.archiva + archiva-repository-admin-api + + + + + org.apache.archiva + archiva-repository-admin-default + + + + org.apache.archiva + metadata-repository-api + + + org.apache.archiva + metadata-store-jcr + runtime + + + org.apache.jackrabbit + jackrabbit-core + + + commons-logging + commons-logging + + + + + + org.apache.velocity + velocity + + + org.apache.velocity + velocity-tools + 1.3 + runtime + + + commons-logging + commons-logging + + + velocity + velocity-dep + + + velocity + velocity + + + struts + struts + + + + + org.apache.archiva + + maven2-repository + + + + org.codehaus.plexus + plexus-slf4j-logging + runtime + + + org.codehaus.plexus + plexus-component-api + + + + + org.codehaus.plexus + plexus-utils + + + org.apache.maven.indexer + indexer-core + + + org.codehaus.plexus + plexus-container-default + + + classworlds + classworlds + + + commons-logging + commons-logging + + + velocity + velocity-dep + + + org.apache.maven + maven-plugin-registry + + + org.apache.maven + maven-settings + + + com.google.code.atinject + atinject + + + + + org.apache.archiva + archiva-proxy + + + org.apache.archiva + archiva-repository-layer + + + org.apache.archiva + archiva-xml-tools + + + xerces + xercesImpl + + + + + org.apache.archiva + archiva-security + + + org.apache.archiva + archiva-core-consumers + + + org.apache.archiva + archiva-configuration + + + + org.apache.archiva + archiva-metadata-consumer + runtime + + + org.apache.archiva + archiva-lucene-consumers + + + org.apache.lucene + lucene-core + + + org.apache.lucene + lucene-queries + + + org.apache.archiva + stage-repository-merge + + + org.apache.archiva + archiva-signature-consumers + + + org.apache.archiva + archiva-applet + + provided + + + org.apache.archiva + archiva-rss + + + + + org.apache.archiva + archiva-rest-services + + + org.eclipse.jetty + jetty-server + + + org.eclipse.jetty + jetty-continuation + + + org.eclipse.jetty + jetty-http + + + org.eclipse.jetty + jetty-io + + + org.eclipse.jetty + jetty-util + + + org.eclipse.jetty + jetty-security + + + commons-logging + commons-logging + + + org.apache.geronimo.specs + geronimo-servlet_3.0_spec + + + org.apache.geronimo.specs + geronimo-javamail_1.4_spec + + + org.apache.geronimo.specs + geronimo-servlet_2.5_spec + + + + + org.apache.archiva + archiva-rest-api + + + org.eclipse.jetty + jetty-server + + + org.eclipse.jetty + jetty-continuation + + + org.eclipse.jetty + jetty-http + + + org.eclipse.jetty + jetty-io + + + org.eclipse.jetty + jetty-util + + + org.eclipse.jetty + jetty-security + + + commons-logging + commons-logging + + + org.apache.geronimo.specs + geronimo-servlet_3.0_spec + + + org.apache.geronimo.specs + geronimo-javamail_1.4_spec + + + org.apache.geronimo.specs + geronimo-servlet_2.5_spec + + + + + javax.servlet + servlet-api + provided + + + + org.apache.archiva + archiva-weba-common + + + + org.apache.archiva + archiva-webdav + + + + jpox + jpox + + + javax.transaction + jta + + + + + jpox + jpox-ehcache + + + commons-logging + commons-logging + + + ehcache + ehcache + + + + + + org.codehaus.redback.components.cache + spring-cache-ehcache + + + commons-logging + commons-logging + + + + + net.sf.ehcache + ehcache-core + + + commons-logging + commons-logging + + + + + + org.codehaus.redback.components + spring-quartz + + + org.quartz-scheduler + quartz + + + c3p0 + c3p0 + + + javax.transaction + jta + + + + + + org.codehaus.redback + redback-rest-services + + + org.codehaus.redback + redback-common-integrations + + + stax + stax-api + + + + + org.codehaus.redback + redback-integrations-security + + + org.slf4j + slf4j-log4j12 + runtime + + + org.slf4j + jcl-over-slf4j + runtime + + + org.apache.cxf + cxf-bundle-jaxrs + + + org.eclipse.jetty + jetty-server + + + org.apache.geronimo.specs + geronimo-servlet_2.5_spec + + + org.apache.geronimo.specs + geronimo-javamail_1.4_spec + + + + + org.springframework + spring-core + + + org.springframework + spring-web + + + + + + + + + src/main/resources + + + src/main/filtered-resources + true + + + + + + + org.codehaus.mojo + tomcat-maven-plugin + + 9091 + /archiva + ${tomcatContextXml} + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-home + ${project.build.directory}/appserver-base/logs + ${basedir}/target/auto-admin-creation.properties + ${project.build.directory} + + + + + org.apache.derby + derby + ${derbyVersion} + + + javax.mail + mail + ${javaxMailVersion} + + + + + + + + + + dev + + + + maven-antrun-plugin + + + override-log4j-with-console-output + process-resources + + run + + + + + + + + + + + + + + + + tdev + + + + org.apache.tomcat.maven + tomcat6-maven-plugin + + 9090 + / + ${tomcatContextXml} + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-home + ${project.build.directory}/appserver-base/logs + ${basedir}/target/auto-admin-creation.properties + + ${project.build.directory} + + + + + org.apache.derby + derby + ${derbyVersion} + + + javax.mail + mail + 1.4 + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.0-SNAPSHOT + + 9090 + / + ${tomcatContextXml} + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-home + ${project.build.directory}/appserver-base/logs + ${basedir}/target/auto-admin-creation.properties + + ${project.build.directory} + + + + + org.apache.derby + derby + ${derbyVersion} + + + javax.mail + mail + 1.4 + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 9b61bef24..c1018e1c5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -529,7 +529,7 @@ org.apache.archiva - archiva-webapp-common + archiva-web-common org.apache.struts diff --git a/archiva-modules/archiva-web/pom.xml b/archiva-modules/archiva-web/pom.xml index 9d4955c6c..1a2303938 100644 --- a/archiva-modules/archiva-web/pom.xml +++ b/archiva-modules/archiva-web/pom.xml @@ -48,7 +48,7 @@ archiva-webdav archiva-rss archiva-rest - archiva-webapp-common + archiva-web-common archiva-webapp diff --git a/pom.xml b/pom.xml index b5e0c0c0d..2cb61e099 100644 --- a/pom.xml +++ b/pom.xml @@ -414,7 +414,7 @@ org.apache.archiva - archiva-webapp-common + archiva-web-common ${project.version}