private static Map<String, String> createAuthorizationAttributeMap( String snaaName, Properties props) { Map<String, String> attributes = new HashMap<String, String>(); List<String> keys = new LinkedList<String>(); // getting keys from properties for (Object o : props.keySet()) { if (((String) o).startsWith(snaaName + authorizationAtt) && ((String) o).endsWith(authorizationKeyAtt)) { keys.add((String) o); } } for (String k : keys) { String key = props.getProperty(k); // getting plain key-number from properties String plainKeyProperty = k.replaceAll(snaaName + authorizationAtt + ".", ""); plainKeyProperty = plainKeyProperty.replaceAll(authorizationKeyAtt, ""); String keyPrefix = snaaName + authorizationAtt + "." + plainKeyProperty; // building value-property-string String value = props.getProperty(keyPrefix + authorizationValAtt); // finally put key and values attributes.put(key, value); } return attributes; }
private static AuthorizationDataSource getAuthorizationDataSource( String snaaName, Properties props) throws ClassNotFoundException, IllegalAccessException, InstantiationException { for (Object o : props.keySet()) { String dataSourceName = snaaName + authorizationAtt + authorizationDataSource; if (o.equals(dataSourceName)) { AuthorizationDataSource dataSource = (AuthorizationDataSource) Class.forName(props.getProperty((String) o)).newInstance(); String dataSourceUsername = props.getProperty(dataSourceName + authorizationDataSourceUsername); String dataSourcePassword = props.getProperty(dataSourceName + authorizationDataSourcePassword); String dataSourceUrl = props.getProperty(dataSourceName + authorizationDataSourceUrl); if (dataSourceUsername != null) { dataSource.setUsername(dataSourceUsername); } if (dataSourcePassword != null) { dataSource.setPassword(dataSourcePassword); } if (dataSourceUrl != null) { dataSource.setUrl(dataSourceUrl); } return dataSource; } } // set default return new ShibbolethDataSource(); }