Skip to content

Commit

Permalink
Change VOMS warning message when requesting a too-long proxy
Browse files Browse the repository at this point in the history
The updated message is similar to the one returned by VOMS server and compatible with the expectation of the VOMS test-suite
  • Loading branch information
federicaagostini authored May 27, 2024
1 parent b0fe8a1 commit a71b803
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
17 changes: 10 additions & 7 deletions iam-voms-aa/src/main/java/it/infn/mw/voms/aa/VOMSWarning.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
*/
package it.infn.mw.voms.aa;

public enum VOMSWarning {
import static java.lang.String.format;

OrderNotSatisfied(1, "The requested order could not be satisfied."),
ShortenedAttributeValidity(
2,
"The validity period of the issued attributes has been shortened to the maximum allowed by "
+ "this VOMS server configuration."),
AttributeSubset(3, "Only a subset of the requested attributes has been returned.");
public class VOMSWarning {

public static final String SHORTENED_ATTRIBUTE_VALIDITY_MESSAGE =
"The validity of this VOMS AC in your proxy is shortened to %d seconds, "
+ "which is the maximum allowed by this VOMS server configuration.";

private int code;
private String message;

public static VOMSWarning shortenedAttributeValidity(long maxAcValidityInSeconds) {
return new VOMSWarning(1, format(SHORTENED_ATTRIBUTE_VALIDITY_MESSAGE, maxAcValidityInSeconds));
}

private VOMSWarning(int legacyCode, String message) {

this.code = legacyCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private VOMSWarningMessage(VOMSWarning warning, String vo) {

this.warning = warning;
this.vo = vo;
this.message = null;
this.message = warning.getDefaultMessage();
}

/**
Expand All @@ -41,8 +41,6 @@ public String getVo() {
*/
public String getMessage() {

if (message == null)
return warning.getDefaultMessage();
return message;
}

Expand All @@ -54,19 +52,11 @@ public VOMSWarning getWarning() {
return warning;
}

public static VOMSWarningMessage orderingNotSatisfied(String vo) {
public static VOMSWarningMessage shortenedAttributeValidity(String vo,
long maxAcValidityInSeconds) {

return new VOMSWarningMessage(VOMSWarning.OrderNotSatisfied, vo);
}

public static VOMSWarningMessage shortenedAttributeValidity(String vo) {

return new VOMSWarningMessage(VOMSWarning.ShortenedAttributeValidity, vo);
}

public static VOMSWarningMessage attributeSubset(String vo) {

return new VOMSWarningMessage(VOMSWarning.AttributeSubset, vo);
return new VOMSWarningMessage(VOMSWarning.shortenedAttributeValidity(maxAcValidityInSeconds),
vo);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private void handleRequestedValidity(VOMSRequestContext context) {
}

if (requestedValidity > MAX_VALIDITY) {
context.getResponse().getWarnings().add(shortenedAttributeValidity(context.getVOName()));
context.getResponse()
.getWarnings()
.add(shortenedAttributeValidity(context.getVOName(), MAX_VALIDITY));
}

Instant now = clock.instant();
Expand Down

0 comments on commit a71b803

Please sign in to comment.