cancel
Showing results for 
Search instead for 
Did you mean: 

How to get All keystores and key storages (alias)

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi cs.santos0,

This is a pretty old thread, just wondering if you have any solution on this? I am facing the similar problem when trying to get the keystoremanager with SAPSecurityResources.

ravindra_bollapalli2
Active Contributor
0 Kudos
Former Member
0 Kudos

hi, thanks again....

i saw that sites, in one of them i found something interesting....

"Make sure you access the DEFAULT Keystore so you won't get into trouble with permissions (I suggest you store your certificates in DEFAULT)"

yes...this is exactly the issue, i can access the DEFAULT keystore (and some others), but i think the others are locked. I already granted permission for my EJB on Security Tab...now i guess, that is missing something else on my code...

I have the following code:


SAPSecurityResources secRes = SAPSecurityResources.getInstance();
KeyStoreManager manager = secRes.getKeyStoreManager(PermissionMode.SYSTEM_LEVEL);
KeyStore keyStore = manager.getKeyStore(certView);
ISsfProfile profile = manager.getISsfProfile(keyStore, certEntry, null);
X509Certificate cert = profile.getCertificate();
String sName = cert.getSubjectDN().getName();
cert.checkValidity();

this works almost equal what i need, but for other questions, i can't used...so, i'm wondering that i need something looks like this:

KeyStoreManager manager = secRes.getKeyStoreManager(PermissionMode.SYSTEM_LEVEL);

i mean, something that granted my pemission on my method....

could you help me?

Thanks in Advance

ravindra_bollapalli2
Active Contributor
0 Kudos

hi,

please check the following

[link|http://help.sap.com/saphelp_nw04/helpdata/en/a4/d0201854fb6a4cb9545892b49d4851/frameset.htm]

[link1|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c6519490-0201-0010-50b4-e824ef87511b]

http://help.sap.com/javadocs/NW04s/current/se/com/sap/security/core/server/https/SecureConnectionFac...

http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/security/lib/KeyStoreManager.html

let me know am i reached ur point

bvr

Edited by: bvr on Mar 26, 2009 7:41 AM

Edited by: bvr on Mar 26, 2009 8:42 AM

Former Member
0 Kudos

hi, thanks for answer!!

I saw every links that you post...but I've seen almost all of then.

Do you have an idea how can i solve that?...because i already granted the permissions for my keystore view entries on the security tab on SAP NetWeaver Administrator. But i don't know if i need to put something else on my method....

just as an observation my KeyStoreManager is that:

import com.sap.engine.interfaces.keystore.KeystoreManager;

and with this, i can get some certifies as i said, but i don't know how get all....

Could help me please?

Thanks in Advance