[java-identity-provider COMMIT] in /trunk/idp-attribute-filter-api/src: main/java/net/shibboleth/idp/attribute/filter...
noreply at shibboleth.net
noreply at shibboleth.net
Mon Jun 24 05:20:09 EDT 2013
Author: rdw
Date: Mon Jun 24 05:20:08 2013
New Revision: 4539
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4539&view=rev
Log:
IDP-287 use @NonnullAfterInit
Modified:
trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/AttributeRule.java
trunk/idp-attribute-filter-api/src/test/java/net/shibboleth/idp/attribute/filter/AttributeValueFilterPolicyTest.java
Modified: trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/AttributeRule.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/AttributeRule.java?rev=4539&r1=4538&r2=4539&view=diff
==============================================================================
--- trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/AttributeRule.java (original)
+++ trunk/idp-attribute-filter-api/src/main/java/net/shibboleth/idp/attribute/filter/AttributeRule.java Mon Jun 24 05:20:08 2013
@@ -25,6 +25,7 @@
import net.shibboleth.idp.attribute.Attribute;
import net.shibboleth.idp.attribute.AttributeValue;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -63,10 +64,7 @@
</attribute>
</code>
*/
- private String attributeId = "<UnassignedAttributeId>";
-
- /** Whether the attributeId has been set. */
- private boolean attributeIdSet;
+ private String attributeId;
/**
* Filter that permits the release of attribute values.
@@ -88,7 +86,7 @@
*
* @return ID of the attribute to which this rule applies
*/
- @Nonnull public String getAttributeId() {
+ @NonnullAfterInit public String getAttributeId() {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
return attributeId;
}
@@ -104,8 +102,7 @@
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- attributeId = Constraint.isNotNull(StringSupport.trimOrNull(id), "Attribute ID can not be null or empty");
- attributeIdSet = true;
+ attributeId = StringSupport.trimOrNull(id);
}
/**
@@ -204,16 +201,18 @@
protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- if (!attributeIdSet) {
- throw new ComponentInitializationException("No attribute specified for this attribute value filter policy");
+ if (null == getAttributeId()) {
+ throw new ComponentInitializationException("Attribute Rule '" + getId()
+ + "': No attribute specified for this attribute value filter policy");
}
if (permitValueRule == null && denyValueRule == null) {
- throw new ComponentInitializationException("Attribute Rule must have a permit rule or a deny rule");
+ throw new ComponentInitializationException("Attribute Rule '" + getId()
+ + "': must have a permit rule or a deny rule");
}
if (permitValueRule != null && denyValueRule != null) {
- throw new ComponentInitializationException("Attribute Rule must have a permit rule or"
- + " a deny rule, but not both");
+ throw new ComponentInitializationException("Attribute Rule '" + getId()
+ + "': must have a permit rule or a deny rule, but not both");
}
ComponentSupport.initialize(permitValueRule);
Modified: trunk/idp-attribute-filter-api/src/test/java/net/shibboleth/idp/attribute/filter/AttributeValueFilterPolicyTest.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-filter-api/src/test/java/net/shibboleth/idp/attribute/filter/AttributeValueFilterPolicyTest.java?rev=4539&r1=4538&r2=4539&view=diff
==============================================================================
--- trunk/idp-attribute-filter-api/src/test/java/net/shibboleth/idp/attribute/filter/AttributeValueFilterPolicyTest.java (original)
+++ trunk/idp-attribute-filter-api/src/test/java/net/shibboleth/idp/attribute/filter/AttributeValueFilterPolicyTest.java Mon Jun 24 05:20:08 2013
@@ -78,32 +78,31 @@
@Test public void testAttributeId() throws ComponentInitializationException {
AttributeRule policy = new AttributeRule();
policy.setId("id");
- Assert.assertNotNull(policy.getAttributeId(), "AttributeId can never be null");
-
- boolean thrown = false;
+ boolean thrown = false;
+ try {
+ policy.initialize();
+ } catch (ComponentInitializationException e) {
+ thrown = true;
+ }
[... 34 lines stripped ...]
More information about the commits
mailing list