| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
|
| 16 |
package org.globus.gsi.provider; |
| 17 |
|
| 18 |
import org.globus.gsi.stores.PEMKeyStore; |
| 19 |
|
| 20 |
import org.apache.commons.logging.Log; |
| 21 |
|
| 22 |
import org.apache.commons.logging.LogFactory; |
| 23 |
|
| 24 |
import java.io.ByteArrayInputStream; |
| 25 |
import java.io.ByteArrayOutputStream; |
| 26 |
import java.io.InputStream; |
| 27 |
import java.util.Enumeration; |
| 28 |
import java.util.Properties; |
| 29 |
|
| 30 |
|
| 31 |
import org.globus.util.GlobusPathMatchingResourcePatternResolver; |
| 32 |
import org.junit.Test; |
| 33 |
|
| 34 |
/** |
| 35 |
* Created by IntelliJ IDEA. |
| 36 |
* User: turtlebender |
| 37 |
* Date: Dec 30, 2009 |
| 38 |
* Time: 1:01:14 PM |
| 39 |
* To change this template use File | Settings | File Templates. |
| 40 |
*/ |
| 41 |
public class FileBasedKeyStoreTest { |
| 42 |
private PEMKeyStore keystore = new PEMKeyStore(); |
| 43 |
private GlobusPathMatchingResourcePatternResolver globusResolver = new GlobusPathMatchingResourcePatternResolver(); |
| 44 |
private Log logger = LogFactory.getLog(FileBasedKeyStoreTest.class.getCanonicalName()); |
| 45 |
|
| 46 |
@Test |
| 47 |
public void testIO() throws Exception { |
| 48 |
InputStream is; |
| 49 |
ByteArrayOutputStream os; |
| 50 |
Properties props = new Properties(); |
| 51 |
props.put(PEMKeyStore.KEY_FILENAME, "classpath:/key.pem"); |
| 52 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 53 |
props.store(baos, "sample"); |
| 54 |
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
| 55 |
keystore.engineLoad(bais, null); |
| 56 |
Enumeration en = keystore.engineAliases(); |
| 57 |
while (en.hasMoreElements()) { |
| 58 |
logger.debug("en.nextElement().toString() = " + en.nextElement().toString()); |
| 59 |
} |
| 60 |
os = new ByteArrayOutputStream(); |
| 61 |
// keystore.engineStore(os, null); |
| 62 |
|
| 63 |
// keystore.engineStore(os, password); |
| 64 |
} |
| 65 |
} |