Search in sources :

Example 1 with JKSKeyProvider

use of com.sun.identity.saml.xmlsig.JKSKeyProvider in project OpenAM by OpenRock.

the class Client method initializeJSSE.

/**
     * Initializes JSSE enviroment.
     *
     * @throws Exception if an error occurs while initializing JSSE
     */
private static void initializeJSSE() throws Exception {
    // put SunJSSE at fisrt place, so that JSSE will work
    Provider provider = Security.getProvider("SunJSSE");
    if (provider != null) {
        Security.removeProvider("SunJSSE");
        Security.insertProviderAt(provider, 1);
    }
    String algorithm = SystemPropertiesManager.get(SOAP_TRUST_SECMNGR_ALGO_PROP);
    if (algorithm == null || algorithm.length() <= 0) {
        algorithm = "SunX509";
    }
    JKSKeyProvider jkskp = createKeyProvider();
    KeyStore trustStore = jkskp.getKeyStore();
    KeyManagerFactory kf = KeyManagerFactory.getInstance(algorithm);
    kf.init(trustStore, jkskp.getPrivateKeyPass().toCharArray());
    kms = kf.getKeyManagers();
    defaultX509km = (X509KeyManager) kms[0];
    defineTrustManager(trustStore, algorithm);
}
Also used : JKSKeyProvider(com.sun.identity.saml.xmlsig.JKSKeyProvider) KeyStore(java.security.KeyStore) JKSKeyProvider(com.sun.identity.saml.xmlsig.JKSKeyProvider) Provider(java.security.Provider) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 2 with JKSKeyProvider

use of com.sun.identity.saml.xmlsig.JKSKeyProvider in project OpenAM by OpenRock.

the class TaskModelImpl method getSigningKeys.

/**
     * Returns a set of signing keys.
     *
     * @return a set of signing keys.
     */
public Set getSigningKeys() throws AMConsoleException {
    try {
        Set keyEntries = new HashSet();
        JKSKeyProvider kp = new JKSKeyProvider();
        KeyStore ks = kp.getKeyStore();
        Enumeration e = ks.aliases();
        if (e != null) {
            while (e.hasMoreElements()) {
                String alias = (String) e.nextElement();
                if (ks.isKeyEntry(alias)) {
                    keyEntries.add(alias);
                }
            }
        }
        return keyEntries;
    } catch (KeyStoreException e) {
        throw new AMConsoleException(e.getMessage());
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) Enumeration(java.util.Enumeration) JKSKeyProvider(com.sun.identity.saml.xmlsig.JKSKeyProvider) KeyStoreException(java.security.KeyStoreException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) KeyStore(java.security.KeyStore) HashSet(java.util.HashSet)

Aggregations

JKSKeyProvider (com.sun.identity.saml.xmlsig.JKSKeyProvider)2 KeyStore (java.security.KeyStore)2 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)1 KeyStoreException (java.security.KeyStoreException)1 Provider (java.security.Provider)1 Enumeration (java.util.Enumeration)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1