Skip to content

Commit

Permalink
CU-86b14j4e0_check-code-security-reports-at-GitHub-for-all-repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ptorres-prowide committed Sep 17, 2024
1 parent 504d420 commit 39307a3
Show file tree
Hide file tree
Showing 27 changed files with 114 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ public static List<Field151> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field151 fromJson(final String json) {

final Field151 field = new Field151();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ public static List<Field152> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field152 fromJson(final String json) {

final Field152 field = new Field152();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ public static List<Field153> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field153 fromJson(final String json) {

final Field153 field = new Field153();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15A> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15A fromJson(final String json) {

final Field15A field = new Field15A();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15B> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15B fromJson(final String json) {

final Field15B field = new Field15B();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15C> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15C fromJson(final String json) {

final Field15C field = new Field15C();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15D> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15D fromJson(final String json) {

final Field15D field = new Field15D();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15E> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15E fromJson(final String json) {

final Field15E field = new Field15E();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15F> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15F fromJson(final String json) {

final Field15F field = new Field15F();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15G> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15G fromJson(final String json) {

final Field15G field = new Field15G();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15H> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15H fromJson(final String json) {

final Field15H field = new Field15H();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15I> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15I fromJson(final String json) {

final Field15I field = new Field15I();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15J> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15J fromJson(final String json) {

final Field15J field = new Field15J();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15K> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15K fromJson(final String json) {

final Field15K field = new Field15K();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15L> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15L fromJson(final String json) {

final Field15L field = new Field15L();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15M> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15M fromJson(final String json) {

final Field15M field = new Field15M();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15N> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15N fromJson(final String json) {

final Field15N field = new Field15N();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15O> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15O fromJson(final String json) {

final Field15O field = new Field15O();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public static List<Field15P> getAll(final SwiftTagListBlock block) {
* @since 7.10.3
* @see Field#fromJson(String)
*/
@SuppressWarnings("unused")
public static Field15P fromJson(final String json) {

final Field15P field = new Field15P();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1434,25 +1434,29 @@ public String getComponentLabel(final int number) {
*/
public String getLabelForLineNumber(String lineIdentifier) {
if (StringUtils.isNumeric(StringUtils.trimToNull(lineIdentifier))) {
int number = Integer.valueOf(lineIdentifier.trim());
if (number == 1) {
return "Name of the Ordering Customer";
} else if (number == 2) {
return "Address Line";
} else if (number == 3) {
return "Country and Town";
} else if (number == 4) {
return "Date of Birth";
} else if (number == 5) {
return "Place of Birth";
} else if (number == 6) {
return "Customer Identification Number";
} else if (number == 7) {
return "National Identity Number";
} else if (number == 8) {
return "Additional Information";
}
}
try {
int number = Integer.valueOf(lineIdentifier.trim());
if (number == 1) {
return "Name of the Ordering Customer";
} else if (number == 2) {
return "Address Line";
} else if (number == 3) {
return "Country and Town";
} else if (number == 4) {
return "Date of Birth";
} else if (number == 5) {
return "Place of Birth";
} else if (number == 6) {
return "Customer Identification Number";
} else if (number == 7) {
return "National Identity Number";
} else if (number == 8) {
return "Additional Information";
}
} catch (NumberFormatException e) {
// ignore
}
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1416,14 +1416,18 @@ public String getComponentLabel(final int number) {
*/
public String getLabelForLineNumber(String lineIdentifier) {
if (StringUtils.isNumeric(StringUtils.trimToNull(lineIdentifier))) {
int number = Integer.valueOf(lineIdentifier.trim());
if (number == 1) {
return "Name of Beneficiary Customer";
} else if (number == 2) {
return "Address Line";
} else if (number == 3) {
return "Country and Town";
}
try {
int number = Integer.valueOf(lineIdentifier.trim());
if (number == 1) {
return "Name of Beneficiary Customer";
} else if (number == 2) {
return "Address Line";
} else if (number == 3) {
return "Country and Town";
}
} catch (NumberFormatException e) {
// ignore
}
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ private Field getField(final Node t) {
String text = getText(n);
// normalize line feeds (DOM parser removes carriage return characters from original XML file)
text = StringUtils.replace(text, "\n", FINWriterVisitor.SWIFT_EOL);
field.setComponent(Integer.parseInt(number), text);
try {
field.setComponent(Integer.parseInt(number), text);
} catch (NumberFormatException e) {
log.warning(
"error setting component " + number + " for field " + name + ": " + e.getMessage());
return null;
}
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/com/prowidesoftware/swift/model/MtSwiftMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public MtSwiftMessage() {}

/**
* Calls {@link #MtSwiftMessage(String, MessageMetadataStrategy)} with the {@link DefaultMtMetadataStrategy}
*
* @param fin the plain FIN message content
*/
public MtSwiftMessage(final String fin) {
Expand Down Expand Up @@ -98,6 +99,7 @@ public MtSwiftMessage(final String fin, final MessageMetadataStrategy metadataSt

/**
* Calls {@link #MtSwiftMessage(InputStream, MessageMetadataStrategy)} with the {@link DefaultMtMetadataStrategy}
*
* @param stream input stream to read
* @throws IOException on error during file reading
*/
Expand All @@ -110,7 +112,7 @@ public MtSwiftMessage(final InputStream stream) throws IOException {
* <br>
* File format is set to {@link FileFormat#FIN}.
*
* @param stream input stream to read
* @param stream input stream to read
* @param metadataStrategy a strategy for metadata extraction
* @throws IOException on error during file reading
* @since 9.1.4
Expand All @@ -134,7 +136,7 @@ public MtSwiftMessage(final File file) throws IOException {
* <br>
* File format is set to {@link FileFormat#FIN}
*
* @param file file holding message content
* @param file file holding message content
* @param metadataStrategy a strategy for metadata extraction
* @throws IOException on error during file reading
* @since 9.1.4
Expand Down Expand Up @@ -342,6 +344,7 @@ private void applyStrategy(SwiftMessage model, MessageMetadataStrategy strategy)

/**
* Calls {@link #updateFromFIN(String, MessageMetadataStrategy)} with the {@link DefaultMtMetadataStrategy}
*
* @param fin raw (FIN) message content to update from
*/
public void updateFromFIN(final String fin) {
Expand Down Expand Up @@ -451,10 +454,13 @@ public SwiftMessage modelMessage() {
public Integer getMessageTypeInt() {
final String number = getMessageType();
if (StringUtils.isNumeric(number)) {
return Integer.parseInt(number);
} else {
return null;
try {
return Integer.parseInt(number);
} catch (NumberFormatException e) {
log.log(Level.WARNING, "error parsing message type as number: " + e.getMessage(), e);
}
}
return null;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/prowidesoftware/swift/model/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ public Integer getNumber() {
}
}
if (sb.length() > 0) {
return Integer.parseInt(sb.toString());
try {
return Integer.parseInt(sb.toString());
} catch (NumberFormatException e) {
return null;
}
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,6 @@ public void addText(final SwiftMessage message) {
this.addText(msg);
}

/**
* removes an unparsed text
*
* @param index the index of the text to remove
* @throws IllegalArgumentException if parameter index is null
* @throws IndexOutOfBoundsException if parameter index is out of bounds
*/
public void removeText(final Integer index) {
// sanity check
Objects.requireNonNull(index, WRITER_MESSAGE);

// remove the text
this.texts.remove(index.intValue());
}

/**
* removes an unparsed text
*
Expand Down
32 changes: 30 additions & 2 deletions src/main/java/com/prowidesoftware/swift/utils/IsoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public static IsoUtils getInstance() {
}

public Set<String> getCurrencies() {
return currencies;
return Collections.unmodifiableSet(currencies);
}

public void setCurrencies(Set<String> currencies) {
this.currencies = currencies;
}

public Set<String> getCountries() {
return countries;
return Collections.unmodifiableSet(countries);
}

public void setCountries(Set<String> countries) {
Expand Down Expand Up @@ -115,6 +115,20 @@ public void addCountry(final String countryCode) {
countries.add(countryCode);
}

/**
* Removes the given country code from the current list of codes.
*
* @param countryCode a two capital letters country code, for example: XK
* @throws IllegalArgumentException if the parameter code is null or not two uppercase letters
* @since 9.4.18
*/
public void removeCountry(final String countryCode) {
Validate.isTrue(
countryCode != null && countryCode.length() == 2 && countryCode.matches("[A-Z]*"),
"The country code must be indicated with two uppercase letters");
countries.remove(countryCode);
}

/**
* Adds the given currency code to the current list of codes, verifying that it does not exist previously.
*
Expand All @@ -128,4 +142,18 @@ public void addCurrency(final String currencyCode) {
"The currency code must by indicated with three uppercase letters");
currencies.add(currencyCode);
}

/**
* Removes the given currency code from the current list of codes.
*
* @param currencyCode a three capital letters currency code, for example: ARS
* @throws IllegalArgumentException if the parameter code is null or not three uppercase letters
* @since 9.4.18
*/
public void removeCurrency(final String currencyCode) {
Validate.isTrue(
currencyCode != null && currencyCode.length() == 3 && currencyCode.matches("[A-Z]*"),
"The currency code must be indicated with three uppercase letters");
currencies.remove(currencyCode);
}
}
Loading

0 comments on commit 39307a3

Please sign in to comment.