Changeset 233

Show
Ignore:
Timestamp:
08/02/07 07:39:13 (1 year ago)
Author:
paulhethmon
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • MetaTest/trunk/src/metatest/Main.java

    r222 r233  
    2626import java.security.KeyFactory; 
    2727import java.security.PublicKey; 
     28import java.security.PrivateKey; 
    2829import java.security.spec.X509EncodedKeySpec; 
     30import java.io.*; 
    2931 
    3032import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; 
     
    3234import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; 
    3335 
     36import net.clareitysecurity.websso.idp.*; 
    3437/** 
    3538 * 
     
    4851   */ 
    4952  public static void main(String[] args) throws MetadataProviderException, ConfigurationException, java.security.NoSuchAlgorithmException,  
    50     java.security.spec.InvalidKeySpecException
     53    java.security.spec.InvalidKeySpecException, java.io.FileNotFoundException, java.io.IOException
    5154    org.opensaml.DefaultBootstrap.bootstrap(); 
    5255    BasicParserPool parser = new BasicParserPool(); 
    5356//    if (1 == 1) return; 
     57     
     58    String privateKeyFile = "c:\\Business\\Clareity\\Dev\\SAML\\MetaTest\\src\\dev.acmeidp.com.key"; 
     59    String encodedPrivateKey = ""; 
     60    String line; 
     61     
     62    // try to load a private key 
     63    BufferedReader in = new BufferedReader(new FileReader(privateKeyFile)); 
     64    line = in.readLine(); 
     65    while (line != null) { 
     66      encodedPrivateKey += line + "\r\n"; 
     67      line = in.readLine(); 
     68    } 
     69    in.close(); 
     70    encodedPrivateKey = encodedPrivateKey.replace("-----BEGIN RSA PRIVATE KEY-----", ""); 
     71    encodedPrivateKey = encodedPrivateKey.replace("-----END RSA PRIVATE KEY-----", ""); 
     72    encodedPrivateKey = encodedPrivateKey.trim(); 
     73//    if (line.equalsIgnoreCase("-----BEGIN RSA PRIVATE KEY-----") == true) line = ""; 
     74//    if (line.equalsIgnoreCase("-----END RSA PRIVATE KEY-----") == true) line = ""; 
     75     
     76    // now create the private key object 
     77    PrivateKeyCache pkCache = new PrivateKeyCache(); 
     78    pkCache.setPrivateKeyEncoded(encodedPrivateKey); 
     79    PrivateKey privateKey = pkCache.getPrivateKey(); 
     80     
     81     
     82     
     83     
    5484     
    5585    String metaUrl = "http://red.csknox.com/idp-meta.xml";