diff options
Diffstat (limited to 'id/server/idserverlib')
4 files changed, 67 insertions, 13 deletions
| diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java index fe5a96c18..e39f3606e 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java @@ -7,6 +7,9 @@ import java.util.List;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.auth.exception.AuthenticationException;  import at.gv.egovernment.moa.id.auth.exception.MOAIDException; +import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; +import at.gv.egovernment.moa.id.commons.db.dao.config.OAStorkAttribute; +import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute;  import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;  import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -168,14 +171,17 @@ public class AttributeCollector implements IAction {  				currentAttribute.setStatus("notAvailable");  				aquiredAttributes.add((PersonalAttribute) currentAttribute.clone());  				addOrUpdateAll(container.getResponse().getPersonalAttributeList(), aquiredAttributes); -              	// - check if we can find a suitable AttributeProvider Plugin                  for (AttributeProvider currentProvider : AttributeProviderFactory.getConfiguredPlugins(oaParam.getStorkAPs())) { +                      try {                          // - hand over control to the suitable plugin                      	Logger.info(currentProvider.getClass().getSimpleName() + " called to handle attribute '" + currentAttribute.getName() + "'"); -                        aquiredAttributes = currentProvider.acquire(currentAttribute, container.getRequest().getSpCountry(), moasession); -                    	Logger.info(currentProvider.getClass().getSimpleName() + " can handle attribute '" + currentAttribute.getName() + "'"); + +                        //aquiredAttributes = currentProvider.acquire(currentAttribute, container.getRequest().getSpCountry(), moasession); +                        aquiredAttributes = currentProvider.acquire(missingAttributes, container.getRequest().getSpCountry(), moasession); + +                        Logger.info(currentProvider.getClass().getSimpleName() + " can handle attribute '" + currentAttribute.getName() + "'");                          break;                      } catch (UnsupportedAttributeException e) {                          // ok, try the next attributeprovider @@ -244,7 +250,7 @@ public class AttributeCollector implements IAction {  	private void addOrUpdateAll(IPersonalAttributeList target, IPersonalAttributeList source) throws MOAIDException {  		Logger.debug("Updating " + source.size() + " attributes...");  		for (PersonalAttribute current : source) { -			Logger.trace("treating " + current.getName()); +			Logger.debug("treating " + current.getName());  			// check if we need to update the current pa  			if (target.containsKey(current.getName())) { @@ -261,7 +267,7 @@ public class AttributeCollector implements IAction {  			} else  				target.add(current); -			Logger.trace("...successfully treated " + current.getName()); +			Logger.debug("...successfully treated " + current.getName());  		}  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java index 2914d8f7d..8203c0c63 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java @@ -10,6 +10,8 @@ import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import eu.stork.peps.auth.commons.IPersonalAttributeList;  import eu.stork.peps.auth.commons.PersonalAttribute; +import java.util.List; +  /**   * An {@link AttributeProvider} can fetch a set of stork attributes. It might complete the query within one method call,   * but might also need to redirect to another webservice to accomplish its task. @@ -31,7 +33,9 @@ public interface AttributeProvider {  	 */  	public IPersonalAttributeList acquire(PersonalAttribute attributes, String spCountyCode, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException; -	/** +    public IPersonalAttributeList acquire(List<PersonalAttribute> attributes, String spCountyCode, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException; + +    /**  	 * Perform redirect.  	 *  	 * @param url the return URL ending with ?artifactId=... @@ -52,5 +56,14 @@ public interface AttributeProvider {  	 */  	public IPersonalAttributeList parse(HttpServletRequest httpReq) throws UnsupportedAttributeException, MOAIDException; +    /** +     * Returns the list of supported attributes +     * +     * @return a list of attributes +     * @throws MOAIDException if something went wrong +     */ +    //public IPersonalAttributeList getSupportedAttributes() throws MOAIDException; + +  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java index 370182e71..332d407be 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java @@ -1,10 +1,7 @@  package at.gv.egovernment.moa.id.protocols.stork2;  import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; +import java.util.*;  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletResponse; @@ -202,9 +199,19 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider {  		}  	} -	/* (non-Javadoc) -	 * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#performRedirect(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, at.gv.egovernment.moa.id.config.auth.OAAuthParameter) -	 */ +    @Override +    public IPersonalAttributeList acquire(List<PersonalAttribute> attributes, String spCountyCode, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException { +        if (attributes.size() == 1) { +            return acquire(attributes.get(0), spCountyCode, moasession); +        } else { +            throw new MOAIDException("stork.13", new Object[] {  });  // TODO message only one attribute supported by this provider + +        } +    } + +    /* (non-Javadoc) +     * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#performRedirect(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, at.gv.egovernment.moa.id.config.auth.OAAuthParameter) +     */  	public void performRedirect(String url,  			HttpServletRequest req, HttpServletResponse resp,  			OAAuthParameter oaParam) throws MOAIDException { diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java index cae5e698b..ccbe2abbd 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java @@ -2,6 +2,7 @@ package at.gv.egovernment.moa.id.protocols.stork2;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.auth.exception.MOAIDException; +import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.util.HTTPUtils;  import at.gv.egovernment.moa.id.util.VelocityProvider; @@ -17,6 +18,7 @@ import org.apache.velocity.app.VelocityEngine;  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletResponse;  import java.io.StringWriter; +import java.util.List;  /**   * Provides mandate attribute from MIS @@ -65,6 +67,28 @@ public class MandateAttributeRequestProvider implements AttributeProvider {          throw new ExternalAttributeRequestRequiredException(this);      } +    @Override +    public IPersonalAttributeList acquire(List<PersonalAttribute> attributes, String spCountryCode, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException { +        Logger.info("Acquiring " + attributes.size() + "  attributes, by: " + getAttrProviderName()); +        this.spCountryCode = spCountryCode; +        requestedAttributes = new PersonalAttributeList(attributes.size()); + +        for (PersonalAttribute personalAttribute : attributes) { +            // break if we cannot handle the requested attribute +            if (!this.attributes.contains(personalAttribute.getName())) { +                Logger.info("Attribute " + personalAttribute.getName() + " not supported by the provider: " + getAttrProviderName()); +                throw new UnsupportedAttributeException(); +            } +            requestedAttributes.add(personalAttribute); +        } + +        Logger.info("Thrown external request by: " + getAttrProviderName()); +        throw new ExternalAttributeRequestRequiredException(this); +    } + + + +      public void performRedirect(String url, HttpServletRequest req, HttpServletResponse resp, OAAuthParameter oaParam) throws MOAIDException {          String spSector = "Business"; @@ -87,6 +111,9 @@ public class MandateAttributeRequestProvider implements AttributeProvider {          attributeRequest.setCitizenCountryCode("AT"); + + +          Logger.info("STORK AttrRequest successfully assembled.");          STORKSAMLEngine samlEngine = STORKSAMLEngine.getInstance("VIDP"); @@ -124,5 +151,6 @@ public class MandateAttributeRequestProvider implements AttributeProvider {          return null;  //      } +  } | 
