Skip to content

Commit

Permalink
Merge pull request #15 from easy-global-market/dependabot/maven/devel…
Browse files Browse the repository at this point in the history
…op/org.codehaus.mojo-jaxb2-maven-plugin-3.1.0

chore(deps): bump org.codehaus.mojo:jaxb2-maven-plugin from 2.5.0 to 3.1.0
  • Loading branch information
bobeal authored Oct 31, 2023
2 parents 0c248d1 + d4486bb commit d69f026
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
13 changes: 12 additions & 1 deletion nifi-file-identity-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<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 @@ -144,6 +144,17 @@
<artifactId>nifi-properties</artifactId>
<version>1.23.2</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.0</version>
<scope>runtime</scope>
</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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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 d69f026

Please sign in to comment.