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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.handler.ArtifactHandler;
24  import org.apache.maven.artifact.metadata.ArtifactMetadata;
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
27  import org.apache.maven.artifact.versioning.ArtifactVersion;
28  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
29  import org.apache.maven.artifact.versioning.VersionRange;
30  
31  import java.io.File;
32  import java.util.ArrayList;
33  import java.util.Collection;
34  import java.util.Iterator;
35  import java.util.List;
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 int compareTo( Object o )
215     {
216         return delegate.compareTo( o );
217     }
218 
219     public void updateVersion( String version, ArtifactRepository localRepository )
220     {
221         delegate.updateVersion( version, localRepository );
222     }
223 
224     public ArtifactFilter getDependencyFilter()
225     {
226         return delegate.getDependencyFilter();
227     }
228 
229     public void setDependencyFilter( ArtifactFilter artifactFilter )
230     {
231         delegate.setDependencyFilter( artifactFilter );
232     }
233 
234     public ArtifactHandler getArtifactHandler()
235     {
236         return delegate.getArtifactHandler();
237     }
238 
239     public List getDependencyTrail()
240     {
241         return delegate.getDependencyTrail();
242     }
243 
244     public void setDependencyTrail( List dependencyTrail )
245     {
246         delegate.setDependencyTrail( dependencyTrail );
247     }
248 
249     public void selectVersion( String version )
250     {
251         delegate.selectVersion( version );
252     }
253 
254     public void setResolved( boolean resolved )
255     {
256         delegate.setResolved( resolved );
257     }
258 
259     public boolean isResolved()
260     {
261         return delegate.isResolved();
262     }
263 
264     public void setResolvedVersion( String version )
265     {
266         delegate.setResolvedVersion( version );
267     }
268 
269     public void setArtifactHandler( ArtifactHandler artifactHandler )
270     {
271         delegate.setArtifactHandler( artifactHandler );
272     }
273 
274     public boolean isOptional()
275     {
276         return delegate.isOptional();
277     }
278 
279     public ArtifactVersion getSelectedVersion()
280         throws OverConstrainedVersionException
281     {
282         return delegate.getSelectedVersion();
283     }
284 
285     public boolean isSelectedVersionKnown()
286         throws OverConstrainedVersionException
287     {
288         return delegate.isSelectedVersionKnown();
289     }
290 
291     public void setOptional( boolean optional )
292     {
293         delegate.setOptional( optional );
294     }
295 
296     public Collection<ArtifactMetadata> getMetadataList()
297     {
298         List<ArtifactMetadata> result = new ArrayList<ArtifactMetadata>( delegate.getMetadataList() );
299         boolean alreadySigned = false;
300         for ( Iterator i = result.iterator(); i.hasNext() && !alreadySigned; )
301         {
302             ArtifactMetadata metadata = (ArtifactMetadata) i.next();
303             alreadySigned = signature.getKey().equals(metadata.getKey());
304         }
305         if ( !alreadySigned )
306         {
307             result.add( signature );
308         }
309         return result;
310     }
311 }