Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal committed Jul 23, 2024
2 parents 2ff36a1 + 0644392 commit 6c304b8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 43 deletions.
6 changes: 3 additions & 3 deletions nifi-file-identity-provider-nar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<parent>
<groupId>io.egm</groupId>
<artifactId>nifi-file-identity-provider-bundle</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
</parent>

<artifactId>nifi-file-identity-provider-nar</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
<packaging>nar</packaging>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
Expand All @@ -35,7 +35,7 @@
<dependency>
<groupId>io.egm</groupId>
<artifactId>nifi-file-identity-provider</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
</dependency>
</dependencies>

Expand Down
20 changes: 15 additions & 5 deletions nifi-file-identity-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<parent>
<groupId>io.egm</groupId>
<artifactId>nifi-file-identity-provider-bundle</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
</parent>

<artifactId>nifi-file-identity-provider</artifactId>
<packaging>jar</packaging>
<properties>
<nifi.version>1.23.2</nifi.version>
<nifi.version>1.27.0</nifi.version>
</properties>

<build>
Expand Down Expand Up @@ -64,7 +64,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
<configuration>
<archive>
<manifest>
Expand Down Expand Up @@ -115,12 +115,12 @@
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.5</version>
<version>4.0.4</version>
</dependency>
</dependencies>
</profile>
Expand All @@ -147,6 +147,16 @@
<artifactId>nifi-properties</artifactId>
<version>${nifi.version}</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,22 @@

package io.egm.nifi.authentication.file;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.InvalidObjectException;
import java.util.List;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import io.egm.nifi.authentication.file.generated.ObjectFactory;
import io.egm.nifi.authentication.file.generated.UserCredentials;
import io.egm.nifi.authentication.file.generated.UserCredentialsList;

import jakarta.xml.bind.*;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.xml.XMLConstants;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InvalidObjectException;
import java.util.List;


/**
* Data access for a simple local XML credentials file. The credentials file
Expand All @@ -55,7 +48,7 @@ public class CredentialsStore {
private static final JAXBContext JAXB_CONTEXT = initializeJaxbContext();
private static final ObjectFactory factory = new ObjectFactory();

private PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
private final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
private File credentialsFile;
private long credentialsListLastModified;
private UserCredentialsList credentialsList = factory.createUserCredentialsList();
Expand All @@ -68,12 +61,7 @@ private static JAXBContext initializeJaxbContext() {
}
}

private static ValidationEventHandler defaultValidationEventHandler = new ValidationEventHandler() {
@Override
public boolean handleEvent(ValidationEvent event) {
return false;
}
};
private static final ValidationEventHandler defaultValidationEventHandler = event -> false;

static UserCredentialsList loadCredentialsList(String filePath) throws Exception {
final File credentialsFile = new File(filePath);
Expand All @@ -90,8 +78,7 @@ static UserCredentialsList loadCredentialsList(File credentialsFile, ValidationE
unmarshaller.setEventHandler(validationEventHandler);
final JAXBElement<UserCredentialsList> element = unmarshaller.unmarshal(new StreamSource(credentialsFile),
UserCredentialsList.class);
UserCredentialsList credentialsList = element.getValue();
return credentialsList;
return element.getValue();
} else {
final String notFoundMessage = "The credentials configuration file was not found at: " +
credentialsFile.getAbsolutePath();
Expand All @@ -110,8 +97,7 @@ static void saveCredentialsList(UserCredentialsList credentialsList, File saveFi

public static CredentialsStore fromFile(String filePath) throws Exception {
UserCredentialsList credentialsList = loadCredentialsList(filePath);
CredentialsStore credStore = new CredentialsStore(credentialsList);
return credStore;
return new CredentialsStore(credentialsList);
}

public static CredentialsStore fromFile(File file) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.egm.nifi.authentication.file.generated.UserCredentials;
import io.egm.nifi.authentication.file.generated.UserCredentialsList;
import jakarta.xml.bind.UnmarshalException;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -59,7 +60,7 @@ public void testLoadCredentialsFile() throws Exception {
public void testLoadInvalidCredentialsFileMessaging() throws Exception {
try {
CredentialsStore.loadCredentialsList(TEST_INVALID_CREDENTIALS_FILE);
} catch (javax.xml.bind.UnmarshalException unmarshalEx) {
} catch (UnmarshalException unmarshalEx) {
String exceptionMessage = unmarshalEx.toString();
assertTrue(exceptionMessage.contains("invalid_credentials"));
assertTrue(exceptionMessage.contains(TEST_INVALID_CREDENTIALS_FILE));
Expand All @@ -71,7 +72,7 @@ public void testLoadInvalidDuplicateUserCredentialsFileMessaging() {
try {
CredentialsStore.loadCredentialsList(TEST_DUPLICATE_USER_CREDENTIALS_FILE);
fail("Duplicate user in credentials file should throw an exception");
} catch (javax.xml.bind.UnmarshalException unmarshalEx) {
} catch (UnmarshalException unmarshalEx) {
String exceptionMessage = unmarshalEx.toString();
assertTrue(exceptionMessage.contains("unique"));
assertTrue(exceptionMessage.contains(TEST_DUPLICATE_USER_CREDENTIALS_FILE));
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
<parent>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-bundles</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
</parent>

<groupId>io.egm</groupId>
<artifactId>nifi-file-identity-provider-bundle</artifactId>
<version>1.23.2</version>
<version>1.27.0</version>
<packaging>pom</packaging>

<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>

<modules>
Expand All @@ -44,7 +44,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down

0 comments on commit 6c304b8

Please sign in to comment.