diff options
Diffstat (limited to 'id/server')
60 files changed, 649 insertions, 771 deletions
| diff --git a/id/server/auth/.settings/org.eclipse.wst.common.component b/id/server/auth/.settings/org.eclipse.wst.common.component index 10109d2c2..40733a1ce 100644 --- a/id/server/auth/.settings/org.eclipse.wst.common.component +++ b/id/server/auth/.settings/org.eclipse.wst.common.component @@ -6,13 +6,13 @@          <dependent-module archiveName="moa-common-2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-common/moa-common">              <dependency-type>uses</dependency-type>          </dependent-module> -        <dependent-module archiveName="moa-id-lib-1.9.97-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-lib/moa-id-lib"> +        <dependent-module archiveName="moa-id-lib-1.9.96-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-lib/moa-id-lib">              <dependency-type>uses</dependency-type>          </dependent-module>          <dependent-module archiveName="stork-saml-engine-1.5.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/stork-saml-engine/stork-saml-engine">              <dependency-type>uses</dependency-type>          </dependent-module> -        <dependent-module archiveName="moa-id-commons-1.9.97-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-commons/moa-id-commons"> +        <dependent-module archiveName="moa-id-commons-1.9.96-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-commons/moa-id-commons">              <dependency-type>uses</dependency-type>          </dependent-module>      <property name="context-root" value="moa-id-auth"/> diff --git a/id/server/auth/pom.xml b/id/server/auth/pom.xml index 350087e40..3423deb79 100644 --- a/id/server/auth/pom.xml +++ b/id/server/auth/pom.xml @@ -2,7 +2,7 @@  	<parent>  		<groupId>MOA.id</groupId>  		<artifactId>moa-id</artifactId> -		<version>1.9.97-SNAPSHOT</version> +		<version>1.9.96-SNAPSHOT</version>  	</parent>  	<modelVersion>4.0.0</modelVersion> diff --git a/id/server/idserverlib/pom.xml b/id/server/idserverlib/pom.xml index 9732f8a63..3cc7c38de 100644 --- a/id/server/idserverlib/pom.xml +++ b/id/server/idserverlib/pom.xml @@ -3,7 +3,7 @@  	<parent>
  		<groupId>MOA.id</groupId>
  		<artifactId>moa-id</artifactId>
 -		<version>1.9.97-SNAPSHOT</version>
 +		<version>1.9.96-SNAPSHOT</version>
  	</parent>
  	<modelVersion>4.0.0</modelVersion>
 diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java index 014a9ec03..af23d4c78 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java @@ -1155,14 +1155,7 @@ public class AuthenticationServer implements MOAIDAuthConstants {  		CreateXMLSignatureResponse csresp = new CreateXMLSignatureResponseParser(  				xmlCreateXMLSignatureReadResponse).parseResponse(); -		 -		Element signature = csresp.getDsigSignature(); -		 -		  		try { -			String test = DOMUtils.serializeNode(signature); -			 -			  			String serializedAssertion = DOMUtils.serializeNode(csresp  					.getSamlAssertion());  			session.setAuthBlock(serializedAssertion); @@ -1695,36 +1688,37 @@ public class AuthenticationServer implements MOAIDAuthConstants {  	   * @param signature XMLDSIG signature  	   * @return Identity link assertion  	 * @throws SZRGWClientException  -	 * @throws ConfigurationException   	   */ -	     public CreateIdentityLinkResponse getIdentityLink(String PEPSIdentifier, String PEPSFirstname, String PEPSFamilyname, String PEPSDateOfBirth, Element signature) throws SZRGWClientException, ConfigurationException { +	     public CreateIdentityLinkResponse getIdentityLink(String PEPSIdentifier, String PEPSFirstname, String PEPSFamilyname, String PEPSDateOfBirth, Element signature) throws SZRGWClientException {  		    SZRGWClient client = new SZRGWClient(); -		   	AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); -		   	ConnectionParameter connectionParameters = authConf.getForeignIDConnectionParameter(); - -		   	client.setAddress(connectionParameters.getUrl()); -		   	if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) { -		   		Logger.debug("Initialisiere SSL Verbindung"); -		   		try { -		   			client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); -		   			 -		   		} catch (IOException e) { -		   			Logger.error("Could not initialize SSL Factory", e); -		   			throw new SZRGWClientException("Could not initialize SSL Factory"); -		   			 -		   		} catch (GeneralSecurityException e) { -		   			Logger.error("Could not initialize SSL Factory", e); -		   			throw new SZRGWClientException("Could not initialize SSL Factory"); -		   			 -		    	} catch (PKIException e) { -		    		Logger.error("Could not initialize SSL Factory", e); -		    		throw new SZRGWClientException("Could not initialize SSL Factory"); -		    	}  -		   	} -		   		 +		    try { +		    	AuthConfigurationProvider authConf = AuthConfigurationProvider.getInstance(); +		    	ConnectionParameter connectionParameters = authConf.getForeignIDConnectionParameter(); + +		    	client.setAddress(connectionParameters.getUrl()); +		    	if (connectionParameters.getUrl().toLowerCase().startsWith("https:")) { +		    		Logger.debug("Initialisiere SSL Verbindung"); +		    		try { +		    			client.setSSLSocketFactory(SSLUtils.getSSLSocketFactory(AuthConfigurationProvider.getInstance(), connectionParameters)); +		    		} catch (IOException e) { +		    			Logger.error("Could not initialize SSL Factory", e); +		    			throw new SZRGWClientException("Could not initialize SSL Factory"); +		    		} catch (GeneralSecurityException e) { +		    			Logger.error("Could not initialize SSL Factory", e); +		    			throw new SZRGWClientException("Could not initialize SSL Factory"); +		    		} catch (PKIException e) { +		    			Logger.error("Could not initialize SSL Factory", e); +		    			throw new SZRGWClientException("Could not initialize SSL Factory"); +		    		}  +		    	}  		    	Logger.info("Starte Kommunikation mit dem Stammzahlenregister Gateway(" + connectionParameters.getUrl() + ")..."); +		    } +		    catch (ConfigurationException e) { +		    	Logger.warn(e); +		    	Logger.warn(MOAIDMessageProvider.getInstance().getMessage("config.12", null )); +		    }  		    // create request  		    CreateIdentityLinkResponse response = null; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilder.java index 3a308f6da..f5d603480 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationBlockAssertionBuilder.java @@ -190,22 +190,9 @@ public class AuthenticationBlockAssertionBuilder extends AuthenticationAssertion           gebeORwbpk = MessageFormat.format(WBPK_ATTRIBUTE, new Object[] { identityLinkValue, identityLinkType });           wbpkNSDeclaration = " xmlns:pr=\"" + PD_NS_URI + "\""; -         //adding type of wbPK domain identifier -          -        String idtype = oaParam.getIdentityLinkDomainIdentifierType(); -        if (MiscUtil.isEmpty(idtype)) { -        	if (identityLinkType.contains("FN")) -        		idtype = "Firmenbuchnummer"; -        	else if (identityLinkType.contains("ZVR")) -        		idtype = "Vereinsnummer"; -        	else if (identityLinkType.contains("ERSB")) -        		idtype = "ERJPZahl"; -        	else  -        		idtype = "Bereichskennung"; -        } -        	 +         //adding type of wbPK domain identifier                  ExtendedSAMLAttribute idLinkDomainIdentifierTypeAttribute =  -             new ExtendedSAMLAttributeImpl("IdentityLinkDomainIdentifierType", idtype, Constants.MOA_NS_URI, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY); +             new ExtendedSAMLAttributeImpl("IdentityLinkDomainIdentifierType", oaParam.getIdentityLinkDomainIdentifierType(), Constants.MOA_NS_URI, ExtendedSAMLAttribute.ADD_TO_AUTHBLOCK_ONLY);          extendedSAMLAttributes.add(idLinkDomainIdentifierTypeAttribute); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilder.java index 5d94d2f16..fd5ff6744 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/PersonDataBuilder.java @@ -27,11 +27,8 @@ package at.gv.egovernment.moa.id.auth.builder;  import org.w3c.dom.Element;  import org.w3c.dom.Node; -import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants;  import at.gv.egovernment.moa.id.auth.data.IdentityLink;  import at.gv.egovernment.moa.id.auth.exception.BuildException; -import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration; -import at.gv.egovernment.moa.util.Constants;  import at.gv.egovernment.moa.util.DOMUtils;  import at.gv.egovernment.moa.util.XPathUtils; @@ -68,12 +65,9 @@ public class PersonDataBuilder {      try {        Element prPerson = (Element)identityLink.getPrPerson().cloneNode(true); -       -      Node prType = XPathUtils.selectSingleNode(prPerson, "pr:Identification/pr:Type"); - -      if (! provideStammzahl &&  -    		  Constants.URN_PREFIX_BASEID.equals(prType.getFirstChild().getNodeValue())) { -        Node prIdentification = XPathUtils.selectSingleNode(prPerson, "pr:Identification/pr:Value");  +      if (! provideStammzahl) { +        Node prIdentification = XPathUtils.selectSingleNode(prPerson, "pr:Identification/pr:Value");        +        //remove IdentificationValue          prIdentification.getFirstChild().setNodeValue("");        }        String xmlString = DOMUtils.serializeNode(prPerson); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/StartAuthenticationBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/StartAuthenticationBuilder.java index 91040dde2..e4bf37417 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/StartAuthenticationBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/StartAuthenticationBuilder.java @@ -36,7 +36,8 @@ public class StartAuthenticationBuilder {  	    Logger.info("Starting authentication for a citizen of country: " + (StringUtils.isEmpty(moasession.getCcc()) ? "AT" : moasession.getCcc()));      	    // STORK or normal authentication -	    if (storkConfig != null && storkConfig.isSTORKAuthentication(moasession.getCcc())) { +	    //TODO: commented because npe was thrown +	    /*if (storkConfig.isSTORKAuthentication(moasession.getCcc())) {  	    	//STORK authentication  	    	Logger.trace("Found C-PEPS configuration for citizen of country: " + moasession.getCcc());  	    	Logger.debug("Starting STORK authentication"); @@ -44,13 +45,13 @@ public class StartAuthenticationBuilder {  	    	AuthenticationServer.startSTORKAuthentication(req, resp, moasession);  	    	return ""; -	    } else { +	    } else {*/  	    	//normal MOA-ID authentication  	    	Logger.debug("Starting normal MOA-ID authentication");  	    	String getIdentityLinkForm = AuthenticationServer.getInstance().startAuthentication(moasession, req);	     	    	return getIdentityLinkForm; -	    } +	    //}  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java index eaa6ac1ae..98ef78d53 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GenerateIFrameTemplateServlet.java @@ -32,16 +32,16 @@ public class GenerateIFrameTemplateServlet extends AuthServlet {  	private static final long serialVersionUID = 1L;  	public void init(ServletConfig servletConfig) throws ServletException { -//		    try { +		    try {  		      super.init(servletConfig); -//		      MOAIDAuthInitializer.initialize(); -//		      Logger.debug("default platform file.encoding: " + System.getProperty("file.encoding")); -//		      Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null)); -//		    } -//		    catch (Exception ex) { -//		      Logger.fatal(MOAIDMessageProvider.getInstance().getMessage("init.02", null), ex); -//		      throw new ServletException(ex); -//		    } +		      MOAIDAuthInitializer.initialize(); +		      Logger.debug("default platform file.encoding: " + System.getProperty("file.encoding")); +		      Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null)); +		    } +		    catch (Exception ex) { +		      Logger.fatal(MOAIDMessageProvider.getInstance().getMessage("init.02", null), ex); +		      throw new ServletException(ex); +		    }  		  }  	protected void doGet(HttpServletRequest req, HttpServletResponse resp) diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetForeignIDServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetForeignIDServlet.java index 07d006bc2..222faec37 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetForeignIDServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/GetForeignIDServlet.java @@ -156,15 +156,9 @@ public class GetForeignIDServlet extends AuthServlet {  	    	try {  				session.setSignerCertificate(AuthenticationServer.getCertificateFromXML(signature)); -				 -				//String test = DOMUtils.serializeNode(signature); -				  			} catch (CertificateException e) {  				Logger.error("Could not extract certificate from CreateXMLSignatureResponse");  				throw new MOAIDException("auth.14", null); -//			} catch (TransformerException e) { -//				// TODO Auto-generated catch block -//				e.printStackTrace();  			}
  	    	// make SZR request to the identity link
 diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/LogOutServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/LogOutServlet.java index ff8265ac3..9c72cfff2 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/LogOutServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/LogOutServlet.java @@ -101,15 +101,15 @@ public class LogOutServlet extends AuthServlet {     * @see javax.servlet.Servlet#init(ServletConfig)     */    public void init(ServletConfig servletConfig) throws ServletException { -//  	try { +  	try {        super.init(servletConfig); -//      MOAIDAuthInitializer.initialize(); -//  		Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null)); -//  	} -//  	catch (Exception ex) { -//  		Logger.fatal(MOAIDMessageProvider.getInstance().getMessage("init.02", null), ex); -//  		throw new ServletException(ex); -//  	} +      MOAIDAuthInitializer.initialize(); +  		Logger.info(MOAIDMessageProvider.getInstance().getMessage("init.00", null)); +  	} +  	catch (Exception ex) { +  		Logger.fatal(MOAIDMessageProvider.getInstance().getMessage("init.02", null), ex); +  		throw new ServletException(ex); +  	}    }    } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java index c0626e84a..a87e9a8c0 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java @@ -35,7 +35,6 @@ import at.gv.egovernment.moa.id.auth.exception.ParseException;  import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser;
  import at.gv.egovernment.moa.id.auth.validator.parep.client.szrgw.CreateIdentityLinkResponse;
  import at.gv.egovernment.moa.id.auth.validator.parep.client.szrgw.SZRGWClientException;
 -import at.gv.egovernment.moa.id.config.ConfigurationException;
  import at.gv.egovernment.moa.logging.Logger;
  import at.gv.egovernment.moa.util.Constants;
  import at.gv.egovernment.moa.util.DateTimeUtils;
 @@ -349,14 +348,9 @@ public class STORKResponseProcessor {  		} catch (SZRGWClientException e) {
  			Logger.error("Error connecting SZR-Gateway: ", e);
  			throw new STORKException("Error connecting SZR-Gateway: ", e);
 -			
  		} catch (ParseException e) {
  			Logger.error("Error parsing IdentityLink received from SZR-Gateway: ", e);
  			throw new STORKException("Error parsing IdentityLink received from SZR-Gateway: ", e);
 -			
 -		} catch (ConfigurationException e) {
 -			Logger.error("Error connecting SZR-Gateway: ", e);
 -			throw new STORKException("Error connecting SZR-Gateway: ", e);
  		}
      	return identityLink;
 diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java index 4507cd236..29f567324 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/auth/AuthConfigurationProvider.java @@ -417,25 +417,24 @@ public class AuthConfigurationProvider extends ConfigurationProvider {    public synchronized void reloadDataBaseConfig() throws ConfigurationException { -		Logger.info("Read MOA-ID 2.x configuration from database."); +		Logger.info("Read MOA-ID 2.0 configuration from database.");  		moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); +		Logger.info("MOA-ID 2.0 is loaded.");  		if (moaidconfig == null) {  			Logger.warn("NO MOA-ID configuration found.");  			throw new ConfigurationException("config.18", null);  		} - -		Logger.debug("MOA-ID 2.x configuration is loaded from database."); -		Logger.info("MOA-ID 2.x starts initialization process ..."); -		 +						  		//build STORK Config	  		AuthComponentGeneral auth = getAuthComponentGeneral(); -		  		ForeignIdentities foreign = auth.getForeignIdentities();  		if (foreign == null ) {  			Logger.warn("Error in MOA-ID Configuration. No STORK configuration found."); -		} //else    +		}  +		//TODO: commented because npe was thrown +		//else     			//storkconfig = new STORKConfig(foreign.getSTORK(), props, rootConfigFileDir); @@ -787,9 +786,6 @@ public class AuthConfigurationProvider extends ConfigurationProvider {   * @throws ConfigurationException      */    public ConnectionParameter getForeignIDConnectionParameter() throws ConfigurationException { -	  if (ForeignIDConnectionParameter == null) -		  throw new ConfigurationException("config.20", null); -	    	  return ForeignIDConnectionParameter;    } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java index c8f14585a..7130089ae 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java @@ -262,7 +262,7 @@ public class DispatcherServlet extends AuthServlet{  								for (String el : mapkeys) {  									IRequest value = protocolRequests.get(el); -									if (value.getOAURL() != null && value.getOAURL().equals(protocolRequest.getOAURL())) { +									if (value.getOAURL().equals(protocolRequest.getOAURL())) {  										if(!AuthenticationSessionStoreage.deleteSessionWithPendingRequestID(el)) {  											Logger.warn(DispatcherServlet.class.getName()+": NO MOASession with PendingRequestID " + el + " found. Delete all user sessions!"); @@ -423,6 +423,9 @@ public class DispatcherServlet extends AuthServlet{  						moasession = AuthenticationSessionStoreage.getSession(moasessionID);  						moasessionID = AuthenticationSessionStoreage.changeSessionID(moasession);  					} + +					 +  				}  				String assertionID = moduleAction.processRequest(protocolRequest, req, resp, moasession); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/ModulStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/ModulStorage.java index 31bf1ff58..d030b8844 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/ModulStorage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/ModulStorage.java @@ -11,7 +11,7 @@ public class ModulStorage {  	private static final String[] modulClasses = new String[]{  		"at.gv.egovernment.moa.id.protocols.saml1.SAML1Protocol",  		"at.gv.egovernment.moa.id.protocols.pvp2x.PVP2XProtocol", -		"at.gv.egovernment.moa.id.protocols.oauth20.OAuth20Protocol" +		"at.gv.egovernment.moa.id.protocols.oauth20.protocol.OAuth20Protocol"  	}; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java index 7008239ab..0693aef8c 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java @@ -23,41 +23,41 @@ public class SSOManager {  	private static final String SSOCOOKIE = "MOA_ID_SSO"; -	private static final int DEFAULTSSOTIMEOUT = 15*60; //sec +	private static final int DEFAULTSSOTIMEOUT = 15 * 60; // sec  	private static SSOManager instance = null;  	private static int sso_timeout; -	  	public static SSOManager getInstance() {  		if (instance == null) {  			instance = new SSOManager();  			try {  				sso_timeout = (int) AuthConfigurationProvider.getInstance().getTimeOuts().getMOASessionUpdated().longValue(); - -			} catch (ConfigurationException e) { +				 +			} +			catch (ConfigurationException e) {  				Logger.info("SSO Timeout can not be loaded from MOA-ID configuration. Use default Timeout with " + DEFAULTSSOTIMEOUT);  				sso_timeout = DEFAULTSSOTIMEOUT;  			} -		 +			  		}  		return instance;  	}  	public boolean isValidSSOSession(String ssoSessionID, HttpServletRequest httpReq) { -				 -		//search SSO Session +		 +		// search SSO Session  		if (ssoSessionID == null) {  			Logger.info("No SSO Session cookie found."); -			return false;		 +			return false;  		} -//		String moaSessionId =HTTPSessionUtils.getHTTPSessionString(httpReq.getSession(), -//				AuthenticationManager.MOA_SESSION, null); +		// String moaSessionId =HTTPSessionUtils.getHTTPSessionString(httpReq.getSession(), +		// AuthenticationManager.MOA_SESSION, null); -		return AuthenticationSessionStoreage.isValidSessionWithSSOID(ssoSessionID, null);	 +		return AuthenticationSessionStoreage.isValidSessionWithSSOID(ssoSessionID, null);  	} @@ -67,51 +67,65 @@ public class SSOManager {  	public String existsOldSSOSession(String ssoId) { -		  Logger.trace("Check that the SSOID has already been used"); -		  Session session = MOASessionDBUtils.getCurrentSession(); -		   -		  List<OldSSOSessionIDStore> result; -		   -		  synchronized (session) { -			  session.beginTransaction(); -			  Query query = session.getNamedQuery("getSSOSessionWithOldSessionID"); -			  query.setString("sessionid", ssoId); -			  result = query.list(); -			   -			  //send transaction -			   -		  } -		   -		  Logger.trace("Found entries: " + result.size()); -		   -		  //Assertion requires an unique artifact -		  if (result.size() == 0) { -			  session.getTransaction().commit(); -			  return null;   -		  } -		   -		  OldSSOSessionIDStore oldSSOSession = result.get(0); -		   -		  AuthenticatedSessionStore correspondingMoaSession = oldSSOSession.getMoasession(); - -		  if (correspondingMoaSession == null) { -				Logger.info("Get request with old SSO SessionID but no corresponding SSO Session is found."); -				return null; -		  } -		   -		   -		  String moasessionid = correspondingMoaSession.getSessionid(); -		   -		  session.getTransaction().commit(); +		Logger.trace("Check that the SSOID has already been used"); +		Session session = MOASessionDBUtils.getCurrentSession(); +		 +		List<OldSSOSessionIDStore> result; +		 +		synchronized (session) { -		  return moasessionid; - +//			try { +//				session.getTransaction().rollback(); +//			} +//			catch (Exception e) { +//				e.printStackTrace(); +//			} +//			try { +//				session.getSessionFactory().openSession(); +//			} +//			catch (Exception e) { +//				e.printStackTrace(); +//			} +			// session.getTransaction().begin(); +			 +			session.beginTransaction(); +			Query query = session.getNamedQuery("getSSOSessionWithOldSessionID"); +			query.setString("sessionid", ssoId); +			result = query.list(); +			 +			// send transaction +			 +		} +		 +		Logger.trace("Found entries: " + result.size()); +		 +		// Assertion requires an unique artifact +		if (result.size() == 0) { +			session.getTransaction().commit(); +			return null; +		} +		 +		OldSSOSessionIDStore oldSSOSession = result.get(0); +		 +		AuthenticatedSessionStore correspondingMoaSession = oldSSOSession.getMoasession(); +		 +		if (correspondingMoaSession == null) { +			Logger.info("Get request with old SSO SessionID but no corresponding SSO Session is found."); +			return null; +		} +		 +		String moasessionid = correspondingMoaSession.getSessionid(); +		 +		session.getTransaction().commit(); +		 +		return moasessionid; +		  	}  	public String createSSOSessionInformations(String moaSessionID, String OAUrl) {  		String newSSOId = Random.nextRandom(); -			 +		  		System.out.println("generate new SSO Tokken (" + newSSOId + ")");  		if (MiscUtil.isEmpty(moaSessionID) || MiscUtil.isEmpty(OAUrl)) { @@ -123,32 +137,30 @@ public class SSOManager {  	} -	  	public void setSSOSessionID(HttpServletRequest httpReq, HttpServletResponse httpResp, String ssoId) {  		Cookie[] cookies = httpReq.getCookies();  		if (cookies != null) { -			deleteSSOSessionID(httpReq, httpResp);	 +			deleteSSOSessionID(httpReq, httpResp);  		}  		Cookie cookie = new Cookie(SSOCOOKIE, ssoId);  		cookie.setMaxAge(sso_timeout);  		cookie.setSecure(true); -		cookie.setPath(httpReq.getContextPath());		 -		httpResp.addCookie(cookie);		 +		cookie.setPath(httpReq.getContextPath()); +		httpResp.addCookie(cookie);  	} -		 -	  	public String getSSOSessionID(HttpServletRequest httpReq) { -	Cookie[] cookies = httpReq.getCookies(); +		Cookie[] cookies = httpReq.getCookies();  		if (cookies != null) {  			for (Cookie cookie : cookies) { -				//funktioniert nicht, da Cookie seltsamerweise immer unsecure übertragen wird (firefox)  -				//if (cookie.getName().equals(SSOCOOKIE) && cookie.getSecure()) { -								 +				// funktioniert nicht, da Cookie seltsamerweise immer unsecure übertragen wird +				// (firefox) +				// if (cookie.getName().equals(SSOCOOKIE) && cookie.getSecure()) { +				  				if (cookie.getName().equals(SSOCOOKIE)) {  					return cookie.getValue();  				} @@ -158,14 +170,12 @@ public class SSOManager {  	}  	public void deleteSSOSessionID(HttpServletRequest httpReq, HttpServletResponse httpResp) { -		Cookie[] cookies = httpReq.getCookies();		 -				 +		Cookie[] cookies = httpReq.getCookies(); +		  		if (cookies != null) {  			for (Cookie cookie : cookies) { -				if (!cookie.getName().equals(SSOCOOKIE))	 -					httpResp.addCookie(cookie); +				if (!cookie.getName().equals(SSOCOOKIE)) httpResp.addCookie(cookie);  			}  		}  	}  } - diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Constants.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Constants.java index 8189aa01b..9466c9faf 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Constants.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Constants.java @@ -1,9 +1,9 @@  package at.gv.egovernment.moa.id.protocols.oauth20; -public class OAuth20Constants { +public final class OAuth20Constants {  	private OAuth20Constants() { -		 +		throw new InstantiationError();  	}  	// error parameters and error codes diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20SessionObject.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20SessionObject.java index 91c099d2c..20711373e 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20SessionObject.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20SessionObject.java @@ -2,6 +2,8 @@ package at.gv.egovernment.moa.id.protocols.oauth20;  import java.io.Serializable; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; +  public class OAuth20SessionObject implements Serializable {  	/** @@ -13,6 +15,8 @@ public class OAuth20SessionObject implements Serializable {  	private String code; +	private AuthenticationSession authDataSession; +	  	public String getScope() {  		return scope;  	} @@ -36,4 +40,12 @@ public class OAuth20SessionObject implements Serializable {  		this.code = code;  	} +	public AuthenticationSession getAuthDataSession() { +		return authDataSession; +	} +	 +	public void setAuthDataSession(AuthenticationSession authDataSession) { +		this.authDataSession = authDataSession; +	} +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Util.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Util.java index 4d3030a0f..11b798d00 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Util.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/oauth20/OAuth20Util.java @@ -1,33 +1,23 @@  package at.gv.egovernment.moa.id.protocols.oauth20;  import java.io.UnsupportedEncodingException; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import java.security.interfaces.RSAPrivateKey;  import java.util.Map;  import java.util.regex.Matcher;  import java.util.regex.Pattern; -import net.oauth.jsontoken.crypto.RsaSHA256Signer; -import net.oauth.jsontoken.crypto.Signer; - -import org.opensaml.xml.security.x509.BasicX509Credential; - -import at.gv.egovernment.moa.id.commons.db.dao.config.OAOAUTH20; -import at.gv.egovernment.moa.id.protocols.oauth20.exceptions.OAuth20CertificateErrorException; -import at.gv.egovernment.moa.id.protocols.oauth20.exceptions.OAuth20Exception; -import at.gv.egovernment.moa.logging.Logger; -import at.gv.egovernment.moa.util.KeyStoreUtils; -import at.gv.egovernment.moa.util.StringUtils; +import org.apache.commons.lang.StringUtils;  import com.google.gson.JsonObject; -public class OAuth20Util { +public final class OAuth20Util {  	public static final String REGEX_HTTPS = "^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";  	public static final String REGEX_FILE = "^(file):/.[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"; +	private OAuth20Util() { +		throw new InstantiationError(); +	} +	  	/**  	 * Simple helper function to add parameter to a url  	 *  @@ -59,9 +49,16 @@ public class OAuth20Util {  		return matcher.find();  	} +	public static boolean isValidStateValue(String state) { +		Pattern urlPattern = Pattern.compile("javascript|<|>|&|;", Pattern.CASE_INSENSITIVE); +		Matcher matcher = urlPattern.matcher(state); +		return !matcher.find(); +	} +	  	public static void addProperytiesToJsonObject(JsonObject jsonObject, Map<String, Object> params) {  		for (Map.Entry<String, Object> param : params.entrySet()) { -			if (param.getKey() != null && !"".equals(param.getKey()) && param.getValue() != null && !"".equals(param.getValue())) { +			 +			if (!StringUtils.isEmpty(param.getKey()) && param.getValue() != null) {  				// check for integer  				try { @@ -89,46 +86,4 @@ public class OAuth20Util {  		}  	} -	public static Signer loadSigner(String issuer) throws OAuth20Exception { -		OAuth20Configuration globalConfig = OAuth20Configuration.getInstance(); -		 -		if (StringUtils.isEmpty(globalConfig.getJWTKeyStore())) { -			throw new OAuth20CertificateErrorException("keystore"); -		} -		 -		if (StringUtils.isEmpty(globalConfig.getJWTKeyName())) { -			throw new OAuth20CertificateErrorException("key name"); -		} -		 -		try { -			KeyStore ks = KeyStoreUtils.loadKeyStore(globalConfig.getJWTKeyStore(), globalConfig.getJWTKeyStorePassword()); -			 -			X509Certificate certificate = (X509Certificate) ks.getCertificate(globalConfig.getJWTKeyName()); -			 -			PrivateKey privateKey = (PrivateKey) ks.getKey(globalConfig.getJWTKeyName(), globalConfig.getJWTKeyPassword() -					.toCharArray()); -			BasicX509Credential credential = new BasicX509Credential(); -			credential.setEntityCertificate(certificate); -			credential.setPrivateKey(privateKey); -			 -			//Logger.debug("Going to use X509Certificate:"); -			Logger.debug(certificate); -			//Logger.debug("Going to use private key:"); -			Logger.debug(privateKey); -			 -			return new RsaSHA256Signer(issuer, globalConfig.getJWTKeyName(), (RSAPrivateKey) credential.getPrivateKey()); -			 -		} -		catch (Exception e) { -			throw new OAuth20CertificateErrorException("keystore"); -		} -		 -	} -	 -	public static boolean isValidStateValue(String state) { -		Pattern urlPattern = Pattern.compile("javascript|<|>|&|;", Pattern.CASE_INSENSITIVE); -		Matcher matcher = urlPattern.matcher(state); -		return !matcher.find(); -	} -	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/PVPAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/PVPAttributeBuilder.java index 9403cb205..054f87e18 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/PVPAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/PVPAttributeBuilder.java @@ -23,6 +23,7 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.EIDSourcePIN;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.EIDSourcePINType;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.GivenNameAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.IAttributeBuilder; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.IAttributeGenerator;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.MandateFullMandateAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.MandateLegalPersonFullNameAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.MandateLegalPersonSourcePinAttributeBuilder; @@ -39,16 +40,26 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.MandateRefere  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.MandateTypeAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.PVPVersionAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.PrincipalNameAttributeBuilder; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.SamlAttributeGenerator; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.InvalidDateFormatAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.InvalidDateFormatException; +import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException;  import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException;  public class PVPAttributeBuilder { - +	 +	private static IAttributeGenerator<Attribute> generator = new SamlAttributeGenerator(); +	  	private static HashMap<String, IAttributeBuilder> builders; - +	  	private static void addBuilder(IAttributeBuilder builder) {  		builders.put(builder.getName(), builder);  	} - +	  	static {  		builders = new HashMap<String, IAttributeBuilder>();  		// Citizen Token normal @@ -84,27 +95,39 @@ public class PVPAttributeBuilder {  		addBuilder(new MandateReferenceValueAttributeBuilder());  		addBuilder(new MandateFullMandateAttributeBuilder());  	} - -	public static Attribute buildAttribute(String name, -			AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { +	 +	public static Attribute buildAttribute(String name, AuthenticationSession authSession, OAAuthParameter oaParam, +			AuthenticationData authData) throws PVP2Exception {  		if (builders.containsKey(name)) { -			return builders.get(name).build(authSession, oaParam, authData); +			try { +				return builders.get(name).build(authSession, oaParam, authData, generator); +			} +			catch (AttributeException e) { +				if (e instanceof UnavailableAttributeException) { +					throw new UnprovideableAttributeException(((UnavailableAttributeException) e).getAttributeName()); +				} else if (e instanceof InvalidDateFormatAttributeException) { +					throw new InvalidDateFormatException(); +				} else if (e instanceof NoMandateDataAttributeException) { +					throw new NoMandateDataAvailableException(); +				} else { +					throw new UnprovideableAttributeException(name); +				} +			}  		}  		return null;  	} - +	  	public static List<Attribute> buildSupportedEmptyAttributes() {  		List<Attribute> attributes = new ArrayList<Attribute>();  		Iterator<IAttributeBuilder> builderIt = builders.values().iterator();  		while (builderIt.hasNext()) {  			IAttributeBuilder builder = builderIt.next(); -			Attribute emptyAttribute = builder.buildEmpty(); +			Attribute emptyAttribute = builder.buildEmpty(generator);  			if (emptyAttribute != null) {  				attributes.add(emptyAttribute);  			}  		}  		return attributes;  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/assertion/PVP2AssertionBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/assertion/PVP2AssertionBuilder.java index f21567245..5e8206739 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/assertion/PVP2AssertionBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/assertion/PVP2AssertionBuilder.java @@ -21,7 +21,6 @@ import org.opensaml.saml2.core.RequestedAuthnContext;  import org.opensaml.saml2.core.Subject;  import org.opensaml.saml2.core.SubjectConfirmation;  import org.opensaml.saml2.core.SubjectConfirmationData; -import org.opensaml.saml2.metadata.AssertionConsumerService;  import org.opensaml.saml2.metadata.AttributeConsumingService;  import org.opensaml.saml2.metadata.EntityDescriptor;  import org.opensaml.saml2.metadata.NameIDFormat; @@ -43,7 +42,6 @@ import at.gv.egovernment.moa.id.data.AuthenticationData;  import at.gv.egovernment.moa.id.protocols.pvp2x.PVPConstants;  import at.gv.egovernment.moa.id.protocols.pvp2x.builder.PVPAttributeBuilder;  import at.gv.egovernment.moa.id.protocols.pvp2x.config.PVPConfiguration; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.InvalidAssertionConsumerServiceException;  import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NameIDFormatNotSupportedException;  import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoAuthContextException;  import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; @@ -295,16 +293,7 @@ public class PVP2AssertionBuilder implements PVPConstants {  				.createSAMLObject(SubjectConfirmationData.class);  		subjectConfirmationData.setInResponseTo(authnRequest.getID());  		subjectConfirmationData.setNotOnOrAfter(new DateTime().plusMinutes(20)); -		 -		//TL: change from entityID to destination URL  -		AssertionConsumerService consumerService = spSSODescriptor -				.getAssertionConsumerServices().get(idx); - -		if (consumerService == null) { -			throw new InvalidAssertionConsumerServiceException(idx); -		} -		 -		subjectConfirmationData.setRecipient(consumerService.getLocation()); +		subjectConfirmationData.setRecipient(peerEntity.getEntityID());  		subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData); @@ -314,7 +303,7 @@ public class PVP2AssertionBuilder implements PVPConstants {  		AudienceRestriction audienceRestriction = SAML2Utils  				.createSAMLObject(AudienceRestriction.class);  		Audience audience = SAML2Utils.createSAMLObject(Audience.class); -		 +  		audience.setAudienceURI(peerEntity.getEntityID());  		audienceRestriction.getAudiences().add(audience);  		conditions.setNotBefore(new DateTime()); @@ -327,12 +316,8 @@ public class PVP2AssertionBuilder implements PVPConstants {  		assertion.setConditions(conditions);  		Issuer issuer = SAML2Utils.createSAMLObject(Issuer.class); -		 -		//TODO: check! -		//change to entity value from entity name to IDP EntityID (URL) -		issuer.setValue(PVPConfiguration.getInstance().getIDPPublicPath()); +		issuer.setValue(PVPConfiguration.getInstance().getIDPIssuerName());  		issuer.setFormat(NameID.ENTITY); -		  		assertion.setIssuer(issuer);  		assertion.setSubject(subject);  		assertion.setID(SAML2Utils.getSecureIdentifier()); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BPKAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BPKAttributeBuilder.java index bb568cd90..f5f84a322 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BPKAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BPKAttributeBuilder.java @@ -1,41 +1,38 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;  import at.gv.egovernment.moa.logging.Logger;  import at.gv.egovernment.moa.util.Constants; -public class BPKAttributeBuilder extends BaseAttributeBuilder { - +public class BPKAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return BPK_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		String bpk = authData.getBPK();  		String type = authData.getBPKType();  		if (type.startsWith(Constants.URN_PREFIX_WBPK)) -			type = type.substring((Constants.URN_PREFIX_WBPK+"+").length()); -		else if (type.startsWith(Constants.URN_PREFIX_CDID)) -			type = type.substring((Constants.URN_PREFIX_CDID+"+").length()); -				 -		if(bpk.length() > BPK_MAX_LENGTH) { +			type = type.substring((Constants.URN_PREFIX_WBPK + "+").length()); +		else if (type.startsWith(Constants.URN_PREFIX_CDID)) type = type.substring((Constants.URN_PREFIX_CDID + "+").length()); +		 +		if (bpk.length() > BPK_MAX_LENGTH) {  			bpk = bpk.substring(0, BPK_MAX_LENGTH);  		}  		Logger.trace("Authenticate user with bPK/wbPK " + bpk + " and Type=" + type); -		return buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, type + ":" + bpk); +		return g.buildStringAttribute(BPK_FRIENDLY_NAME, BPK_NAME, type + ":" + bpk);  	} -	 -	public Attribute buildEmpty() { -		return buildemptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(BPK_FRIENDLY_NAME, BPK_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BirthdateAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BirthdateAttributeBuilder.java index fa42fc54f..ef594b91c 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BirthdateAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/BirthdateAttributeBuilder.java @@ -5,41 +5,39 @@ import java.text.ParseException;  import java.text.SimpleDateFormat;  import java.util.Date; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class BirthdateAttributeBuilder extends BaseAttributeBuilder { - +public class BirthdateAttributeBuilder implements IPVPAttributeBuilder { +	  	public static final String IDENTITY_LINK_DATE_FORMAT = "yyyy-MM-dd"; - +	  	public String getName() {  		return BIRTHDATE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		try { -			DateFormat identityLinkFormat = new SimpleDateFormat( -					IDENTITY_LINK_DATE_FORMAT); -			Date date = identityLinkFormat.parse(authSession.getIdentityLink() -					.getDateOfBirth()); -			DateFormat pvpDateFormat = new SimpleDateFormat( -					BIRTHDATE_FORMAT_PATTERN); +			DateFormat identityLinkFormat = new SimpleDateFormat(IDENTITY_LINK_DATE_FORMAT); +			Date date = identityLinkFormat.parse(authSession.getIdentityLink().getDateOfBirth()); +			DateFormat pvpDateFormat = new SimpleDateFormat(BIRTHDATE_FORMAT_PATTERN);  			String dateString = pvpDateFormat.format(date); -			return buildStringAttribute(BIRTHDATE_FRIENDLY_NAME, -					BIRTHDATE_NAME, dateString); -		} catch (ParseException e) { +			 +			return g.buildStringAttribute(BIRTHDATE_FRIENDLY_NAME, BIRTHDATE_NAME, dateString); +			 +			//return buildStringAttribute(BIRTHDATE_FRIENDLY_NAME, BIRTHDATE_NAME, dateString); +		} +		catch (ParseException e) {  			e.printStackTrace();  			return null;  		}  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(BIRTHDATE_FRIENDLY_NAME, -				BIRTHDATE_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(BIRTHDATE_FRIENDLY_NAME, BIRTHDATE_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDAuthBlock.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDAuthBlock.java index 16d05842a..d2532fc28 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDAuthBlock.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDAuthBlock.java @@ -4,42 +4,40 @@ import iaik.util.logging.Log;  import java.io.IOException; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException;  import at.gv.egovernment.moa.util.Base64Utils;  import at.gv.egovernment.moa.util.MiscUtil; -public class EIDAuthBlock extends BaseAttributeBuilder { - +public class EIDAuthBlock implements IPVPAttributeBuilder { +	  	public String getName() {  		return EID_AUTH_BLOCK_NAME;  	} - -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		try {  			String authblock = authSession.getAuthBlock();  			if (MiscUtil.isNotEmpty(authblock)) { -				return buildStringAttribute(EID_AUTH_BLOCK_FRIENDLY_NAME, -						EID_AUTH_BLOCK_NAME, Base64Utils.encode(authblock.getBytes()));	 +				return g.buildStringAttribute(EID_AUTH_BLOCK_FRIENDLY_NAME, EID_AUTH_BLOCK_NAME, +						Base64Utils.encode(authblock.getBytes()));  			} -		} catch (IOException e) { +		} +		catch (IOException e) {  			Log.info("Encode AuthBlock BASE64 failed.");  		} -		throw new UnprovideableAttributeException(EID_AUTH_BLOCK_NAME); -			 +		throw new UnavailableAttributeException(EID_AUTH_BLOCK_NAME); +		  	} - -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_AUTH_BLOCK_FRIENDLY_NAME, EID_AUTH_BLOCK_NAME); +	 +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_AUTH_BLOCK_FRIENDLY_NAME, EID_AUTH_BLOCK_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCcsURL.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCcsURL.java index 0d96d4817..470dc11fa 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCcsURL.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCcsURL.java @@ -1,33 +1,30 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException;  import at.gv.egovernment.moa.util.MiscUtil; -public class EIDCcsURL extends BaseAttributeBuilder{ +public class EIDCcsURL implements IPVPAttributeBuilder {  	public String getName() {  		return EID_CCS_URL_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		String bkuurl = authSession.getBkuURL();  		if (MiscUtil.isNotEmpty(bkuurl)) -			return buildStringAttribute(EID_CCS_URL_FRIENDLY_NAME, EID_CCS_URL_NAME, bkuurl); +			return g.buildStringAttribute(EID_CCS_URL_FRIENDLY_NAME, EID_CCS_URL_NAME, bkuurl);  		else -			throw new UnprovideableAttributeException(EID_CCS_URL_NAME); +			throw new UnavailableAttributeException(EID_CCS_URL_NAME);  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_CCS_URL_FRIENDLY_NAME, EID_CCS_URL_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_CCS_URL_FRIENDLY_NAME, EID_CCS_URL_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCitizenQAALevelAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCitizenQAALevelAttributeBuilder.java index 5ddd87c7b..770609e7a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCitizenQAALevelAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDCitizenQAALevelAttributeBuilder.java @@ -1,26 +1,25 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class EIDCitizenQAALevelAttributeBuilder extends BaseAttributeBuilder { +public class EIDCitizenQAALevelAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return EID_CITIZEN_QAA_LEVEL_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { -		return buildIntegerAttribute(EID_CITIZEN_QAA_LEVEL_FRIENDLY_NAME,  +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		return g.buildIntegerAttribute(EID_CITIZEN_QAA_LEVEL_FRIENDLY_NAME,   				EID_CITIZEN_QAA_LEVEL_NAME, 4);  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_CITIZEN_QAA_LEVEL_FRIENDLY_NAME,  +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_CITIZEN_QAA_LEVEL_FRIENDLY_NAME,   				EID_CITIZEN_QAA_LEVEL_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIdentityLinkBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIdentityLinkBuilder.java index d8be65f53..ea1ed0470 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIdentityLinkBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIdentityLinkBuilder.java @@ -4,28 +4,26 @@ import java.io.IOException;  import javax.xml.transform.TransformerException; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.auth.exception.MOAIDException;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;  import at.gv.egovernment.moa.id.util.IdentityLinkReSigner;  import at.gv.egovernment.moa.logging.Logger;  import at.gv.egovernment.moa.util.Base64Utils;  import at.gv.egovernment.moa.util.DOMUtils; -public class EIDIdentityLinkBuilder extends BaseAttributeBuilder { +public class EIDIdentityLinkBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return EID_IDENTITY_LINK_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		try {  			String ilAssertion = null;  			if (oaParam.getBusinessService()) { @@ -43,27 +41,27 @@ public class EIDIdentityLinkBuilder extends BaseAttributeBuilder {  				ilAssertion = authData.getIdentityLink().getSerializedSamlAssertion(); -			return buildStringAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME, +			return g.buildStringAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME,  					EID_IDENTITY_LINK_NAME, Base64Utils.encode(ilAssertion.getBytes()));  		} catch (MOAIDException e) {  			Logger.warn("IdentityLink serialization error.", e); -			return buildemptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME, +			return g.buildEmptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME,  					EID_IDENTITY_LINK_NAME);  		} catch (TransformerException e) {  			Logger.warn("IdentityLink serialization error.", e); -			return buildemptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME, +			return g.buildEmptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME,  					EID_IDENTITY_LINK_NAME);  		} catch (IOException e) {  			Logger.warn("IdentityLink serialization error.", e); -			return buildemptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME, +			return g.buildEmptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME,  					EID_IDENTITY_LINK_NAME);  		}  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME, +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_IDENTITY_LINK_FRIENDLY_NAME,  				EID_IDENTITY_LINK_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIssuingNationAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIssuingNationAttributeBuilder.java index 08e4e67b3..7d6173ee2 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIssuingNationAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDIssuingNationAttributeBuilder.java @@ -5,21 +5,20 @@ import iaik.x509.X509Certificate;  import javax.naming.ldap.LdapName;  import javax.naming.ldap.Rdn; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;  import at.gv.egovernment.moa.logging.Logger; -public class EIDIssuingNationAttributeBuilder extends BaseAttributeBuilder { +public class EIDIssuingNationAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return EID_ISSUING_NATION_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		String countryCode = "AT"; @@ -48,12 +47,12 @@ public class EIDIssuingNationAttributeBuilder extends BaseAttributeBuilder {  			}  		} -		return buildStringAttribute(EID_ISSUING_NATION_FRIENDLY_NAME, +		return g.buildStringAttribute(EID_ISSUING_NATION_FRIENDLY_NAME,  				EID_ISSUING_NATION_NAME, countryCode);  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_ISSUING_NATION_FRIENDLY_NAME, +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_ISSUING_NATION_FRIENDLY_NAME,  				EID_ISSUING_NATION_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSectorForIDAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSectorForIDAttributeBuilder.java index 8cb2b5be6..43e052644 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSectorForIDAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSectorForIDAttributeBuilder.java @@ -1,26 +1,25 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class EIDSectorForIDAttributeBuilder extends BaseAttributeBuilder { +public class EIDSectorForIDAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return EID_SECTOR_FOR_IDENTIFIER_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) {		 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		String bpktype = authData.getBPKType(); -		return buildStringAttribute(EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME, +		return g.buildStringAttribute(EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME,  				EID_SECTOR_FOR_IDENTIFIER_NAME, bpktype);  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME, +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME,  				EID_SECTOR_FOR_IDENTIFIER_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSignerCertificate.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSignerCertificate.java index f5cb51228..93ddd3506 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSignerCertificate.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSignerCertificate.java @@ -4,29 +4,26 @@ import iaik.util.logging.Log;  import java.io.IOException; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException;  import at.gv.egovernment.moa.util.Base64Utils; -public class EIDSignerCertificate extends BaseAttributeBuilder { +public class EIDSignerCertificate implements IPVPAttributeBuilder {  	public String getName() {  		return EID_SIGNER_CERTIFICATE_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		try {  			byte[] signerCertificate = authSession.getEncodedSignerCertificate();  			if (signerCertificate != null) { -				return buildStringAttribute(EID_SIGNER_CERTIFICATE_FRIENDLY_NAME, EID_SIGNER_CERTIFICATE_NAME, Base64Utils +				return g.buildStringAttribute(EID_SIGNER_CERTIFICATE_FRIENDLY_NAME, EID_SIGNER_CERTIFICATE_NAME, Base64Utils  						.encode(signerCertificate));  			} @@ -34,12 +31,12 @@ public class EIDSignerCertificate extends BaseAttributeBuilder {  			Log.info("Signer certificate BASE64 encoding error");  		} -		throw new UnprovideableAttributeException(EID_SIGNER_CERTIFICATE_NAME); +		throw new UnavailableAttributeException(EID_SIGNER_CERTIFICATE_NAME);  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_SIGNER_CERTIFICATE_FRIENDLY_NAME, EID_SIGNER_CERTIFICATE_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_SIGNER_CERTIFICATE_FRIENDLY_NAME, EID_SIGNER_CERTIFICATE_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePIN.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePIN.java index d21d264f6..a8ec0bfb4 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePIN.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePIN.java @@ -1,33 +1,30 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException; -public class EIDSourcePIN extends BaseAttributeBuilder { +public class EIDSourcePIN implements IPVPAttributeBuilder  {  	public String getName() {  		return EID_SOURCE_PIN_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if (oaParam.getBusinessService()) -			throw new UnprovideableAttributeException(EID_SOURCE_PIN_NAME); +			throw new UnavailableAttributeException(EID_SOURCE_PIN_NAME);  		else { -			return buildStringAttribute(EID_SOURCE_PIN_FRIENDLY_NAME, EID_SOURCE_PIN_NAME, authData.getIdentificationValue()); +			return g.buildStringAttribute(EID_SOURCE_PIN_FRIENDLY_NAME, EID_SOURCE_PIN_NAME, authData.getIdentificationValue());  		}  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_SOURCE_PIN_FRIENDLY_NAME, EID_SOURCE_PIN_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_SOURCE_PIN_FRIENDLY_NAME, EID_SOURCE_PIN_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePINType.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePINType.java index 9bc9716cf..858a53bed 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePINType.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/EIDSourcePINType.java @@ -1,33 +1,30 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.UnprovideableAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException; -public class EIDSourcePINType extends BaseAttributeBuilder { +public class EIDSourcePINType implements IPVPAttributeBuilder {  	public String getName() {  		return EID_SOURCE_PIN_TYPE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if (oaParam.getBusinessService()) -			throw new UnprovideableAttributeException(EID_SOURCE_PIN_TYPE_NAME); +			throw new UnavailableAttributeException(EID_SOURCE_PIN_TYPE_NAME);  		else { -			return buildStringAttribute(EID_SOURCE_PIN_TYPE_FRIENDLY_NAME, EID_SOURCE_PIN_TYPE_NAME, authData.getIdentificationType()); +			return g.buildStringAttribute(EID_SOURCE_PIN_TYPE_FRIENDLY_NAME, EID_SOURCE_PIN_TYPE_NAME, authData.getIdentificationType());  		}  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(EID_SOURCE_PIN_TYPE_FRIENDLY_NAME, EID_SOURCE_PIN_TYPE_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(EID_SOURCE_PIN_TYPE_FRIENDLY_NAME, EID_SOURCE_PIN_TYPE_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/GivenNameAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/GivenNameAttributeBuilder.java index 5c8151c01..648ea6d25 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/GivenNameAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/GivenNameAttributeBuilder.java @@ -1,24 +1,23 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class GivenNameAttributeBuilder extends BaseAttributeBuilder { +public class GivenNameAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return GIVEN_NAME_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { -		return buildStringAttribute(GIVEN_NAME_FRIENDLY_NAME, GIVEN_NAME_NAME, authSession.getIdentityLink().getGivenName()); +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		return g.buildStringAttribute(GIVEN_NAME_FRIENDLY_NAME, GIVEN_NAME_NAME, authSession.getIdentityLink().getGivenName());  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(GIVEN_NAME_FRIENDLY_NAME, GIVEN_NAME_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(GIVEN_NAME_FRIENDLY_NAME, GIVEN_NAME_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/IAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/IAttributeBuilder.java index 173fbd52f..29f612961 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/IAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/IAttributeBuilder.java @@ -1,15 +1,15 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;  public interface IAttributeBuilder {  	public String getName(); -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception; -	public Attribute buildEmpty(); +	 +	public <ATT> ATT build(final AuthenticationSession authSession, final OAAuthParameter oaParam, final AuthenticationData authData, +			final IAttributeGenerator<ATT> g) throws AttributeException; +	 +	public <ATT> ATT buildEmpty(final IAttributeGenerator<ATT> g);  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateFullMandateAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateFullMandateAttributeBuilder.java index 0afd71bc1..7d5f1d998 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateFullMandateAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateFullMandateAttributeBuilder.java @@ -4,32 +4,29 @@ import java.io.IOException;  import javax.xml.transform.TransformerException; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;  import at.gv.egovernment.moa.logging.Logger;  import at.gv.egovernment.moa.util.Base64Utils;  import at.gv.egovernment.moa.util.DOMUtils; -public class MandateFullMandateAttributeBuilder extends BaseAttributeBuilder { +public class MandateFullMandateAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return MANDATE_FULL_MANDATE_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if (authSession.getUseMandate()) {  			if (authSession.getMandate() != null) {  				String fullMandate;  				try {  					fullMandate = DOMUtils.serializeNode(authSession  							.getMandate()); -					return buildStringAttribute(MANDATE_FULL_MANDATE_FRIENDLY_NAME, +					return g.buildStringAttribute(MANDATE_FULL_MANDATE_FRIENDLY_NAME,  							MANDATE_FULL_MANDATE_NAME, Base64Utils.encode(fullMandate.getBytes()));  				} catch (TransformerException e) {  					Logger.error("Failed to generate Full Mandate", e); @@ -42,8 +39,8 @@ public class MandateFullMandateAttributeBuilder extends BaseAttributeBuilder {  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_FULL_MANDATE_FRIENDLY_NAME, +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_FULL_MANDATE_FRIENDLY_NAME,  				MANDATE_FULL_MANDATE_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonFullNameAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonFullNameAttributeBuilder.java index 15059c036..c49f72315 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonFullNameAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonFullNameAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -8,44 +7,43 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.CorporateBod  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateLegalPersonFullNameAttributeBuilder extends BaseAttributeBuilder { - +public class MandateLegalPersonFullNameAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_LEG_PER_FULL_NAME_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate); -			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +			if (mandateObject == null) { +				throw new NoMandateDataAttributeException();  			}  			CorporateBodyType corporation = mandateObject.getMandator().getCorporateBody(); -			if(corporation == null) { +			if (corporation == null) {  				Logger.error("No corporation mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			return buildStringAttribute(MANDATE_LEG_PER_FULL_NAME_FRIENDLY_NAME,  -					MANDATE_LEG_PER_FULL_NAME_NAME, corporation.getFullName()); +			return g.buildStringAttribute(MANDATE_LEG_PER_FULL_NAME_FRIENDLY_NAME, MANDATE_LEG_PER_FULL_NAME_NAME, +					corporation.getFullName());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_LEG_PER_FULL_NAME_FRIENDLY_NAME,  -				MANDATE_LEG_PER_FULL_NAME_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_LEG_PER_FULL_NAME_FRIENDLY_NAME, MANDATE_LEG_PER_FULL_NAME_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinAttributeBuilder.java index 820efb209..9b1ed0520 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -9,37 +8,37 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.Identificati  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateLegalPersonSourcePinAttributeBuilder extends BaseAttributeBuilder { +public class MandateLegalPersonSourcePinAttributeBuilder  implements IPVPAttributeBuilder  {  	public String getName() {  		return MANDATE_LEG_PER_SOURCE_PIN_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if(authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			CorporateBodyType corporation = mandateObject.getMandator().getCorporateBody();  			if(corporation == null) {  				Logger.error("No corporation mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			IdentificationType id = null;  			if(corporation.getIdentification().size() == 0) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			id =  corporation.getIdentification().get(0);  			/*if(authSession.getBusinessService()) { @@ -49,16 +48,16 @@ public class MandateLegalPersonSourcePinAttributeBuilder extends BaseAttributeBu  			}*/  			/*if(id == null) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}*/ -			return buildStringAttribute(MANDATE_LEG_PER_SOURCE_PIN_FRIENDLY_NAME,  +			return g.buildStringAttribute(MANDATE_LEG_PER_SOURCE_PIN_FRIENDLY_NAME,   					MANDATE_LEG_PER_SOURCE_PIN_NAME, id.getValue().getValue());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_LEG_PER_SOURCE_PIN_FRIENDLY_NAME, MANDATE_LEG_PER_SOURCE_PIN_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_LEG_PER_SOURCE_PIN_FRIENDLY_NAME, MANDATE_LEG_PER_SOURCE_PIN_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinTypeAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinTypeAttributeBuilder.java index 44b58d04f..d40cb2f99 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinTypeAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateLegalPersonSourcePinTypeAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -9,59 +8,53 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.Identificati  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateLegalPersonSourcePinTypeAttributeBuilder extends -		BaseAttributeBuilder { - +public class MandateLegalPersonSourcePinTypeAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if (mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if (mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			CorporateBodyType corporation = mandateObject.getMandator() -					.getCorporateBody(); +			CorporateBodyType corporation = mandateObject.getMandator().getCorporateBody();  			if (corporation == null) {  				Logger.error("No corporate mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			IdentificationType id = null; -			if(corporation.getIdentification().size() == 0) { +			if (corporation.getIdentification().size() == 0) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			id =  corporation.getIdentification().get(0); -			/*id = MandateBuilder.getBPKIdentification(corporate); -			if (id == null) { -				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); -			}*/ -			return buildStringAttribute( -					MANDATE_LEG_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME, -					MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME, id.getType()); +			id = corporation.getIdentification().get(0); +			/* +			 * id = MandateBuilder.getBPKIdentification(corporate); if (id == null) { +			 * Logger.error("Failed to generate IdentificationType"); throw new +			 * NoMandateDataAttributeException(); } +			 */ +			return g.buildStringAttribute(MANDATE_LEG_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME, MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME, +					id.getType());  		}  		return null; - +		  	} - -	public Attribute buildEmpty() { -		return buildemptyAttribute( -				MANDATE_LEG_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME, -				MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME); +	 +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_LEG_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME, MANDATE_LEG_PER_SOURCE_PIN_TYPE_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBPKAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBPKAttributeBuilder.java index dc4e9dd49..b6c7389e0 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBPKAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBPKAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -11,52 +10,51 @@ import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.auth.exception.BuildException;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger;  import at.gv.egovernment.moa.util.Constants; -public class MandateNaturalPersonBPKAttributeBuilder extends BaseAttributeBuilder { - +public class MandateNaturalPersonBPKAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_NAT_PER_BPK_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate); -			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +			if (mandateObject == null) { +				throw new NoMandateDataAttributeException();  			} -			PhysicalPersonType physicalPerson = mandateObject.getMandator() -					.getPhysicalPerson(); +			PhysicalPersonType physicalPerson = mandateObject.getMandator().getPhysicalPerson();  			if (physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			IdentificationType id = null;  			id = physicalPerson.getIdentification().get(0); -//			if(authSession.getBusinessService()) { -//				id = MandateBuilder.getWBPKIdentification(physicalPerson); -//			} else { -//				id = MandateBuilder.getBPKIdentification(physicalPerson); -//			} -			if(id == null) { +			// if(authSession.getBusinessService()) { +			// id = MandateBuilder.getWBPKIdentification(physicalPerson); +			// } else { +			// id = MandateBuilder.getBPKIdentification(physicalPerson); +			// } +			if (id == null) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			String bpk;  			try { -			 +				  				if (id.getType().equals(Constants.URN_PREFIX_BASEID)) { -					if (authSession.getBusinessService()) {						     +					if (authSession.getBusinessService()) {  						bpk = new BPKBuilder().buildWBPK(id.getValue().getValue(), oaParam.getIdentityLinkDomainIdentifier());  					} @@ -65,26 +63,24 @@ public class MandateNaturalPersonBPKAttributeBuilder extends BaseAttributeBuilde  						bpk = new BPKBuilder().buildBPK(id.getValue().getValue(), oaParam.getTarget());  					} -								 -				} else  +					 +				} else  					bpk = id.getValue().getValue(); -			} catch (BuildException e ){ +			} +			catch (BuildException e) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -		 -			return buildStringAttribute(MANDATE_NAT_PER_BPK_FRIENDLY_NAME,  -					MANDATE_NAT_PER_BPK_NAME, bpk); +			 +			return g.buildStringAttribute(MANDATE_NAT_PER_BPK_FRIENDLY_NAME, MANDATE_NAT_PER_BPK_NAME, bpk);  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_BPK_FRIENDLY_NAME,  -				MANDATE_NAT_PER_BPK_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_BPK_FRIENDLY_NAME, MANDATE_NAT_PER_BPK_NAME);  	} - - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBirthDateAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBirthDateAttributeBuilder.java index a87d4d25c..bc719afeb 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBirthDateAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonBirthDateAttributeBuilder.java @@ -5,7 +5,6 @@ import java.text.ParseException;  import java.text.SimpleDateFormat;  import java.util.Date; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -13,62 +12,55 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPers  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.InvalidDateFormatException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.InvalidDateFormatAttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateNaturalPersonBirthDateAttributeBuilder extends -		BaseAttributeBuilder { - +public class MandateNaturalPersonBirthDateAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_NAT_PER_BIRTHDATE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if (mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if (mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			PhysicalPersonType physicalPerson = mandateObject.getMandator() -					.getPhysicalPerson(); +			PhysicalPersonType physicalPerson = mandateObject.getMandator().getPhysicalPerson();  			if (physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} - +			  			String dateOfBirth = physicalPerson.getDateOfBirth();  			try { -				DateFormat mandateFormat = new SimpleDateFormat( -						MandateBuilder.MANDATE_DATE_OF_BIRTH_FORMAT); +				DateFormat mandateFormat = new SimpleDateFormat(MandateBuilder.MANDATE_DATE_OF_BIRTH_FORMAT);  				Date date = mandateFormat.parse(dateOfBirth); -				DateFormat pvpDateFormat = new SimpleDateFormat( -						MANDATE_NAT_PER_BIRTHDATE_FORMAT_PATTERN); +				DateFormat pvpDateFormat = new SimpleDateFormat(MANDATE_NAT_PER_BIRTHDATE_FORMAT_PATTERN);  				String dateString = pvpDateFormat.format(date); - -				return buildStringAttribute( -						MANDATE_NAT_PER_BIRTHDATE_FRIENDLY_NAME, -						MANDATE_NAT_PER_BIRTHDATE_NAME, dateString); -			} catch (ParseException e) { +				 +				return g.buildStringAttribute(MANDATE_NAT_PER_BIRTHDATE_FRIENDLY_NAME, MANDATE_NAT_PER_BIRTHDATE_NAME, dateString); +			} +			catch (ParseException e) {  				e.printStackTrace(); -				throw new InvalidDateFormatException(); +				throw new InvalidDateFormatAttributeException();  			}  		}  		return null; - +		  	} - -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_BIRTHDATE_FRIENDLY_NAME, -				MANDATE_NAT_PER_BIRTHDATE_NAME); +	 +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_BIRTHDATE_FRIENDLY_NAME, MANDATE_NAT_PER_BIRTHDATE_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonFamilyNameAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonFamilyNameAttributeBuilder.java index 6744e5d20..0e40f9e04 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonFamilyNameAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonFamilyNameAttributeBuilder.java @@ -2,7 +2,6 @@ package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes;  import java.util.Iterator; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -11,32 +10,32 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPers  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateNaturalPersonFamilyNameAttributeBuilder  extends BaseAttributeBuilder { +public class MandateNaturalPersonFamilyNameAttributeBuilder  implements IPVPAttributeBuilder {  	public String getName() {  		return MANDATE_NAT_PER_FAMILY_NAME_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if(authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			PhysicalPersonType physicalPerson = mandateObject.getMandator().getPhysicalPerson();  			if(physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			StringBuilder sb = new StringBuilder(); @@ -46,15 +45,15 @@ public class MandateNaturalPersonFamilyNameAttributeBuilder  extends BaseAttribu  				sb.append(" " + fNamesit.next().getValue());  			} -			return buildStringAttribute(MANDATE_NAT_PER_FAMILY_NAME_FRIENDLY_NAME,  +			return g.buildStringAttribute(MANDATE_NAT_PER_FAMILY_NAME_FRIENDLY_NAME,   					MANDATE_NAT_PER_FAMILY_NAME_NAME, sb.toString());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_FAMILY_NAME_FRIENDLY_NAME,  +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_FAMILY_NAME_FRIENDLY_NAME,   				MANDATE_NAT_PER_FAMILY_NAME_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonGivenNameAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonGivenNameAttributeBuilder.java index 67aa8df0e..88efc3717 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonGivenNameAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonGivenNameAttributeBuilder.java @@ -2,7 +2,6 @@ package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes;  import java.util.Iterator; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -10,51 +9,49 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPers  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateNaturalPersonGivenNameAttributeBuilder extends BaseAttributeBuilder { - +public class MandateNaturalPersonGivenNameAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_NAT_PER_GIVEN_NAME_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate); -			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +			if (mandateObject == null) { +				throw new NoMandateDataAttributeException();  			}  			PhysicalPersonType physicalPerson = mandateObject.getMandator().getPhysicalPerson(); -			if(physicalPerson == null) { +			if (physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			StringBuilder sb = new StringBuilder();  			Iterator<String> gNamesit = physicalPerson.getName().getGivenName().iterator(); -			while(gNamesit.hasNext()) { +			while (gNamesit.hasNext()) {  				sb.append(" " + gNamesit.next());  			} -			return buildStringAttribute(MANDATE_NAT_PER_GIVEN_NAME_FRIENDLY_NAME,  -					MANDATE_NAT_PER_GIVEN_NAME_NAME, sb.toString()); +			return g.buildStringAttribute(MANDATE_NAT_PER_GIVEN_NAME_FRIENDLY_NAME, MANDATE_NAT_PER_GIVEN_NAME_NAME, sb.toString());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_GIVEN_NAME_FRIENDLY_NAME,  -				MANDATE_NAT_PER_GIVEN_NAME_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_GIVEN_NAME_FRIENDLY_NAME, MANDATE_NAT_PER_GIVEN_NAME_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinAttributeBuilder.java index aa8061506..b0c2261ef 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -9,35 +8,33 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPers  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateNaturalPersonSourcePinAttributeBuilder extends -		BaseAttributeBuilder { +public class MandateNaturalPersonSourcePinAttributeBuilder  implements IPVPAttributeBuilder {  	public String getName() {  		return MANDATE_NAT_PER_SOURCE_PIN_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if(authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			PhysicalPersonType physicalPerson = mandateObject.getMandator()  					.getPhysicalPerson();  			if (physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			IdentificationType id = null;  			id = physicalPerson.getIdentification().get(0); @@ -48,17 +45,17 @@ public class MandateNaturalPersonSourcePinAttributeBuilder extends  			}*/  			if(id == null) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			return buildStringAttribute(MANDATE_NAT_PER_SOURCE_PIN_FRIENDLY_NAME, +			return g.buildStringAttribute(MANDATE_NAT_PER_SOURCE_PIN_FRIENDLY_NAME,  					MANDATE_NAT_PER_SOURCE_PIN_NAME, id.getValue().getValue());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_SOURCE_PIN_FRIENDLY_NAME,  +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_SOURCE_PIN_FRIENDLY_NAME,   				MANDATE_NAT_PER_SOURCE_PIN_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinTypeAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinTypeAttributeBuilder.java index 6ef2f5fa5..54b0b8d74 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinTypeAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateNaturalPersonSourcePinTypeAttributeBuilder.java @@ -1,6 +1,5 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; @@ -9,35 +8,33 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPers  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder;  import at.gv.egovernment.moa.logging.Logger; -public class MandateNaturalPersonSourcePinTypeAttributeBuilder extends -		BaseAttributeBuilder { +public class MandateNaturalPersonSourcePinTypeAttributeBuilder implements IPVPAttributeBuilder  {  	public String getName() {  		return MANDATE_NAT_PER_SOURCE_PIN_TYPE_NAME;  	} -	public Attribute build(AuthenticationSession authSession, -			OAAuthParameter oaParam, AuthenticationData authData) -			throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if(authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate);  			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			PhysicalPersonType physicalPerson = mandateObject.getMandator()  					.getPhysicalPerson();  			if (physicalPerson == null) {  				Logger.error("No physicalPerson mandate"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			IdentificationType id = null;  			id = physicalPerson.getIdentification().get(0); @@ -48,17 +45,17 @@ public class MandateNaturalPersonSourcePinTypeAttributeBuilder extends  			}*/  			if(id == null) {  				Logger.error("Failed to generate IdentificationType"); -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			} -			return buildStringAttribute(MANDATE_NAT_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME, +			return g.buildStringAttribute(MANDATE_NAT_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME,  					MANDATE_NAT_PER_SOURCE_PIN_TYPE_NAME, id.getType());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_NAT_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME,  +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_NAT_PER_SOURCE_PIN_TYPE_FRIENDLY_NAME,   				MANDATE_NAT_PER_SOURCE_PIN_TYPE_NAME);  	} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepDescAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepDescAttributeBuilder.java index 66ac56d00..80393fb50 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepDescAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepDescAttributeBuilder.java @@ -1,27 +1,26 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.protocols.pvp2x.utils.AttributeExtractor; -public class MandateProfRepDescAttributeBuilder extends BaseAttributeBuilder { +public class MandateProfRepDescAttributeBuilder implements IPVPAttributeBuilder {  	public String getName() {  		return MANDATE_PROF_REP_DESC_NAME;  	} -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException {  		if(authSession.getUseMandate()) {  			Element mandate = authSession.getMandate();  			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +				throw new NoMandateDataAttributeException();  			}  			String text = AttributeExtractor.extractSAMLAttributeOA( @@ -32,7 +31,7 @@ public class MandateProfRepDescAttributeBuilder extends BaseAttributeBuilder {  				return null;  			} -			return buildStringAttribute(MANDATE_PROF_REP_DESC_FRIENDLY_NAME,  +			return g.buildStringAttribute(MANDATE_PROF_REP_DESC_FRIENDLY_NAME,   					MANDATE_PROF_REP_DESC_NAME, text);  		} @@ -40,8 +39,8 @@ public class MandateProfRepDescAttributeBuilder extends BaseAttributeBuilder {  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_PROF_REP_DESC_FRIENDLY_NAME,  +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_PROF_REP_DESC_FRIENDLY_NAME,   				MANDATE_PROF_REP_DESC_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepOIDAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepOIDAttributeBuilder.java index d708cba95..e3bfda252 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepOIDAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateProfRepOIDAttributeBuilder.java @@ -1,48 +1,42 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.protocols.pvp2x.utils.AttributeExtractor; -public class MandateProfRepOIDAttributeBuilder extends BaseAttributeBuilder { - +public class MandateProfRepOIDAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_PROF_REP_OID_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			} -			String oid = AttributeExtractor.extractSAMLAttributeOA( -					EXT_SAML_MANDATE_OID,   -					authSession); +			String oid = AttributeExtractor.extractSAMLAttributeOA(EXT_SAML_MANDATE_OID, authSession); -			if(oid == null) { +			if (oid == null) {  				return null;  			} -			return buildStringAttribute(MANDATE_PROF_REP_OID_FRIENDLY_NAME,  -					MANDATE_PROF_REP_OID_NAME, oid); +			return g.buildStringAttribute(MANDATE_PROF_REP_OID_FRIENDLY_NAME, MANDATE_PROF_REP_OID_NAME, oid);  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_PROF_REP_OID_FRIENDLY_NAME,  -				MANDATE_PROF_REP_OID_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_PROF_REP_OID_FRIENDLY_NAME, MANDATE_PROF_REP_OID_NAME);  	}  } - 
\ No newline at end of file diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateReferenceValueAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateReferenceValueAttributeBuilder.java index 5a50473d3..ad664486b 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateReferenceValueAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateReferenceValueAttributeBuilder.java @@ -1,43 +1,41 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMandateDataAvailableException; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder; -public class MandateReferenceValueAttributeBuilder extends BaseAttributeBuilder { - +public class MandateReferenceValueAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_REFERENCE_VALUE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws PVP2Exception { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new NoMandateDataAvailableException(); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate); -			if(mandateObject == null) { -				throw new NoMandateDataAvailableException(); +			if (mandateObject == null) { +				throw new NoMandateDataAttributeException();  			} -			return buildStringAttribute(MANDATE_REFERENCE_VALUE_FRIENDLY_NAME,  -					MANDATE_REFERENCE_VALUE_NAME, mandateObject.getMandateID()); +			return g.buildStringAttribute(MANDATE_REFERENCE_VALUE_FRIENDLY_NAME, MANDATE_REFERENCE_VALUE_NAME, +					mandateObject.getMandateID());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_REFERENCE_VALUE_FRIENDLY_NAME,  -				MANDATE_REFERENCE_VALUE_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_REFERENCE_VALUE_FRIENDLY_NAME, MANDATE_REFERENCE_VALUE_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateTypeAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateTypeAttributeBuilder.java index bc7fdaf73..76dc1cb83 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateTypeAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/MandateTypeAttributeBuilder.java @@ -1,41 +1,41 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute;  import org.w3c.dom.Element;  import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate;  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.ResponderErrorException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.NoMandateDataAttributeException;  import at.gv.egovernment.moa.id.util.MandateBuilder; -public class MandateTypeAttributeBuilder extends BaseAttributeBuilder { - +public class MandateTypeAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return MANDATE_TYPE_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) throws ResponderErrorException { -		if(authSession.getUseMandate()) { +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		if (authSession.getUseMandate()) {  			Element mandate = authSession.getMandate(); -			if(mandate == null) { -				throw new ResponderErrorException("No mandate data available", null); +			if (mandate == null) { +				throw new NoMandateDataAttributeException();  			}  			Mandate mandateObject = MandateBuilder.buildMandate(mandate); -			if(mandateObject == null) { -				throw new ResponderErrorException("No mandate data available", null); +			if (mandateObject == null) { +				throw new NoMandateDataAttributeException();  			} -			return buildStringAttribute(MANDATE_TYPE_FRIENDLY_NAME, MANDATE_TYPE_NAME, mandateObject.getAnnotation()); +			return g.buildStringAttribute(MANDATE_TYPE_FRIENDLY_NAME, MANDATE_TYPE_NAME, mandateObject.getAnnotation());  		}  		return null;  	} -	public Attribute buildEmpty() { -		return buildemptyAttribute(MANDATE_TYPE_FRIENDLY_NAME, MANDATE_TYPE_NAME); +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(MANDATE_TYPE_FRIENDLY_NAME, MANDATE_TYPE_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PVPVersionAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PVPVersionAttributeBuilder.java index 545d70d76..149513764 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PVPVersionAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PVPVersionAttributeBuilder.java @@ -1,24 +1,23 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class PVPVersionAttributeBuilder extends BaseAttributeBuilder { - +public class PVPVersionAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return PVP_VERSION_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { -		return buildStringAttribute(PVP_VERSION_FRIENDLY_NAME, PVP_VERSION_NAME, PVP_VERSION_2_1); +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		return g.buildStringAttribute(PVP_VERSION_FRIENDLY_NAME, PVP_VERSION_NAME, PVP_VERSION_2_1);  	} - -	public Attribute buildEmpty() { -		return buildemptyAttribute(PVP_VERSION_FRIENDLY_NAME, PVP_VERSION_NAME); +	 +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(PVP_VERSION_FRIENDLY_NAME, PVP_VERSION_NAME);  	}  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PrincipalNameAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PrincipalNameAttributeBuilder.java index 7ca7eb829..2de5ae79a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PrincipalNameAttributeBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/builder/attributes/PrincipalNameAttributeBuilder.java @@ -1,24 +1,23 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes; -import org.opensaml.saml2.core.Attribute; -  import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;  import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;  import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException; -public class PrincipalNameAttributeBuilder extends BaseAttributeBuilder { - +public class PrincipalNameAttributeBuilder implements IPVPAttributeBuilder { +	  	public String getName() {  		return PRINCIPAL_NAME_NAME;  	} - -	public Attribute build(AuthenticationSession authSession,  -			OAAuthParameter oaParam, AuthenticationData authData) { -		return buildStringAttribute(PRINCIPAL_NAME_FRIENDLY_NAME, PRINCIPAL_NAME_NAME, authSession.getIdentityLink().getFamilyName()); +	 +	public <ATT> ATT build(AuthenticationSession authSession, OAAuthParameter oaParam, AuthenticationData authData, +			IAttributeGenerator<ATT> g) throws AttributeException { +		return g.buildStringAttribute(PRINCIPAL_NAME_FRIENDLY_NAME, PRINCIPAL_NAME_NAME, authSession.getIdentityLink().getFamilyName());  	} - -	public Attribute buildEmpty() { -		return buildemptyAttribute(PRINCIPAL_NAME_FRIENDLY_NAME, PRINCIPAL_NAME_NAME); +	 +	public <ATT> ATT buildEmpty(IAttributeGenerator<ATT> g) { +		return g.buildEmptyAttribute(PRINCIPAL_NAME_FRIENDLY_NAME, PRINCIPAL_NAME_NAME);  	} - +	  } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/requestHandler/AuthnRequestHandler.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/requestHandler/AuthnRequestHandler.java index fec21df9e..1d494c512 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/requestHandler/AuthnRequestHandler.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/requestHandler/AuthnRequestHandler.java @@ -1,11 +1,8 @@  package at.gv.egovernment.moa.id.protocols.pvp2x.requestHandler; -import java.util.Date; -  import javax.servlet.http.HttpServletRequest;  import javax.servlet.http.HttpServletResponse; -import org.joda.time.DateTime;  import org.opensaml.common.xml.SAMLConstants;  import org.opensaml.saml2.core.Assertion;  import org.opensaml.saml2.core.AuthnRequest; @@ -54,19 +51,10 @@ public class AuthnRequestHandler implements IRequestHandler, PVPConstants {  		Issuer nissuer = SAML2Utils.createSAMLObject(Issuer.class); -		 -		//TODO: check! -		//change to entity value from entity name to IDP EntityID (URL) -		nissuer.setValue(PVPConfiguration.getInstance().getIDPPublicPath()); -		//nissuer.setValue(PVPConfiguration.getInstance().getIDPIssuerName()); +		nissuer.setValue(PVPConfiguration.getInstance().getIDPIssuerName());  		nissuer.setFormat(NameID.ENTITY); -		  		authResponse.setIssuer(nissuer);  		authResponse.setInResponseTo(authnRequest.getID()); -		 -		//SAML2 response required IssueInstant -		authResponse.setIssueInstant(new DateTime()); -		  		authResponse.getAssertions().add(assertion);  		authResponse.setStatus(SAML2Utils.getSuccessStatus()); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java index e85d87aa3..e9d41b7ee 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java @@ -91,12 +91,10 @@ public class MetadataSignatureFilter implements MetadataFilter {  					throw new MOAIDException("Root element of metadata file has to be signed", null);  				}  				processEntitiesDescriptor(entitiesDescriptor); -				 -			} else if (metadata instanceof EntityDescriptor) { +			} /*else if (metadata instanceof EntityDescriptor) {  				EntityDescriptor entityDescriptor = (EntityDescriptor) metadata;  				processEntityDescriptorr(entityDescriptor); -				 -			} else { +			} */else {  				throw new MOAIDException("Invalid Metadata file Root element is no EntitiesDescriptor", null);  			} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java index d0c28538c..e40d11128 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/storage/AuthenticationSessionStoreage.java @@ -209,7 +209,6 @@ public class AuthenticationSessionStoreage {  				  //Assertion requires an unique artifact  				  if (result.size() != 1) {  					 Logger.trace("No entries found."); -					 tx.commit();  				   	throw new MOADatabaseException("No session found with this sessionID");  				  } diff --git a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties index 78a1206c0..37e35b6ce 100644 --- a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties +++ b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties @@ -66,8 +66,7 @@ config.15=Das Personenbindungs-Trust-Profil (TrustProfileID \= {0}) darf nicht f  config.16=MOA ID Proxy konnte nicht gestartet werden. Das Element ConnnectionParameter im allgemeinen Konfigurationsteil der MOA-ID-PROXY Konfigurationsdatei fehlt. 
  config.17=Fehler beim initialisieren von Hibernate
  config.18=Keine MOA-ID 2.x Konfiguration gefunden.
 -config.19=Kein Schl?ssel f\u00FCr die Resignierung der Personenbindung gefunden.
 -config.20=SZR-Gateway ist nicht konfiguriert. Anmeldung f\u00FCr ausl\u00E4ndische Personen nicht m\u00F6glich. 
 +config.19=Kein Schl?ssel f\u00FCr die Resignierung der Personenbindung gefunden. 
  parser.00=Leichter Fehler beim Parsen: {0}
  parser.01=Fehler beim Parsen: {0}
 diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java index 6452d5ae6..d9d61ee1d 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/CertTest.java @@ -1,24 +1,28 @@  package test.at.gv.egovernment.moa.id.auth.oauth; +import iaik.security.ecc.provider.ECCProvider; +  import java.security.KeyStore;  import java.security.PrivateKey;  import java.security.cert.X509Certificate; -import java.security.interfaces.RSAPrivateKey; -import net.oauth.jsontoken.crypto.RsaSHA256Signer; -import net.oauth.jsontoken.crypto.RsaSHA256Verifier; +import net.oauth.jsontoken.crypto.Signer; +import net.oauth.jsontoken.crypto.Verifier;  import org.opensaml.xml.security.x509.BasicX509Credential; +import org.testng.Assert;  import org.testng.annotations.Test; +import at.gv.egovernment.moa.id.protocols.oauth20.json.OAuth20SHA256Signer; +import at.gv.egovernment.moa.id.protocols.oauth20.json.OAuth20SHA256Verifier;  import at.gv.egovernment.moa.util.KeyStoreUtils; -import at.gv.egovernment.moa.util.StringUtils; -import eu.stork.vidp.messages.exception.SAMLException;  public class CertTest {  	/** KeyStore Path */ -	private String keyStorePath = "file:/D:/dev/work/exthex/workspace/OAuthTesting/resources/keys/test_keystore.jks"; +	private String rsaKeyStorePath = "file:/D:/dev/work/exthex/workspace/OAuthTesting/resources/keys/test_keystore.jks"; +	 +	private String ecdsaKeyStorePath = "file:/D:/dev/work/exthex/workspace/OAuthTesting/resources/keys/ECDSA_keystore.jks";  	/** KeyStore Password */  	private String keyStorePassword = "test12"; @@ -29,19 +33,14 @@ public class CertTest {  	/** Key password */  	private String keyPassword = "test12"; - -	 -	 -	@Test(enabled = false) -	public void loadCert() throws Exception { -		 -		if (StringUtils.isEmpty(this.keyStorePath)) throw new SAMLException("No keyStorePath specified"); +	private BasicX509Credential getCredentials(String keyStorePath) { +		Assert.assertNotNull(keyStorePath);  		// KeyStorePassword optional  		// if (StringUtils.isEmpty(this.keyStorePassword))  		// throw new SAMLException("No keyStorePassword specified"); -		if (StringUtils.isEmpty(this.keyName)) throw new SAMLException("No keyName specified"); +		Assert.assertNotNull(this.keyName);  		// KeyStorePassword optional  		// if (StringUtils.isEmpty(this.keyPassword)) @@ -49,7 +48,8 @@ public class CertTest {  		KeyStore ks = null;  		try { -			ks = KeyStoreUtils.loadKeyStore(this.keyStorePath, this.keyStorePassword); +			ks = KeyStoreUtils.loadKeyStore(keyStorePath, this.keyStorePassword); +			  		}  		catch (Exception e) {  			e.printStackTrace(); @@ -58,29 +58,52 @@ public class CertTest {  		// return new KeyStoreX509CredentialAdapter(ks, keyName, keyPwd.toCharArray());  		BasicX509Credential credential = null;  		try { -			java.security.cert.X509Certificate certificate = (X509Certificate) ks.getCertificate(this.keyName); +			X509Certificate certificate = (X509Certificate) ks.getCertificate(this.keyName);  			PrivateKey privateKey = (PrivateKey) ks.getKey(this.keyName, this.keyPassword.toCharArray()); +			 +			// System.out.println("KS Provider:" + privateKey.getClass());  			credential = new BasicX509Credential();  			credential.setEntityCertificate(certificate);  			credential.setPrivateKey(privateKey); -			System.out.println(privateKey); +			System.out.println("Private Key: " + privateKey);  		}  		catch (Exception e) {  			e.printStackTrace();  		} -		System.out.println(credential); +		return credential; +	} +	 +	private void signAndVerify(BasicX509Credential credential) throws Exception {  		String data = "someData"; -		RsaSHA256Signer signer = new RsaSHA256Signer("signer1", keyName, (RSAPrivateKey) credential.getPrivateKey()); +		Signer signer = new OAuth20SHA256Signer("signer1", keyName, credential.getPrivateKey());  		byte[] signedData = signer.sign(data.getBytes()); -		RsaSHA256Verifier verifier = new RsaSHA256Verifier(credential.getPublicKey()); +		Verifier verifier = new OAuth20SHA256Verifier(credential.getPublicKey());  		verifier.verifySignature(data.getBytes(), signedData);  	} +	 +	@Test +	// (enabled = false) +	public void testRSA() throws Exception { +		BasicX509Credential credential = this.getCredentials(this.rsaKeyStorePath); +		 +		// System.out.println(credential); +		this.signAndVerify(credential); +	} +	 +	@Test +	public void testECDSA() throws Exception { +		ECCProvider.addAsProvider(); +		 +		// Security.addProvider(new ECCProvider()); +		BasicX509Credential credential = this.getCredentials(this.ecdsaKeyStorePath); +		this.signAndVerify(credential); +	}  } diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20ErrorsTests.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20ErrorsTests.java index 64179d75a..9aede62e3 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20ErrorsTests.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20ErrorsTests.java @@ -1,8 +1,6 @@  package test.at.gv.egovernment.moa.id.auth.oauth;  import java.io.IOException; -import java.util.Arrays; -import java.util.List;  import javax.servlet.http.HttpServletResponse; @@ -22,10 +20,6 @@ import at.gv.egovernment.moa.id.protocols.oauth20.OAuth20Util;  import com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver;  import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; -import com.google.api.client.http.HttpTransport; -import com.google.api.client.http.javanet.NetHttpTransport; -import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory;  public class OAuth20ErrorsTests { @@ -45,7 +39,7 @@ public class OAuth20ErrorsTests {  	// client secret  	private static String CLIENT_SECRET = "d435cf0a-3933-48f7-b142-339710c8f070";  	// OAuth 2.0 scopes -	private static List<String> SCOPES = Arrays.asList("testScope1", "testScope2"); +	//private static List<String> SCOPES = Arrays.asList("testScope1", "testScope2");  	// state  	private static String STATE = "testState";  	// code diff --git a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20GoogleClientTestCase.java b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20GoogleClientTestCase.java index 7cf2ac82b..b2c17f062 100644 --- a/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20GoogleClientTestCase.java +++ b/id/server/idserverlib/src/test/java/test/at/gv/egovernment/moa/id/auth/oauth/OAuth20GoogleClientTestCase.java @@ -62,7 +62,8 @@ public class OAuth20GoogleClientTestCase {  	// open browser for bku login  	private void openURL(String url) {  		Assert.assertNotNull(url); -		System.out.println(url); +		log.info("Please open the following URL in your browser:"); +		log.info(url);  		if (Desktop.isDesktopSupported()) {  			Desktop desktop = Desktop.getDesktop();  			if (desktop.isSupported(Action.BROWSE)) { @@ -75,10 +76,7 @@ public class OAuth20GoogleClientTestCase {  				}  			}  		} -		// Finally just ask user to open in their browser using copy-paste -		log.info("Please open the following URL in your browser:"); -		log.info(url);  	}  	private TokenResponse authorize() throws Exception { @@ -123,6 +121,8 @@ public class OAuth20GoogleClientTestCase {  		Assert.assertTrue(idToken.verifyIssuer(ISS));  		log.info(idToken.getPayload().toPrettyString()); +		log.info(idToken.getHeader().toPrettyString()); +  	}  	@Test(enabled = false) diff --git a/id/server/moa-id-commons/pom.xml b/id/server/moa-id-commons/pom.xml index 9ec756f85..94726fa16 100644 --- a/id/server/moa-id-commons/pom.xml +++ b/id/server/moa-id-commons/pom.xml @@ -3,7 +3,7 @@    <parent>      <groupId>MOA.id</groupId>      <artifactId>moa-id</artifactId> -    <version>1.9.97-SNAPSHOT</version> +    <version>1.9.96-SNAPSHOT</version>    </parent>    <artifactId>moa-id-commons</artifactId>    <name>moa-id-commons</name> diff --git a/id/server/pom.xml b/id/server/pom.xml index 0f9531abf..a3461e956 100644 --- a/id/server/pom.xml +++ b/id/server/pom.xml @@ -4,7 +4,7 @@      <parent>
          <groupId>MOA</groupId>
          <artifactId>id</artifactId>
 -        <version>1.9.97-SNAPSHOT</version>
 +        <version>1.9.96-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>
 diff --git a/id/server/proxy/.settings/org.eclipse.wst.common.component b/id/server/proxy/.settings/org.eclipse.wst.common.component index 5b7986017..e1f55f641 100644 --- a/id/server/proxy/.settings/org.eclipse.wst.common.component +++ b/id/server/proxy/.settings/org.eclipse.wst.common.component @@ -6,13 +6,13 @@          <dependent-module archiveName="moa-common-2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-common/moa-common">
              <dependency-type>uses</dependency-type>
          </dependent-module>
 -        <dependent-module archiveName="moa-id-lib-1.9.97-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-lib/moa-id-lib">
 +        <dependent-module archiveName="moa-id-lib-1.9.96-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-lib/moa-id-lib">
              <dependency-type>uses</dependency-type>
          </dependent-module>
          <dependent-module archiveName="stork-saml-engine-1.5.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/stork-saml-engine/stork-saml-engine">
              <dependency-type>uses</dependency-type>
          </dependent-module>
 -        <dependent-module archiveName="moa-id-commons-1.9.97-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-commons/moa-id-commons">
 +        <dependent-module archiveName="moa-id-commons-1.9.96-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/moa-id-commons/moa-id-commons">
              <dependency-type>uses</dependency-type>
          </dependent-module>
      <property name="context-root" value="moa-id-proxy"/>
 diff --git a/id/server/proxy/pom.xml b/id/server/proxy/pom.xml index 212ddda71..c7cb9a7c8 100644 --- a/id/server/proxy/pom.xml +++ b/id/server/proxy/pom.xml @@ -2,7 +2,7 @@  	<parent>
  		<groupId>MOA.id</groupId>
  		<artifactId>moa-id</artifactId>
 -		<version>1.9.97-SNAPSHOT</version>
 +		<version>1.9.96-SNAPSHOT</version>
  	</parent>
  	<properties>
 | 
