Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change VOMS warning message when requesting a too long proxy #756

Merged
merged 8 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading