Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Webtools Releng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
webtools
Releng
Webtools Releng
Commits
524e032c
Commit
524e032c
authored
16 years ago
by
david_williams
Browse files
Options
Downloads
Patches
Plain Diff
improve signing
parent
3e2e3d83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java
+116
-6
116 additions, 6 deletions
...rg/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java
with
116 additions
and
6 deletions
plugins/org.eclipse.wtp.releng.tools/src/org/eclipse/wtp/releng/tools/UpdatePackPropertiesFile.java
+
116
−
6
View file @
524e032c
package
org.eclipse.wtp.releng.tools
;
package
org.eclipse.wtp.releng.tools
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FilenameFilter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.ObjectInputStream.GetField
;
import
java.util.Arrays
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipInputStream
;
import
org.apache.tools.ant.BuildException
;
import
org.apache.tools.ant.BuildException
;
import
org.apache.tools.ant.Project
;
import
org.apache.tools.ant.Task
;
import
org.apache.tools.ant.Task
;
public
class
UpdatePackPropertiesFile
extends
Task
{
public
class
UpdatePackPropertiesFile
extends
Task
{
static
class
JarFileFilter
implements
FilenameFilter
{
public
boolean
accept
(
File
dir
,
String
name
)
{
if
(
name
.
endsWith
(
".jar"
))
{
return
true
;
}
return
false
;
}
}
private
String
archiveFilename
;
private
String
archiveFilename
;
private
String
packFileTemplate
;
private
String
packFileTemplate
;
private
FilenameFilter
jarFileFilter
=
new
JarFileFilter
();
public
void
execute
()
throws
BuildException
{
public
void
execute
()
throws
BuildException
{
boolean
invalidProperties
=
false
;
boolean
invalidProperties
=
false
;
...
@@ -30,6 +53,7 @@ public class UpdatePackPropertiesFile extends Task {
...
@@ -30,6 +53,7 @@ public class UpdatePackPropertiesFile extends Task {
ZipFile
archiveFile
=
null
;
ZipFile
archiveFile
=
null
;
try
{
try
{
archiveFile
=
new
ZipFile
(
getArchiveFilename
());
archiveFile
=
new
ZipFile
(
getArchiveFilename
());
archiveFile
.
close
();
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
)
{
invalidProperties
=
true
;
invalidProperties
=
true
;
...
@@ -43,15 +67,101 @@ public class UpdatePackPropertiesFile extends Task {
...
@@ -43,15 +67,101 @@ public class UpdatePackPropertiesFile extends Task {
if
(
invalidProperties
)
{
if
(
invalidProperties
)
{
throw
new
BuildException
(
"The properties for this task are not valid. See log for more details"
);
throw
new
BuildException
(
"The properties for this task are not valid. See log for more details"
);
}
}
Enumeration
allEntries
=
archiveFile
.
entries
();
// comma seperated list
while
(
allEntries
.
hasMoreElements
())
{
String
signedJarNames
=
null
;
ZipEntry
zipentry
=
(
ZipEntry
)
allEntries
.
nextElement
();
try
{
log
(
zipentry
.
getName
());
signedJarNames
=
getSignedJarNames
();
}
catch
(
IOException
e
)
{
throw
new
BuildException
(
e
);
}
}
log
(
signedJarNames
);
}
}
private
String
getSignedJarNames
()
throws
IOException
{
String
result
=
""
;
String
tempdir
=
System
.
getProperty
(
"java.io.tmpdir"
);
if
(
!(
tempdir
.
endsWith
(
"/"
)
||
tempdir
.
endsWith
(
"\\"
))
)
tempdir
=
tempdir
+
System
.
getProperty
(
"file.separator"
);
String
zipfilename
=
getArchiveFilename
();
String
destinationdirectory
=
tempdir
+
zipfilename
;
extractZipStream
(
destinationdirectory
,
zipfilename
);
// we avoid short recursing since we know structure
File
featureDestDir
=
new
File
(
destinationdirectory
+
"/eclipse/features/"
);
String
[]
jars
=
featureDestDir
.
list
(
jarFileFilter
);
File
bundlesDestDir
=
new
File
(
destinationdirectory
+
"/eclipse/plugins/"
);
String
[]
bundlejars
=
bundlesDestDir
.
list
(
jarFileFilter
);
result
=
checkIfJarsSigned
(
result
,
jars
);
result
=
checkIfJarsSigned
(
result
,
bundlejars
);
return
result
;
}
private
String
checkIfJarsSigned
(
String
currentresults
,
String
[]
jars
)
throws
IOException
{
for
(
int
i
=
0
;
i
<
jars
.
length
;
i
++)
{
String
jarname
=
jars
[
i
];
JarFile
jarFile
=
new
JarFile
(
jarname
);
Enumeration
jarentries
=
jarFile
.
entries
();
while
(
jarentries
.
hasMoreElements
())
{
JarEntry
jarentry
=
(
JarEntry
)
jarentries
.
nextElement
();
String
entryname
=
jarentry
.
getName
();
log
(
entryname
);
// Project.MSG_DEBUG
if
(
entryname
.
endsWith
(
"ECLIPSE.SF"
)
||
entryname
.
endsWith
(
"ECLIPSF.SF"
))
{
currentresults
=
currentresults
+
jarname
+
","
;
break
;
}
}
}
return
currentresults
;
}
private
void
extractZipStream
(
String
destinationdirectory
,
String
zipfilename
)
throws
IOException
{
byte
[]
buf
=
new
byte
[
1024
];
ZipInputStream
zipinputstream
=
null
;
ZipEntry
zipentry
;
zipinputstream
=
new
ZipInputStream
(
new
FileInputStream
(
zipfilename
));
zipentry
=
zipinputstream
.
getNextEntry
();
while
(
zipentry
!=
null
)
{
//for each entry to be extracted
String
entryName
=
zipentry
.
getName
();
System
.
out
.
println
(
"entryname "
+
entryName
);
int
n
;
FileOutputStream
fileoutputstream
;
File
newFile
=
new
File
(
entryName
);
String
directory
=
newFile
.
getParent
();
if
(
directory
==
null
)
{
if
(
newFile
.
isDirectory
())
break
;
}
fileoutputstream
=
new
FileOutputStream
(
destinationdirectory
+
entryName
);
while
((
n
=
zipinputstream
.
read
(
buf
,
0
,
1024
))
>
-
1
)
fileoutputstream
.
write
(
buf
,
0
,
n
);
fileoutputstream
.
close
();
zipinputstream
.
closeEntry
();
zipentry
=
zipinputstream
.
getNextEntry
();
}
//while
zipinputstream
.
close
();
}
public
String
getArchiveFilename
()
{
public
String
getArchiveFilename
()
{
return
archiveFilename
;
return
archiveFilename
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment