You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2014/01/30 12:22:27 UTC
svn commit: r1562778 - in
/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml:
bean/ConditionsBean.java builder/SAML1ComponentBuilder.java
builder/SAML2ComponentBuilder.java
Author: coheigea
Date: Thu Jan 30 11:22:27 2014
New Revision: 1562778
URL: http://svn.apache.org/r1562778
Log:
Refactor of how to set SAML Token expiry
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java?rev=1562778&r1=1562777&r2=1562778&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java Thu Jan 30 11:22:27 2014
@@ -29,7 +29,7 @@ import org.joda.time.DateTime;
public class ConditionsBean {
private DateTime notBefore;
private DateTime notAfter;
- private int tokenPeriodMinutes;
+ private long tokenPeriodSeconds;
private String audienceURI;
private boolean oneTimeUse;
private ProxyRestrictionBean proxyRestriction;
@@ -62,7 +62,7 @@ public class ConditionsBean {
public ConditionsBean(
int tokenPeriodMinutes
) {
- this.tokenPeriodMinutes = tokenPeriodMinutes;
+ this.tokenPeriodSeconds = tokenPeriodMinutes * 60;
}
/**
@@ -107,7 +107,7 @@ public class ConditionsBean {
* @return the tokenPeriodMinutes (type int)
*/
public int getTokenPeriodMinutes() {
- return tokenPeriodMinutes;
+ return (int)(tokenPeriodSeconds / 60L);
}
/**
@@ -116,7 +116,25 @@ public class ConditionsBean {
* @param tokenPeriodMinutes the tokenPeriodMinutes to set
*/
public void setTokenPeriodMinutes(int tokenPeriodMinutes) {
- this.tokenPeriodMinutes = tokenPeriodMinutes;
+ this.tokenPeriodSeconds = tokenPeriodMinutes * 60;
+ }
+
+ /**
+ * Get the tokenPeriodSeconds of this object.
+ *
+ * @return the tokenPeriodSeconds (type long)
+ */
+ public long getTokenPeriodSeconds() {
+ return tokenPeriodSeconds;
+ }
+
+ /**
+ * Set the tokenPeriodSeconds.
+ *
+ * @param tokenPeriodSeconds the tokenPeriodSeconds to set
+ */
+ public void setTokenPeriodSeconds(long tokenPeriodSeconds) {
+ this.tokenPeriodSeconds = tokenPeriodSeconds;
}
/**
@@ -174,7 +192,7 @@ public class ConditionsBean {
ConditionsBean that = (ConditionsBean) o;
- if (tokenPeriodMinutes != that.tokenPeriodMinutes) return false;
+ if (tokenPeriodSeconds != that.tokenPeriodSeconds) return false;
if (notBefore == null && that.notBefore != null) {
return false;
@@ -211,7 +229,7 @@ public class ConditionsBean {
*/
@Override
public int hashCode() {
- int result = tokenPeriodMinutes;
+ int result = (int)tokenPeriodSeconds;
if (notBefore != null) {
result = 31 * result + notBefore.hashCode();
}
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java?rev=1562778&r1=1562777&r2=1562778&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML1ComponentBuilder.java Thu Jan 30 11:22:27 2014
@@ -256,7 +256,7 @@ public final class SAML1ComponentBuilder
return conditions;
}
- int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes();
+ long tokenPeriodSeconds = conditionsBean.getTokenPeriodSeconds();
DateTime notBefore = conditionsBean.getNotBefore();
DateTime notAfter = conditionsBean.getNotAfter();
@@ -271,10 +271,13 @@ public final class SAML1ComponentBuilder
} else {
DateTime newNotBefore = new DateTime();
conditions.setNotBefore(newNotBefore);
- if (tokenPeriodMinutes <= 0) {
- tokenPeriodMinutes = 5;
+ if (tokenPeriodSeconds <= 0) {
+ tokenPeriodSeconds = 5L * 60L;
}
- conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes));
+ DateTime notOnOrAfter =
+ new DateTime(newNotBefore.getMillis() + tokenPeriodSeconds * 1000L);
+
+ conditions.setNotOnOrAfter(notOnOrAfter);
}
if (conditionsBean.getAudienceURI() != null) {
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java?rev=1562778&r1=1562777&r2=1562778&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/builder/SAML2ComponentBuilder.java Thu Jan 30 11:22:27 2014
@@ -189,7 +189,7 @@ public final class SAML2ComponentBuilder
return conditions;
}
- int tokenPeriodMinutes = conditionsBean.getTokenPeriodMinutes();
+ long tokenPeriodSeconds = conditionsBean.getTokenPeriodSeconds();
DateTime notBefore = conditionsBean.getNotBefore();
DateTime notAfter = conditionsBean.getNotAfter();
@@ -204,10 +204,13 @@ public final class SAML2ComponentBuilder
} else {
DateTime newNotBefore = new DateTime();
conditions.setNotBefore(newNotBefore);
- if (tokenPeriodMinutes <= 0) {
- tokenPeriodMinutes = 5;
+ if (tokenPeriodSeconds <= 0) {
+ tokenPeriodSeconds = 5L * 60L;
}
- conditions.setNotOnOrAfter(newNotBefore.plusMinutes(tokenPeriodMinutes));
+ DateTime notOnOrAfter =
+ new DateTime(newNotBefore.getMillis() + tokenPeriodSeconds * 1000L);
+
+ conditions.setNotOnOrAfter(notOnOrAfter);
}
if (conditionsBean.getAudienceURI() != null) {