diff options
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols')
6 files changed, 10 insertions, 259 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVP2XProtocol.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVP2XProtocol.java index d9e3b741f..39c22b701 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVP2XProtocol.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVP2XProtocol.java @@ -11,7 +11,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringEscapeUtils; -import org.opensaml.DefaultBootstrap; import org.opensaml.common.xml.SAMLConstants; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.RequestAbstractType; @@ -23,11 +22,9 @@ import org.opensaml.saml2.metadata.AssertionConsumerService; import org.opensaml.saml2.metadata.AttributeConsumingService; import org.opensaml.saml2.metadata.EntityDescriptor; import org.opensaml.saml2.metadata.SPSSODescriptor; -import org.opensaml.xml.ConfigurationException; import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; -import at.gv.egovernment.moa.id.auth.exception.WrongParametersException; import at.gv.egovernment.moa.id.moduls.IAction; import at.gv.egovernment.moa.id.moduls.IModulInfo; import at.gv.egovernment.moa.id.moduls.IRequest; @@ -39,7 +36,6 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.binding.IEncoder; import at.gv.egovernment.moa.id.protocols.pvp2x.binding.MOARequest; import at.gv.egovernment.moa.id.protocols.pvp2x.binding.PostBinding; import at.gv.egovernment.moa.id.protocols.pvp2x.binding.RedirectBinding; -import at.gv.egovernment.moa.id.protocols.pvp2x.config.PVPConfiguration; import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.MandateAttributesNotHandleAbleException; import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoMetadataInformationException; import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.PVP2Exception; @@ -47,7 +43,6 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.utils.CheckMandateAttributes; import at.gv.egovernment.moa.id.protocols.pvp2x.utils.SAML2Utils; import at.gv.egovernment.moa.id.protocols.pvp2x.verification.SAMLVerificationEngine; import at.gv.egovernment.moa.id.protocols.pvp2x.verification.TrustEngineFactory; -import at.gv.egovernment.moa.id.util.ParamValidatorUtils; import at.gv.egovernment.moa.id.util.VelocityLogAdapter; import at.gv.egovernment.moa.logging.Logger; @@ -61,18 +56,11 @@ public class PVP2XProtocol implements IModulInfo, MOAIDAuthConstants { public static final String SOAP = "Soap"; public static final String METADATA = "Metadata"; - private static List<ServletInfo> servletList = new ArrayList<ServletInfo>(); - private static List<IDecoder> decoder = new ArrayList<IDecoder>(); private static HashMap<String, IAction> actions = new HashMap<String, IAction>(); static { - servletList.add(new ServletInfo(PVPProcessor.class, REDIRECT, - ServletType.AUTH)); - servletList.add(new ServletInfo(PVPProcessor.class, POST, - ServletType.AUTH)); - decoder.add(new PostBinding()); decoder.add(new RedirectBinding()); @@ -94,10 +82,6 @@ public class PVP2XProtocol implements IModulInfo, MOAIDAuthConstants { return instance; } - public List<ServletInfo> getServlets() { - return servletList; - } - public String getName() { return NAME; } @@ -179,19 +163,13 @@ public class PVP2XProtocol implements IModulInfo, MOAIDAuthConstants { AssertionConsumerService consumerService = spSSODescriptor.getAssertionConsumerServices().get(assertionidx); AttributeConsumingService attributeConsumer = spSSODescriptor.getAttributeConsumingServices().get(attributeIdx); - //TODO: maybe change to getEntityID() - //String oaURL = consumerService.getLocation(); String oaURL = moaRequest.getEntityMetadata().getEntityID(); String binding = consumerService.getBinding(); String entityID = moaRequest.getEntityMetadata().getEntityID(); Logger.info("Dispatch PVP2 Request: OAURL=" + oaURL + " Binding=" + binding); - //String oaURL = (String) request.getParameter(PARAM_OA); oaURL = StringEscapeUtils.escapeHtml(oaURL); -// if (!ParamValidatorUtils.isValidOA(oaURL)) -// throw new WrongParametersException("StartAuthentication", -// PARAM_OA, "auth.12"); config.setOAURL(oaURL); config.setBinding(binding); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVPTargetConfiguration.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVPTargetConfiguration.java index d842d5fe0..7d101c936 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVPTargetConfiguration.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/PVPTargetConfiguration.java @@ -4,6 +4,9 @@ import at.gv.egovernment.moa.id.moduls.RequestImpl; import at.gv.egovernment.moa.id.protocols.pvp2x.binding.MOARequest; public class PVPTargetConfiguration extends RequestImpl { + + private static final long serialVersionUID = 4889919265919638188L; + MOARequest request; String binding; String consumerURL; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactAction.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactAction.java index 75186eec2..fa9dbe990 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactAction.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactAction.java @@ -1,28 +1,15 @@ package at.gv.egovernment.moa.id.protocols.saml1; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang.StringEscapeUtils; -import at.gv.egovernment.moa.id.auth.builder.RedirectFormBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.exception.AuthenticationException; -import at.gv.egovernment.moa.id.auth.exception.BuildException; import at.gv.egovernment.moa.id.auth.exception.WrongParametersException; import at.gv.egovernment.moa.id.auth.servlet.RedirectServlet; -import at.gv.egovernment.moa.id.commons.db.dao.session.AuthenticatedSessionStore; -import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; -import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.id.data.AuthenticationData; -import at.gv.egovernment.moa.id.moduls.AuthenticationManager; import at.gv.egovernment.moa.id.moduls.IAction; import at.gv.egovernment.moa.id.moduls.IRequest; import at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage; @@ -34,15 +21,7 @@ public class GetArtifactAction implements IAction { public String processRequest(IRequest req, HttpServletRequest httpReq, HttpServletResponse httpResp, AuthenticationSession session) throws AuthenticationException { - -// HttpSession httpSession = httpReq.getSession(); -// AuthenticationManager authmanager = AuthenticationManager.getInstance(); -// AuthenticationSession session = authmanager.getAuthenticationSession(httpSession); - -// if (!AuthenticationSessionStoreage.isAuthenticated(session.getSessionID())) { -// throw new AuthenticationException("auth.21", new Object[] {}); -// } - + String oaURL = (String) req.getOAURL(); String target = (String) req.getTarget(); @@ -59,23 +38,10 @@ public class GetArtifactAction implements IAction { throw new WrongParametersException("StartAuthentication", PARAM_OA, "auth.12"); - - // if (oaURL == null) { -// oaURL = session.getOAURLRequested(); -// } - - // TODO: Support Mandate MODE! OAAuthParameter oaParam = AuthConfigurationProvider.getInstance() .getOnlineApplicationParameter(oaURL); - - // builds authentication data and stores it together with a SAML - // artifact - - //TODO: check, if this is correct!!!! - //AuthenticationData authData = buildAuthenticationData(session, session.getXMLVerifySignatureResponse(), - // useUTC, false); - + SAML1AuthenticationServer saml1server = SAML1AuthenticationServer.getInstace(); AuthenticationData authData = SAML1AuthenticationServer.buildAuthenticationData(session, @@ -97,18 +63,13 @@ public class GetArtifactAction implements IAction { httpResp.addHeader("Location", url); } else { - String redirectURL = oaURL; - - //session.getOAURLRequested(); - + String redirectURL = oaURL; if (!oaParam.getBusinessService()) { -// redirectURL = addURLParameter(redirectURL, PARAM_TARGET, -// URLEncoder.encode(session.getTarget(), "UTF-8")); redirectURL = addURLParameter(redirectURL, PARAM_TARGET, URLEncoder.encode(oaParam.getTarget(), "UTF-8")); - } + redirectURL = addURLParameter(redirectURL, PARAM_SAMLARTIFACT, URLEncoder.encode(samlArtifactBase64, "UTF-8")); redirectURL = httpResp.encodeRedirectURL(redirectURL); @@ -120,30 +81,11 @@ public class GetArtifactAction implements IAction { return authData.getAssertionID(); - } catch (WrongParametersException ex) { - // handleWrongParameters(ex, req, httpResp); - ex.printStackTrace(); - } catch (ConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (BuildException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (AuthenticationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (MOADatabaseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (Exception ex) { + Logger.error("SAML1 Assertion build error", ex); + throw new AuthenticationException("SAML1 Assertion build error.", new Object[]{}, ex); } - return null; } protected static String addURLParameter(String url, String paramname, diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactServlet.java deleted file mode 100644 index 87868e777..000000000 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/GetArtifactServlet.java +++ /dev/null @@ -1,135 +0,0 @@ -package at.gv.egovernment.moa.id.protocols.saml1; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang.StringEscapeUtils; - -import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; -import at.gv.egovernment.moa.id.auth.exception.AuthenticationException; -import at.gv.egovernment.moa.id.auth.exception.BuildException; -import at.gv.egovernment.moa.id.auth.exception.WrongParametersException; -import at.gv.egovernment.moa.id.auth.servlet.AuthServlet; -import at.gv.egovernment.moa.id.config.ConfigurationException; -import at.gv.egovernment.moa.id.moduls.AuthenticationManager; -import at.gv.egovernment.moa.id.util.ParamValidatorUtils; -import at.gv.egovernment.moa.logging.Logger; -import at.gv.egovernment.moa.util.URLEncoder; - -public class GetArtifactServlet extends AuthServlet { - - /** - * - */ - private static final long serialVersionUID = 3593264832041467899L; - - /** - * Constructor for GetArtifactServlet. - */ - public GetArtifactServlet() { - super(); - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - HttpSession httpSession = req.getSession(); - - - -// AuthenticationSession session = AuthenticationManager -// .getAuthenticationSession(httpSession); -// -// String oaURL = (String) req.getAttribute(PARAM_OA); -// oaURL = StringEscapeUtils.escapeHtml(oaURL); -// -// String target = (String) req.getAttribute(PARAM_TARGET); -// target = StringEscapeUtils.escapeHtml(target); -// -// try { -// -// // check parameter -// if (!ParamValidatorUtils.isValidOA(oaURL)) -// throw new WrongParametersException("StartAuthentication", -// PARAM_OA, "auth.12"); -// -// if (oaURL == null) { -// oaURL = session.getOAURLRequested(); -// } -// -// if (oaURL == null) { -// throw new WrongParametersException("StartAuthentication", -// PARAM_OA, "auth.12"); -// } -// -// String samlArtifactBase64 = SAML1AuthenticationServer -// .BuildSAMLArtifact(session); -// -// String redirectURL = oaURL; -// session.getOAURLRequested(); -// if (!session.getBusinessService()) { -// redirectURL = addURLParameter(redirectURL, PARAM_TARGET, -// URLEncoder.encode(session.getTarget(), "UTF-8")); -// -// } -// redirectURL = addURLParameter(redirectURL, PARAM_SAMLARTIFACT, -// URLEncoder.encode(samlArtifactBase64, "UTF-8")); -// redirectURL = resp.encodeRedirectURL(redirectURL); -// -// resp.setContentType("text/html"); -// resp.setStatus(302); -// -// resp.addHeader("Location", redirectURL); -// Logger.debug("REDIRECT TO: " + redirectURL); -// -// // CONFIRMATION FOR SSO! -// /* -// * OAAuthParameter oaParam = -// * AuthConfigurationProvider.getInstance(). -// * getOnlineApplicationParameter(oaURL); -// * -// * String friendlyName = oaParam.getFriendlyName(); if(friendlyName -// * == null) { friendlyName = oaURL; } -// * -// * -// * LoginConfirmationBuilder builder = new -// * LoginConfirmationBuilder(); -// * builder.addParameter(PARAM_SAMLARTIFACT, samlArtifactBase64); -// * String form = builder.finish(oaURL, session.getIdentityLink() -// * .getName(), friendlyName); -// */ -// -// /* -// resp.setContentType("text/html"); -// -// OutputStream out = resp.getOutputStream(); -// out.write(form.getBytes("UTF-8")); -// out.flush(); -// out.close();*/ -// -// } catch (WrongParametersException ex) { -// handleWrongParameters(ex, req, resp); -// } catch (ConfigurationException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (BuildException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (AuthenticationException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } - - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - doGet(req, resp); - } - -} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1AuthenticationServer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1AuthenticationServer.java index 9e5f43d8e..c9ee281e6 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1AuthenticationServer.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1AuthenticationServer.java @@ -51,11 +51,9 @@ public class SAML1AuthenticationServer extends AuthenticationServer { return instance; } - //private static Map authenticationDataStore = new HashMap(); private static AssertionStorage authenticationDataStore = AssertionStorage.getInstance(); - //TODO: make this time configurable /** * time out in milliseconds used by {@link cleanup} for authentication data * store @@ -119,19 +117,6 @@ public class SAML1AuthenticationServer extends AuthenticationServer { } } - //removed from MOA-ID 2.0 config -// try { -// String boolStr = AuthConfigurationProvider.getInstance() -// .getGenericConfigurationParameter( -// "AuthenticationServer.KeepAssertion"); -// if (null != boolStr && boolStr.equalsIgnoreCase("true")) -// keepAssertion = true;// Only allowed for debug purposes!!! -// -// } catch (ConfigurationException ex) { -// throw new AuthenticationException("1205", new Object[] { -// samlArtifact, ex.toString() }); -// } - authenticationDataStore.remove(samlArtifact); long now = new Date().getTime(); @@ -317,11 +302,6 @@ public class SAML1AuthenticationServer extends AuthenticationServer { authData.setSamlAssertion(samlAssertion); -// String samlArtifact = new SAMLArtifactBuilder().build( -// session.getAuthURL(), session.getSessionID(), -// saml1parameter.getSourceID()); - - //TODO: check if it correct String samlArtifact = new SAMLArtifactBuilder().build( session.getAuthURL(), Random.nextRandom(), saml1parameter.getSourceID()); @@ -349,10 +329,6 @@ public class SAML1AuthenticationServer extends AuthenticationServer { throw new AuthenticationException("auth.10", new Object[] { REQ_VERIFY_AUTH_BLOCK, PARAM_SESSIONID }); - //AuthenticationSession session = getSession(sessionID); - // AuthConfigurationProvider authConf = - // AuthConfigurationProvider.getInstance(); - IdentityLink tempIdentityLink = null; Element mandate = session.getMandate(); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1Protocol.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1Protocol.java index e36ac0a8c..9d163032e 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1Protocol.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/saml1/SAML1Protocol.java @@ -1,8 +1,6 @@ package at.gv.egovernment.moa.id.protocols.saml1; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -19,8 +17,6 @@ import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.id.moduls.IAction; import at.gv.egovernment.moa.id.moduls.IModulInfo; import at.gv.egovernment.moa.id.moduls.IRequest; -import at.gv.egovernment.moa.id.moduls.ServletInfo; -import at.gv.egovernment.moa.id.moduls.ServletType; import at.gv.egovernment.moa.id.moduls.RequestImpl; import at.gv.egovernment.moa.id.util.ParamValidatorUtils; import at.gv.egovernment.moa.logging.Logger; @@ -33,13 +29,9 @@ public class SAML1Protocol implements IModulInfo, MOAIDAuthConstants { public static final String GETARTIFACT = "GetArtifact"; - private static List<ServletInfo> servletList = new ArrayList<ServletInfo>(); - private static HashMap<String, IAction> actions = new HashMap<String, IAction>(); static { - servletList.add(new ServletInfo(GetArtifactServlet.class, GETARTIFACT, - ServletType.AUTH)); actions.put(GETARTIFACT, new GetArtifactAction()); @@ -55,11 +47,6 @@ public class SAML1Protocol implements IModulInfo, MOAIDAuthConstants { return instance; } - public List<ServletInfo> getServlets() { - return servletList; - } - - public String getName() { return NAME; } |