use of org.apache.qpid.server.util.FileHelper in project qpid-broker-j by apache.
the class FileGroupDatabase method writeGroupFile.
private synchronized void writeGroupFile(final String groupFile) throws IOException {
final Properties propertiesFile = new Properties();
for (String group : _groupToUserMap.keySet()) {
Set<String> users = _groupToUserMap.get(group);
final String userList = Joiner.on(",").useForNull("").join(users);
propertiesFile.setProperty(group + ".users", userList);
}
new FileHelper().writeFileSafely(new File(groupFile).toPath(), new BaseAction<File, IOException>() {
@Override
public void performAction(File file) throws IOException {
String comment = "Written " + new Date();
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
propertiesFile.store(fileOutputStream, comment);
}
}
});
}
use of org.apache.qpid.server.util.FileHelper in project qpid-broker-j by apache.
the class FileBasedGroupProviderImpl method onCreate.
@Override
protected void onCreate() {
super.onCreate();
File file = new File(_path);
if (!file.exists()) {
File parent = file.getAbsoluteFile().getParentFile();
if (!parent.exists() && !parent.mkdirs()) {
throw new IllegalConfigurationException(String.format("Cannot create groups file at '%s'", _path));
}
try {
String posixFileAttributes = getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS);
new FileHelper().createNewFile(file, posixFileAttributes);
} catch (IOException e) {
throw new IllegalConfigurationException(String.format("Cannot create groups file at '%s'", _path), e);
}
}
}
use of org.apache.qpid.server.util.FileHelper in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method onCreate.
@Override
protected void onCreate() {
super.onCreate();
File passwordFile = new File(_path);
if (!passwordFile.exists()) {
try {
Path path = new FileHelper().createNewFile(passwordFile, getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS));
if (!Files.exists(path)) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path));
}
} catch (IOException e) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path), e);
}
}
}
Aggregations