Skip to content

Commit

Permalink
MSHARED-277 - JarSignerUtil.unsignArchive invalid entry compressed size
Browse files Browse the repository at this point in the history
Submitted by: Timo Meinen [email protected]
Comment: Add a junit test to test it

git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1540158 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Tony Chemit committed Nov 8, 2013
1 parent 1e924ad commit 25964b6
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void unsignArchive( File jarFile )
continue;
}

zos.putNextEntry( ze );
zos.putNextEntry(new ZipEntry(ze.getName()));

IOUtil.copy( zis, zos );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.apache.maven.shared.jarsigner;

/*
* 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 junit.framework.TestCase;
import org.apache.maven.shared.utils.io.FileUtils;

import java.io.File;

/**
* Created on 11/8/13.
*
* @author Tony Chemit <[email protected]>
* @version $Id$
* @since 1.1
*/
public class JarSignerUtilTest
extends TestCase
{

// Fix MSHARED-277
public void testUnsignArchive()
throws Exception
{

File file = new File( "src/test/javax.persistence_2.0.5.v201212031355.jar" );
File target = new File( "target/", file.getName() );

if ( target.exists() )
{
FileUtils.forceDelete( target );
}

FileUtils.copyFile( file, target );

assertTrue( JarSignerUtil.isArchiveSigned( target ) );

JarSignerUtil.unsignArchive( target );

assertFalse( JarSignerUtil.isArchiveSigned( target ) );

}
}
Binary file not shown.

0 comments on commit 25964b6

Please sign in to comment.