[java-identity-provider COMMIT] in /trunk: idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/Passw...

noreply at shibboleth.net noreply at shibboleth.net
Thu Mar 10 11:14:22 EST 2016


Author: scantor
Date: Thu Mar 10 11:14:21 2016
New Revision: 8143

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8143&view=rev
Log:
IDP-942 - idp startup fails when no idp.sealer properties defined

https://issues.shibboleth.net/jira/browse/IDP-942

Modified:
    trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/PasswordPrincipalSerializer.java
    trunk/idp-conf/src/main/resources/system/conf/general-authn-system.xml
    trunk/idp-conf/src/main/resources/system/conf/global-system.xml
    trunk/idp-conf/src/main/resources/system/conf/saml-nameid-system.xml
    trunk/idp-conf/src/main/resources/system/flows/cas/login/login-beans.xml
    trunk/idp-conf/src/main/resources/system/flows/client-storage/client-storage-read-beans.xml
    trunk/idp-conf/src/main/resources/system/flows/client-storage/client-storage-write-beans.xml
    trunk/idp-conf/src/main/resources/system/flows/logout/logout-beans.xml
    trunk/idp-conf/src/main/resources/system/flows/logout/logout-propagation-beans.xml
    trunk/idp-conf/src/main/resources/system/flows/saml/saml-abstract-beans.xml
    trunk/idp-conf/src/test/resources/flows/test/client-storage/client-storage-test-beans.xml
    trunk/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/PopulateLogoutPropagationContext.java

Modified: trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/PasswordPrincipalSerializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/PasswordPrincipalSerializer.java?rev=8143&r1=8142&r2=8143&view=diff
==============================================================================
--- trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/PasswordPrincipalSerializer.java	(original)
+++ trunk/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/principal/impl/PasswordPrincipalSerializer.java	Thu Mar 10 11:14:21 2016
@@ -43,11 +43,8 @@
 
 import net.shibboleth.idp.authn.principal.AbstractPrincipalSerializer;
 import net.shibboleth.idp.authn.principal.PasswordPrincipal;
-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.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import net.shibboleth.utilities.java.support.logic.Constraint;
 import net.shibboleth.utilities.java.support.security.DataSealer;
 import net.shibboleth.utilities.java.support.security.DataSealerException;
 import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
@@ -68,7 +65,7 @@
     @Nonnull private final Logger log = LoggerFactory.getLogger(PasswordPrincipalSerializer.class);
 
     /** Data sealer. */
-    @NonnullAfterInit private DataSealer sealer;
+    @Nullable private DataSealer sealer;
     
     /** JSON object bulder factory. */
     @Nonnull private final JsonBuilderFactory objectBuilderFactory;
@@ -83,31 +80,34 @@
      * 
      * @param theSealer encrypting component to use
      */
-    public void setDataSealer(@Nonnull final DataSealer theSealer) {
+    public void setDataSealer(@Nullable final DataSealer theSealer) {
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
         
-        sealer = Constraint.isNotNull(theSealer, "DataSealer cannot be null");
+        sealer = theSealer;
     }
-    
+
     /** {@inheritDoc} */
     @Override
-    protected void doInitialize() throws ComponentInitializationException {
-        super.doInitialize();
-        
-        if (sealer == null) {
-            throw new ComponentInitializationException("DataSealer cannot be null");
+    public boolean supports(@Nonnull final Principal principal) {
+        if (principal instanceof PasswordPrincipal) {
+            if (sealer == null) {
+                log.error("No DataSealer was provided, unable to support PasswordPrincipal serialization");
+                return false;
+            }
+            return true;
+        } else {
+            return false;
         }
     }
 
     /** {@inheritDoc} */
     @Override
-    public boolean supports(@Nonnull final Principal principal) {
-        return principal instanceof PasswordPrincipal;
-    }
-
-    /** {@inheritDoc} */
-    @Override
     @Nonnull @NotEmpty public String serialize(@Nonnull final Principal principal) throws IOException {
+        
+        if (sealer == null) {
+            throw new IOException("No DataSealer was provided, unable to support PasswordPrincipal serialization");
+        }
+        
         final StringWriter sink = new StringWriter(32);
         final JsonGenerator gen = getJsonGenerator(sink);
         try {
@@ -125,12 +125,25 @@
     /** {@inheritDoc} */
     @Override
     public boolean supports(@Nonnull @NotEmpty final String value) {
-        return JSON_PATTERN.matcher(value).matches();
+        if (JSON_PATTERN.matcher(value).matches()) {

[... 319 lines stripped ...]


More information about the commits mailing list