View Javadoc
1   package org.apache.maven.plugin.gpg;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.ArrayList;
24  import java.util.Collection;
25  import java.util.Iterator;
26  import java.util.List;
27  
28  import org.apache.maven.artifact.Artifact;
29  import org.apache.maven.artifact.handler.ArtifactHandler;
30  import org.apache.maven.artifact.metadata.ArtifactMetadata;
31  import org.apache.maven.artifact.repository.ArtifactRepository;
32  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
33  import org.apache.maven.artifact.versioning.ArtifactVersion;
34  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
35  import org.apache.maven.artifact.versioning.VersionRange;
36  
37  /**
38   * A wrapper class for attached artifacts which have a GPG signature. Needed as attached artifacts in general do not
39   * have metadata.
40   */
41  public class AttachedSignedArtifact
42      implements Artifact
43  {
44      private final Artifact delegate;
45  
46      private final AscArtifactMetadata signature;
47  
48      public AttachedSignedArtifact( Artifact delegate, AscArtifactMetadata signature )
49      {
50          this.delegate = delegate;
51          this.signature = signature;
52      }
53  
54      public void setArtifactId( String artifactId )
55      {
56          delegate.setArtifactId( artifactId );
57      }
58  
59      public List getAvailableVersions()
60      {
61          return delegate.getAvailableVersions();
62      }
63  
64      public void setAvailableVersions( List availableVersions )
65      {
66          delegate.setAvailableVersions( availableVersions );
67      }
68  
69      public String getBaseVersion()
70      {
71          return delegate.getBaseVersion();
72      }
73  
74      public void setBaseVersion( String baseVersion )
75      {
76          delegate.setBaseVersion( baseVersion );
77      }
78  
79      public String getDownloadUrl()
80      {
81          return delegate.getDownloadUrl();
82      }
83  
84      public void setDownloadUrl( String downloadUrl )
85      {
86          delegate.setDownloadUrl( downloadUrl );
87      }
88  
89      public void setGroupId( String groupId )
90      {
91          delegate.setGroupId( groupId );
92      }
93  
94      public ArtifactRepository getRepository()
95      {
96          return delegate.getRepository();
97      }
98  
99      public void setRepository( ArtifactRepository repository )
100     {
101         delegate.setRepository( repository );
102     }
103 
104     public String getScope()
105     {
106         return delegate.getScope();
107     }
108 
109     public void setScope( String scope )
110     {
111         delegate.setScope( scope );
112     }
113 
114     public String getVersion()
115     {
116         return delegate.getVersion();
117     }
118 
119     public void setVersion( String version )
120     {
121         delegate.setVersion( version );
122     }
123 
124     public VersionRange getVersionRange()
125     {
126         return delegate.getVersionRange();
127     }
128 
129     public void setVersionRange( VersionRange range )
130     {
131         delegate.setVersionRange( range );
132     }
133 
134     public boolean isRelease()
135     {
136         return delegate.isRelease();
137     }
138 
139     public void setRelease( boolean release )
140     {
141         delegate.setRelease( release );
142     }
143 
144     public boolean isSnapshot()
145     {
146         return delegate.isSnapshot();
147     }
148 
149     public void addMetadata( ArtifactMetadata metadata )
150     {
151         delegate.addMetadata( metadata );
152     }
153 
154     public String getClassifier()
155     {
156         return delegate.getClassifier();
157     }
158 
159     public boolean hasClassifier()
160     {
161         return delegate.hasClassifier();
162     }
163 
164     public String getGroupId()
165     {
166         return delegate.getGroupId();
167     }
168 
169     public String getArtifactId()
170     {
171         return delegate.getArtifactId();
172     }
173 
174     public String getType()
175     {
176         return delegate.getType();
177     }
178 
179     public void setFile( File file )
180     {
181         delegate.setFile( file );
182     }
183 
184     public File getFile()
185     {
186         return delegate.getFile();
187     }
188 
189     public String getId()
190     {
191         return delegate.getId();
192     }
193 
194     public String getDependencyConflictId()
195     {
196         return delegate.getDependencyConflictId();
197     }
198 
199     public String toString()
200     {
201         return delegate.toString();
202     }
203 
204     public int hashCode()
205     {
206         return delegate.hashCode();
207     }
208 
209     public boolean equals( Object o )
210     {
211         return delegate.equals( o );
212     }
213 
214     public void updateVersion( String version, ArtifactRepository localRepository )
215     {
216         delegate.updateVersion( version, localRepository );
217     }
218 
219     public ArtifactFilter getDependencyFilter()
220     {
221         return delegate.getDependencyFilter();
222     }
223 
224     public void setDependencyFilter( ArtifactFilter artifactFilter )
225     {
226         delegate.setDependencyFilter( artifactFilter );
227     }
228 
229     public ArtifactHandler getArtifactHandler()
230     {
231         return delegate.getArtifactHandler();
232     }
233 
234     public List getDependencyTrail()
235     {
236         return delegate.getDependencyTrail();
237     }
238 
239     public void setDependencyTrail( List dependencyTrail )
240     {
241         delegate.setDependencyTrail( dependencyTrail );
242     }
243 
244     public void selectVersion( String version )
245     {
246         delegate.selectVersion( version );
247     }
248 
249     public void setResolved( boolean resolved )
250     {
251         delegate.setResolved( resolved );
252     }
253 
254     public boolean isResolved()
255     {
256         return delegate.isResolved();
257     }
258 
259     public void setResolvedVersion( String version )
260     {
261         delegate.setResolvedVersion( version );
262     }
263 
264     public void setArtifactHandler( ArtifactHandler artifactHandler )
265     {
266         delegate.setArtifactHandler( artifactHandler );
267     }
268 
269     public boolean isOptional()
270     {
271         return delegate.isOptional();
272     }
273 
274     public ArtifactVersion getSelectedVersion()
275         throws OverConstrainedVersionException
276     {
277         return delegate.getSelectedVersion();
278     }
279 
280     public boolean isSelectedVersionKnown()
281         throws OverConstrainedVersionException
282     {
283         return delegate.isSelectedVersionKnown();
284     }
285 
286     public void setOptional( boolean optional )
287     {
288         delegate.setOptional( optional );
289     }
290 
291     public Collection<ArtifactMetadata> getMetadataList()
292     {
293         List<ArtifactMetadata> result = new ArrayList<ArtifactMetadata>( delegate.getMetadataList() );
294         boolean alreadySigned = false;
295         for ( Iterator i = result.iterator(); i.hasNext() && !alreadySigned; )
296         {
297             ArtifactMetadata metadata = (ArtifactMetadata) i.next();
298             alreadySigned = signature.getKey().equals( metadata.getKey() );
299         }
300         if ( !alreadySigned )
301         {
302             result.add( signature );
303         }
304         return result;
305     }
306 
307     public int compareTo( Artifact o )
308     {
309         return delegate.compareTo( o );
310     }
311 
312     public ArtifactMetadata getMetadata( Class<?> metadataClass )
313     {
314         // TODO Auto-generated method stub
315         return delegate.getMetadata( metadataClass );
316     }
317 }