/** * @param props the properties to take the access credentials from. * @throws MissingValueException in case the given properties is missing values. */ public static UrlCredentials getCredentials(Dictionary<String, ?> props) throws MissingValueException { return getCredentials(props, ""); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = IllegalArgumentException.class) public void testGetCredentialsWithNullDictionaryFail() { UrlCredentialsFactory.getCredentials(null); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary, java.lang.String)}. */ @Test(expectedExceptions = IllegalArgumentException.class) public void testGetCredentialsWithNullPrefixFail() { UrlCredentialsFactory.getCredentials(new Hashtable<String, Object>(), null); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryMissingBaseUrlFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "none"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = IllegalArgumentException.class) public void testGetCredentialsWithDictionaryInvalidAuthTypeFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "nonsense"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test() public void testGetCredentialsWithValidDictionaryOk() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "none"); UrlCredentialsFactory.getCredentials(props); } }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryBasicTypeMissingUserNameFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic"); props.put(UrlCredentialsFactory.KEY_AUTH_USER_PASSWORD, "bar"); UrlCredentialsFactory.getCredentials(props); }
/** * {@inheritDoc} */ public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException { UrlCredentials creds; synchronized (m_credentialMapping) { creds = m_credentialMapping.get(pid); } try { creds = UrlCredentialsFactory.getCredentials(properties); synchronized (m_credentialMapping) { m_credentialMapping.put(pid, creds); } } catch (MissingValueException e) { throw new ConfigurationException(e.getProperty(), e.getMessage()); } }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryBasicTypeMissingPasswordFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic"); props.put(UrlCredentialsFactory.KEY_AUTH_USER_NAME, "bar"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test() public void testGetCredentialsWithDictionaryBasicTypeOk() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "basic"); props.put(UrlCredentialsFactory.KEY_AUTH_USER_NAME, "foo"); props.put(UrlCredentialsFactory.KEY_AUTH_USER_PASSWORD, "bar"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryClientCertTypeMissingKeystoreFileFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "bar"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "qux"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "foo"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryClientCertTypeMissingKeystorePasswordFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "bar"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "qux"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "foo"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryClientCertTypeMissingTruststoreFileFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "bar"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "qux"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "foo"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test(expectedExceptions = MissingValueException.class) public void testGetCredentialsWithDictionaryClientCertTypeMissingTruststorePasswordFail() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "bar"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "qux"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "foo"); UrlCredentialsFactory.getCredentials(props); }
/** * Test method for {@link org.apache.ace.connectionfactory.impl.UrlCredentialsFactory#getCredentials(java.util.Dictionary)}. */ @Test() public void testGetCredentialsWithDictionaryClientCertTypeOk() { Dictionary<String, Object> props = new Hashtable<>(); props.put(UrlCredentialsFactory.KEY_AUTH_BASE_URL, AUTH_BASE_URL); props.put(UrlCredentialsFactory.KEY_AUTH_TYPE, "client_cert"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_FILE, "foo"); props.put(UrlCredentialsFactory.KEY_AUTH_TRUSTSTORE_PASS, "bar"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_FILE, "qux"); props.put(UrlCredentialsFactory.KEY_AUTH_KEYSTORE_PASS, "quu"); try { UrlCredentialsFactory.getCredentials(props); } catch (IllegalArgumentException e) { // Ok; expected as the implementation tries to open the files "foo" and "qux"... } }