[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[geclipse-dev] Certificate class problem
|
Hi again every body,
I am actually building an autonomous application taking benefit of
geclipse architecture that will submit jobs on computational grids.
For that I think I need to download the certificates of the
authorities. I have a problem witting the code that downloads the
certificates because the
EUGridPMACertificate class is in the package
eu.geclipse.core.internal.auth, that in internal.
The code I have written is (EFSFile is a class that simplify file usage
over EFS):
byte[] certificateData = null;
byte[] infoData = null;
String DEFAULT_LOCATION =
"http://www.eugridpma.org/distribution/igtf/current/accredited/tgz";
URI defaultURI;
defaultURI = new URI( DEFAULT_LOCATION );
EFSFile repo = new EFSFile(defaultURI);
List< String > result = new ArrayList< String >();
InputStreamReader iReader = new
InputStreamReader(repo.openInputStream());
BufferedReader bReader = new BufferedReader( iReader );
StringBuffer buffer = new StringBuffer();
String line;
while ( ( line = bReader.readLine() ) != null ) {
buffer.append( line );
}
String content = buffer.toString().replaceAll( " ", "" );
//$NON-NLS-1$ //$NON-NLS-2$
int index = -1;
while ( ( index = content.indexOf( "ahref=\"", index+1 ) ) >
0 ) { //$NON-NLS-1$
int endIndex = content.indexOf( "\">", index+7 );
//$NON-NLS-1$
if ( endIndex > 0 ) {
String file = content.substring( index+7, endIndex );
if ( file.toLowerCase().endsWith( ".tar.gz" )
//$NON-NLS-1$
|| file.toLowerCase().endsWith( ".tgz" ) ) {
//$NON-NLS-1$
result.add( file );
}
}
index = endIndex;
}
for(String certName: result) {
URI uri = new URI( defaultURI.toString() + "/" + certName
); //$NON-NLS-1$
EFSFile cert = new EFSFile(uri);
InputStream iStream = cert.openInputStream();
BufferedInputStream bStream = new BufferedInputStream(
iStream );
GZIPInputStream zStream = new GZIPInputStream( bStream );
TarInputStream tiStream = new TarInputStream( zStream );
TarEntry tEntry;
while ( ( tEntry = tiStream.getNextEntry() ) != null ) {
if ( !tEntry.isDirectory() ) {
IPath oPath = tEntry.getPath();
String extension = oPath.getFileExtension();
if (
*PEMCertificate*.CERT_FILE_EXTENSION.equalsIgnoreCase( extension ) ) {
certificateData = readFromStream( tiStream );
} else if (*
EUGridPMACertificate*.INFO_FILE_EXTENSION.equalsIgnoreCase( extension ) ) {
infoData = readFromStream( tiStream );
}
}
}
}
if ( ( certificateData != null ) && ( infoData != null ) ) {
result = *new EUGridPMACertificate( certificateData,
infoData );*
}
Is there a way of bypassing it?
Sorry to bother. Once, I will be finished I will publish the code as a
tutorial, if you are interested.
Romain