Skip to Content
0
Former Member
Mar 25, 2009 at 02:47 PM

How to get All keystores and key storages (alias)

688 Views

Hi everyone,

i have the following code:

 
public String getMessage(String name) {

		String msg = "";
		
		try {
			InitialContext ctx = new InitialContext();
			Object o = (Object) ctx.lookup("keystore");
			KeystoreManager manager = (KeystoreManager) o;				
			String[] keyStores = manager.getKeystoreViewAliases();
			
			Enumeration<String> aliases = null;
			KeyStore keyStore = null; 
			String alias = null;
			StringBuilder sb = new StringBuilder();			

			for(int i = 0; i < keyStores.length; i++){
				keyStore = manager.getKeystore(keyStores<i>);
				aliases = keyStore.aliases();
				
				while(aliases.hasMoreElements()){
					alias = aliases.nextElement();
					sb.append(keyStores<i> + " : " + alias + "\n");
				}
				
				sb.append(keyStores<i> + " : " 
						+ keyStore.getType() + "\n");
				}
			
			msg = "try: " + sb.toString();			

		}catch(Exception ex){			
			msg += "catch: " + ex.getMessage();
		}
		
		return msg;
	}

this is a session bean method, which get all keystores and each alias from each keystore and print a message (later this will have other functionality). But, when i run a client for this method, just some keystores are listed like the "TrustedCAs" and "DEFAULT"...but i'd like to list all keystores. Looking for

answers, i found out that happens because this keystores and its alias are trusted. but how can i grant

which the others are trusted to?

I'm using Netweaver 7.1 and EJB 3.0

Could anybody help me?

Thanks in Advance