Commit 1b722339 by Juho Juopperi

LanBortalTerminalWeb project

1 parent 46437a83
Showing with 502 additions and 7 deletions
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<project>LanBortalBeans</project> <project>LanBortalBeans</project>
<project>LanBortalBeansClient</project> <project>LanBortalBeansClient</project>
<project>LanBortalAuthModuleClient</project> <project>LanBortalAuthModuleClient</project>
<project>LanBortalTerminalWeb</project>
<project>LanBortalCommonWeb</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
......
...@@ -22,5 +22,12 @@ ...@@ -22,5 +22,12 @@
<dependent-module archiveName="LanBortalAuthModuleClient.jar" deploy-path="/lib" handle="module:/resource/LanBortalAuthModuleClient/LanBortalAuthModuleClient"> <dependent-module archiveName="LanBortalAuthModuleClient.jar" deploy-path="/lib" handle="module:/resource/LanBortalAuthModuleClient/LanBortalAuthModuleClient">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="LanBortalTerminalWeb.war" deploy-path="/" handle="module:/resource/LanBortalTerminalWeb/LanBortalTerminalWeb">
<dependent-object/>
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="LanBortalCommonWeb.jar" deploy-path="/lib" handle="module:/resource/LanBortalCommonWeb/LanBortalCommonWeb">
<dependency-type>uses</dependency-type>
</dependent-module>
</wb-module> </wb-module>
</project-modules> </project-modules>
package fi.insomnia.bortal;
import java.util.StringTokenizer;
import javax.security.auth.login.LoginException;
import com.sun.appserv.security.AppservCertificateLoginModule;
public class BortalCertificateLoginModule extends AppservCertificateLoginModule {
@Override
protected void authenticateUser() throws LoginException {
// Get the distinguished name from the X500Principal.
String dname = getX500Principal().getName();
log("BortalCertificateLoginModule: " + dname);
StringTokenizer st = new StringTokenizer(dname, " \t\n\r\f,");
while (st.hasMoreTokens()) {
String next = st.nextToken(); // Set the appname:OU as the group.
// At this point, one has the application name and the DN of // the
// certificate. A suitable login decision can be made here.
if (next.startsWith("CN=")) {
commitUserAuthentication(new String[] { getAppName() + ":"
+ next.substring(3) });
return;
}
}
throw new LoginException("No OU found.");
}
private void log(String s) {
System.out.println("BortalCertificateLoginModule: " + s);
}
}
...@@ -38,8 +38,6 @@ package fi.insomnia.bortal; ...@@ -38,8 +38,6 @@ package fi.insomnia.bortal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
...@@ -81,9 +79,6 @@ public class BortalLoginModule extends AppservPasswordLoginModule { ...@@ -81,9 +79,6 @@ public class BortalLoginModule extends AppservPasswordLoginModule {
throw new LoginException("Realm not SampleRealm"); throw new LoginException("Realm not SampleRealm");
} }
// find cert
log("Trying to find certificates");
RealmBeanRemote authbean = BortalRealm.getAuthBean(); RealmBeanRemote authbean = BortalRealm.getAuthBean();
if (authbean == null) { if (authbean == null) {
throw new LoginException( throw new LoginException(
...@@ -139,8 +134,7 @@ public class BortalLoginModule extends AppservPasswordLoginModule { ...@@ -139,8 +134,7 @@ public class BortalLoginModule extends AppservPasswordLoginModule {
} }
private void log(String s) { private void log(String s) {
System.out.println((new StringBuilder()).append("BortalLoginModule::") System.out.println("BortalLoginModule: " + s);
.append(s).toString());
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 6 (MacOS X Default)">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish 3.1.2">
<attributes>
<attribute name="owner.project.facets" value="jst.utility"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LanBortalCommonWeb</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="LanBortalCommonWeb">
<wb-resource deploy-path="/" source-path="/src"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="GlassFish 3.1.2"/>
<fixed facet="jst.utility"/>
<fixed facet="java"/>
<installed facet="java" version="1.6"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
Manifest-Version: 1.0
Class-Path:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 6 (MacOS X Default)">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish 3.1.2">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LanBortalTerminalWeb</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="LanBortalTerminalWeb">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="LanBortalTerminalWeb"/>
<property name="java-output-path" value="/LanBortalTerminalWeb/build/classes"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="GlassFish 3.1.2"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<installed facet="java" version="1.6"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="sun.facet" version="9"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<resource-bundle>
<base-name>fi.insomnia.bortal.resources.i18n</base-name>
<var>i18n</var>
</resource-bundle>
<message-bundle>fi.insomnia.bortal.resources.i18n</message-bundle>
<!-- Legal Country codes: http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm -->
<!-- Assigned Country codes: -->
<!-- Insomnia: IN (INDIA) -->
<!-- Stream: ST (SAO TOME AND PRINCIPE ) -->
<!-- Vector VE (VENEZUELA, BOLIVARIAN REPUBLIC OF) -->
<locale-config>
<default-locale>fi_FI</default-locale>
<supported-locale>fi_fi_XII</supported-locale>
<supported-locale>en_ST_v7</supported-locale>
</locale-config>
</application>
<factory>
<exception-handler-factory>fi.insomnia.bortal.terminal.exceptions.BortalTerminalExceptionHandlerFactory</exception-handler-factory>
</factory>
</faces-config>
<glassfish-web-app error-url="">
<security-role-mapping>
<role-name>allusers</role-name>
<group-name>allusers</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>terminal</role-name>
<group-name>terminal</group-name>
</security-role-mapping>
</glassfish-web-app>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/LanBortalTerminalWeb</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java code.</description>
</property>
</jsp-config>
</sun-web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>LanBortalTerminalWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.wtf</welcome-file>
</welcome-file-list>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.wtf</url-pattern>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
<!--param-value>Production</param-value -->
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<display-name>PrimefacesFileupload</display-name>
<filter-name>PrimeFacesFileupload</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFacesFileupload</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>certificate</realm-name>
</login-config>
<security-constraint>
<display-name>Resource that needs cert auth</display-name>
<web-resource-collection>
<web-resource-name>BortalTerminalWebResource</web-resource-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.wtf</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>allusers</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<description>All authenticated users</description>
<role-name>allusers</role-name>
</security-role>
<security-role>
<description>Sales Terminal</description>
<role-name>terminal</role-name>
</security-role>
<persistence-unit-ref>
<persistence-unit-ref-name>BortalEMF</persistence-unit-ref-name>
</persistence-unit-ref>
</web-app>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
>
<h:head>
<title></title>
</h:head>
<h:body>
<h1>Hurrdurr</h1>
</h:body>
</html>
\ No newline at end of file
package fi.insomnia.bortal.terminal.exceptions;
import java.util.Iterator;
import java.util.Map;
import javax.ejb.AccessLocalException;
import javax.ejb.EJBAccessException;
import javax.faces.FacesException;
import javax.faces.application.NavigationHandler;
import javax.faces.application.ViewExpiredException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionDeniedException;
public class BortalTerminalExceptionHandler extends ExceptionHandlerWrapper {
private static final Logger logger = LoggerFactory
.getLogger(BortalTerminalExceptionHandler.class);
private final ExceptionHandler wrapped;
public BortalTerminalExceptionHandler(ExceptionHandler wrapped) {
this.wrapped = wrapped;
}
@Override
public ExceptionHandler getWrapped() {
return wrapped;
}
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents()
.iterator();
while (i.hasNext()) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event
.getSource();
Throwable t = context.getException();
logger.debug("Found exception! handing it: {}", t.getClass()
.toString());
if (t instanceof ViewExpiredException) {
errorpage(i, t, "viewExpired");
}
Throwable cause = t.getCause();
for (int loop = 0; loop < 20 && cause != null; ++loop) {
logger.debug(
"Cause not null, but {}: {}, checking"
+ cause.getClass(), cause.getMessage());
if (cause instanceof PermissionDeniedException
|| cause instanceof EJBAccessException
|| cause instanceof AccessLocalException) {
logger.debug("Found Permission Denied cause: {}, {}",
cause.getClass(), cause.getMessage());
// errorpage(i, t, "permissionDenied");
}
cause = cause.getCause();
}
}
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped().handle();
}
private void errorpage(Iterator<ExceptionQueuedEvent> i, Throwable t,
String navigateTo) {
logger.info("navigating to {} because root exception: {}", navigateTo,
t.getClass());
ViewExpiredException vee = null;
if (t instanceof ViewExpiredException) {
vee = (ViewExpiredException) t;
}
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, Object> requestMap = fc.getExternalContext()
.getRequestMap();
NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
// Push some useful stuff to the request scope for
// use in the page
if (vee != null) {
requestMap.put("currentViewId", vee.getViewId());
}
nav.handleNavigation(fc, null, navigateTo);
fc.renderResponse();
} finally {
i.remove();
}
}
}
package fi.insomnia.bortal.terminal.exceptions;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;
public class BortalTerminalExceptionHandlerFactory extends ExceptionHandlerFactory {
private ExceptionHandlerFactory parent;
public BortalTerminalExceptionHandlerFactory(ExceptionHandlerFactory parent) {
this.parent = parent;
}
@Override
public ExceptionHandler getExceptionHandler() {
ExceptionHandler result = parent.getExceptionHandler();
result = new BortalTerminalExceptionHandler(result);
return result;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!