protected KeyInfo getServerKeyInfo(String alias) { Credential serverCredential = keyManager.getCredential(alias); if (serverCredential == null) { throw new RuntimeException("Key for alias " + alias + " not found"); } else if (serverCredential.getPrivateKey() == null) { throw new RuntimeException("Key with alias " + alias + " doesn't have a private key"); } return generateKeyInfoForCredential(serverCredential); }
@Test public void testWithWorkingCertificate() throws Exception { SamlConfig config = new SamlConfig(); config.setPrivateKey(KEY); config.setPrivateKeyPassword(PASSWORD); config.setCertificate(CERTIFICATE); keyManager = SamlKeyManagerFactory.getKeyManager(config); Credential credential = keyManager.getDefaultCredential(); assertNotNull(credential.getPrivateKey()); assertNotNull(credential.getPublicKey()); assertNotNull(credential); }
/** {@inheritDoc} */ public KeyInfoGenerator newInstance() { //TODO lock options during cloning ? BasicOptions newOptions = options.clone(); return new BasicKeyInfoGenerator(newOptions); }
/** * Determine whether the credential is a local credential. * * A local credential will have either a private key or a secret (symmetric) key. * * @param credential the credential to evaluate * @return true if the credential has either a private or secret key, false otherwise */ protected boolean isLocalCredential(Credential credential) { return credential.getPrivateKey() != null || credential.getSecretKey() != null; }
/** * Sets the public key for this credential. * * @param key public key for this credential */ public void setPublicKey(PublicKey key) { publicKey = key; if (key != null) { setSecretKey(null); } }
/** {@inheritDoc} */ public boolean hasNext() { if (nextCredential != null) { return true; } nextCredential = getNextCredential(); if (nextCredential != null) { return true; } return false; }
/** * Constructor. */ public AbstractCredential() { credentialContextSet = new CredentialContextSet(); }
/** Constructor. */ public X509KeyInfoGeneratorFactory() { super(); options = (X509Options) super.getOptions(); }
/** * Constructor. * * All boolean options are initialzed as false; */ public BasicKeyInfoGeneratorFactory() { options = newOptions(); }
/** * Get a new instance to hold options. Used by the top-level superclass constructor. * Subclasses <strong>MUST</strong> override to produce an instance of the appropriate * subclass of {@link BasicOptions}. * * @return a new instance of factory/generator options */ protected BasicOptions newOptions() { return new BasicOptions(); }
try { Credential signingCredential = openSAMLContext.keyStoreCredentialResolver().resolveSingle(criteriaSet); String relayState = authState; LOG.debug("Sending authnRequest to {}", target);
@Test public void test_add_certs_keys_only() throws Exception { config.setKeys(EMPTY_MAP); config.addAndActivateKey("cert-only", new SamlKey(null, null, certificate1)); JKSKeyManager manager1 = (JKSKeyManager) SamlKeyManagerFactory.getKeyManager(config); assertNotNull(manager1.getDefaultCredential().getPublicKey()); assertNull(manager1.getDefaultCredential().getPrivateKey()); }
/** * Determine whether the credential is a local credential. * * A local credential will have either a private key or a secret (symmetric) key. * * @param credential the credential to evaluate * @return true if the credential has either a private or secret key, false otherwise */ protected boolean isLocalCredential(Credential credential) { return credential.getPrivateKey() != null || credential.getSecretKey() != null; }
/** * Sets the private key for this credential. * * @param key private key for this credential */ public void setPrivateKey(PrivateKey key) { privateKey = key; if (key != null) { setSecretKey(null); } } }
/** {@inheritDoc} */ public KeyInfoGenerator newInstance() { //TODO lock options during cloning ? BasicOptions newOptions = options.clone(); return new BasicKeyInfoGenerator(newOptions); }
/** {@inheritDoc} */ public boolean hasNext() { if (nextCredential != null) { return true; } nextCredential = getNextCredential(); if (nextCredential != null) { return true; } return false; }
/** * Constructor. */ public AbstractCredential() { credentialContextSet = new CredentialContextSet(); }
keyManager = SamlKeyManagerFactory.getKeyManager(config); Credential credential = keyManager.getDefaultCredential(); assertNotNull(credential.getPrivateKey()); assertNotNull(credential.getPublicKey()); assertNotNull(credential);
/** * Sets the private key for this credential. * * @param key private key for this credential */ public void setPrivateKey(PrivateKey key) { privateKey = key; if (key != null) { setSecretKey(null); } } }
/** * Sets the public key for this credential. * * @param key public key for this credential */ public void setPublicKey(PublicKey key) { publicKey = key; if (key != null) { setSecretKey(null); } }