From aa1dda4e14e7aebd3ec0df5e50493d273a65d999 Mon Sep 17 00:00:00 2001
From: Thomas Lenz <tlenz@iaik.tugraz.at>
Date: Wed, 2 Sep 2015 17:06:24 +0200
Subject: fix problem with private service applications and target friendlyname

---
 .../StartAuthentificationParameterParser.java      | 79 ++++++++++++----------
 1 file changed, 42 insertions(+), 37 deletions(-)

(limited to 'id/server/idserverlib/src/main')

diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/parser/StartAuthentificationParameterParser.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/parser/StartAuthentificationParameterParser.java
index ded261bfc..32ee2a126 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/parser/StartAuthentificationParameterParser.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/parser/StartAuthentificationParameterParser.java
@@ -125,42 +125,51 @@ public class StartAuthentificationParameterParser extends MOAIDAuthConstants{
 		    // get target and target friendly name from config
 		    String targetConfig = oaParam.getTarget();
 			String targetFriendlyNameConfig = oaParam.getTargetFriendlyName();
-			 			
-			if (StringUtils.isEmpty(targetConfig)
-					|| (module.equals(SAML1Protocol.PATH) && 
-							!StringUtils.isEmpty(target)) 
-				) {
-					//INFO: ONLY SAML1 legacy mode
-			    	// if SAML1 is used and target attribute is given in request
-			    	// use requested target
-			    	// check target parameter
-				if (!ParamValidatorUtils.isValidTarget(target)) {
-                    Logger.error("Selected target is invalid. Using target: " + target);
-			   		throw new WrongParametersException("StartAuthentication", PARAM_TARGET, "auth.12");
-                }
-				if (MiscUtil.isNotEmpty(targetConfig))
-					targetFriendlyName = targetFriendlyNameConfig;
-				
-				else {
-					String sectorName = TargetToSectorNameMapper.getSectorNameViaTarget(target);
-					if (MiscUtil.isNotEmpty(sectorName))
-							targetFriendlyName = sectorName;
+			
+			if (!oaParam.getBusinessService()) {
+				if (StringUtils.isEmpty(targetConfig)
+						|| (module.equals(SAML1Protocol.PATH) && 
+								!StringUtils.isEmpty(target)) 
+					) {
+						//INFO: ONLY SAML1 legacy mode
+				    	// if SAML1 is used and target attribute is given in request
+				    	// use requested target
+				    	// check target parameter
+					if (!ParamValidatorUtils.isValidTarget(target)) {
+	                    Logger.error("Selected target is invalid. Using target: " + target);
+				   		throw new WrongParametersException("StartAuthentication", PARAM_TARGET, "auth.12");
+	                }
+					if (MiscUtil.isNotEmpty(targetConfig))
+						targetFriendlyName = targetFriendlyNameConfig;
 					
 					else {
-						//check target contains subSector
-						int delimiter = target.indexOf("-");
-						if (delimiter > 0) {
-							targetFriendlyName = 
-									TargetToSectorNameMapper.getSectorNameViaTarget(target.substring(0, delimiter));
-							
-						}						
-					}					
+						String sectorName = TargetToSectorNameMapper.getSectorNameViaTarget(target);
+						if (MiscUtil.isNotEmpty(sectorName))
+								targetFriendlyName = sectorName;
+						
+						else {
+							//check target contains subSector
+							int delimiter = target.indexOf("-");
+							if (delimiter > 0) {
+								targetFriendlyName = 
+										TargetToSectorNameMapper.getSectorNameViaTarget(target.substring(0, delimiter));
+								
+							}						
+						}					
+					}
+										
+				} else {
+				    	// use target from config			    	
+				    	target = targetConfig;
+				    	targetFriendlyName = targetFriendlyNameConfig;
 				}
-									
+				moasession.setTarget(target);
+	            moasession.setTargetFriendlyName(targetFriendlyName);
+	            
 			} else {
-			    	// use target from config			    	
-			    	target = targetConfig;
-			    	targetFriendlyName = targetFriendlyNameConfig;
+	            Logger.debug("Business: " + moasession.getBusinessService() + " stork: " + moasession.getStorkService());
+	            moasession.setDomainIdentifier(oaParam.getIdentityLinkDomainIdentifier());
+				
 			}
 			
 			
@@ -204,13 +213,9 @@ public class StartAuthentificationParameterParser extends MOAIDAuthConstants{
 			}
 			
 			moasession.setPublicOAURLPrefix(oaParam.getPublicURLPrefix());
-			
-			moasession.setTarget(target);
 			moasession.setBusinessService(oaParam.getBusinessService());
+
             //moasession.setStorkService(oaParam.getStorkService());
-            Logger.debug("Business: " + moasession.getBusinessService() + " stork: " + moasession.getStorkService());
-            moasession.setTargetFriendlyName(targetFriendlyName);
-			moasession.setDomainIdentifier(oaParam.getIdentityLinkDomainIdentifier());
 		}
 	   
 		//check OnlineApplicationURL
-- 
cgit v1.2.3