2
0
Fork 0

wip made remote ejb working over http

This commit is contained in:
Willem Cazander 2012-11-21 20:45:08 +01:00
parent d4e537a2bf
commit 2a0d992642
393 changed files with 8916 additions and 3872 deletions

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vasc-demo-tech-ejb3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.forwardfire.vasc.demo</groupId>
<artifactId>vasc-demo-tech</artifactId>
<version>0.4.1-SNAPSHOT</version>
</parent>
<artifactId>vasc-demo-tech-ejb3</artifactId>
<name>vasc-demo-tech-ejb3</name>
<description>vasc-demo-tech-ejb3</description>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,17 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import java.util.List;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
public interface VascMenuController {
List<VascMenuWeb> getFilteredMenuWeb(VascMenuWebType type);
List<VascMenuGroup> getFilteredMenuGroup();
List<VascMenu> getFilteredMenu(String groupId);
}

View file

@ -0,0 +1,280 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenu;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroupComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebComparator;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuGroup;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWeb;
import net.forwardfire.vasc.demo.tech.ejb3.menu.model.VascMenuWebType;
/**
* MenuController Shows the menu for the user.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenuControllerImpl implements VascMenuControllerLocal,VascMenuControllerRemote {
private VascMenuWebComparator vascMenuWebComparator = null;
private VascMenuGroupComparator vascMenuGroupComparator = null;
private VascMenuComparator vascMenuComparator = null;
@Resource
private SessionContext session;
public VascMenuControllerImpl() {
vascMenuWebComparator = new VascMenuWebComparator();
vascMenuGroupComparator = new VascMenuGroupComparator();
vascMenuComparator = new VascMenuComparator();
}
public List<VascMenuWeb> fetchVascMenuWeb() {
List<VascMenuWeb> result = new ArrayList<VascMenuWeb>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU_WEB");
ResultSet rs = s.getResultSet();
//int cols = rs.getMetaData().getColumnCount();
while (rs.next()) {
VascMenuWeb menu = new VascMenuWeb();
menu.setId(rs.getInt(1));
menu.setHref(rs.getString(2));
menu.setTitle(rs.getString(3));
menu.setTarget(rs.getString(4));
menu.setActive(rs.getBoolean(5));
menu.setRoles(rs.getString(6));
menu.setMenuOrder(rs.getInt(7));
menu.setMenuType(VascMenuWebType.valueOf(rs.getString(8)));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
public List<VascMenuGroup> fetchVascMenuGroup() {
List<VascMenuGroup> result = new ArrayList<VascMenuGroup>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU_GROUP");
ResultSet rs = s.getResultSet();
while (rs.next()) {
VascMenuGroup menu = new VascMenuGroup();
menu.setId(rs.getString(1));
menu.setTitle(rs.getString(2));
menu.setActive(rs.getBoolean(3));
menu.setRoles(rs.getString(4));
menu.setMenuOrder(rs.getInt(5));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
public List<VascMenu> fetchVascMenu() {
List<VascMenu> result = new ArrayList<VascMenu>(50);
Connection connection = null;
try {
DataSource ds = getDataSource("openejb:Resource/jdbc/DemoManagerDataDS");
connection = ds.getConnection();
Statement s = connection.createStatement();
s.execute("SELECT * FROM VASC_MENU");
ResultSet rs = s.getResultSet();
while (rs.next()) {
VascMenu menu = new VascMenu();
menu.setId(rs.getInt(1));
menu.setVascEntryId(rs.getString(2));
menu.setTitle(rs.getString(3));
menu.setActive(rs.getBoolean(4));
menu.setRoles(rs.getString(5));
menu.setMenuOrder(rs.getInt(6));
menu.setMenuGroup(rs.getString(7));
if (filterVascMenuRoles(menu.getActive(),menu.getRoles())==false) {
continue;
}
result.add(menu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (connection!=null) {
try {
connection.close();
} catch (Exception e) {
}
}
}
return result;
}
private DataSource getDataSource(String name) throws SQLException {
try {
Context initialContext = new InitialContext();
DataSource datasource = (DataSource)initialContext.lookup(name);
if ( datasource == null ) {
throw new SQLException("Cannot lookup datasource: "+name);
}
return datasource;
} catch ( NamingException e ) {
throw new SQLException("Cannot get connection " + e,e);
}
}
private boolean filterVascMenuRoles(Boolean active,String roles) {
if (active!=null && active==false) {
return false;
}
if (roles!=null && roles.isEmpty()==false) {
String[] rolesArray = roles.split(",");
for (String role:rolesArray) {
if (role.isEmpty()) {
continue;
}
if (session.isCallerInRole(role)==false) {
return false;
}
}
}
return true;
}
public List<VascMenuGroup> getFilteredMenuGroup() {
List<VascMenuGroup> result = fetchVascMenuGroup();
for (VascMenuGroup group:result) {
group.setMenus(getFilteredMenu(group.getId()));
}
Collections.sort(result,vascMenuGroupComparator);
return result;
}
public List<VascMenu> getFilteredMenu(String groupId) {
if (groupId==null) {
throw new NullPointerException("Can't filter on null groupId.");
}
List<VascMenu> result = new ArrayList<VascMenu>(15);
for (VascMenu menu:fetchVascMenu()) {
if (groupId.equals(menu.getMenuGroup())) {
result.add(menu);
}
}
Collections.sort(result,vascMenuComparator);
return result;
}
public List<VascMenuWeb> getFilteredMenuWeb(VascMenuWebType type) {
if (type==null) {
throw new NullPointerException("Can't filter on null type.");
}
List<VascMenuWeb> result = new ArrayList<VascMenuWeb>(15);
for (VascMenuWeb menu:fetchVascMenuWeb()) {
if (type.equals(menu.getMenuType())) {
result.add(menu);
}
}
Collections.sort(result,vascMenuWebComparator);
return result;
}
private List<VascMenuWeb> getMenuFiltered(VascMenuWebType type) {
return getFilteredMenuWeb(type);
}
public List<VascMenuWeb> getMenuBarLeft() {
return getMenuFiltered(VascMenuWebType.BAR_LEFT);
}
public List<VascMenuWeb> getMenuBarRight() {
return getMenuFiltered(VascMenuWebType.BAR_RIGHT);
}
public List<VascMenuWeb> getMenuBarBottom() {
return getMenuFiltered(VascMenuWebType.BAR_BOTTOM);
}
public List<VascMenuWeb> getMenuPageIndex() {
return getMenuFiltered(VascMenuWebType.PAGE_INDEX);
}
public List<VascMenuWeb> getMenuPageUserLeft() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_LEFT);
}
public List<VascMenuWeb> getMenuPageUserRight() {
return getMenuFiltered(VascMenuWebType.PAGE_USER_RIGHT);
}
public List<VascMenuWeb> getMenuPageAdmin() {
return getMenuFiltered(VascMenuWebType.PAGE_ADMIN);
}
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import javax.ejb.Local;
@Local
public interface VascMenuControllerLocal extends VascMenuController {
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.menu;
import javax.ejb.Remote;
@Remote
public interface VascMenuControllerRemote extends VascMenuController {
}

View file

@ -0,0 +1,141 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
/**
* VascMenu stores menu item information.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenu implements Serializable {
private static final long serialVersionUID = 5087600835051760512L;
private Integer id = null;
private String vascEntryId = null;
private String title = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private String menuGroup = null;
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the vascEntryId
*/
public String getVascEntryId() {
return vascEntryId;
}
/**
* @param vascEntryId the vascEntryId to set
*/
public void setVascEntryId(String vascEntryId) {
this.vascEntryId = vascEntryId;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roles
*/
public String getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(String roles) {
this.roles = roles;
}
/**
* @return the menuOrder
*/
public Integer getMenuOrder() {
return menuOrder;
}
/**
* @param menuOrder the menuOrder to set
*/
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menuGroup
*/
public String getMenuGroup() {
return menuGroup;
}
/**
* @param menuGroup the menuGroup to set
*/
public void setMenuGroup(String menuGroup) {
this.menuGroup = menuGroup;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
/**
* VascMenuComparator orders the menu group.
*
* @author Willem Cazander
* @version 1.0 nov 17, 2012
*/
public class VascMenuComparator implements Serializable,Comparator<VascMenu> {
private static final long serialVersionUID = 386631856823832371L;
public int compare(VascMenu m1, VascMenu m2) {
if (m1.getMenuOrder()==null) {
return 1;
}
if (m2.getMenuOrder()==null) {
return -1;
}
return m1.getMenuOrder().compareTo(m2.getMenuOrder());
}
}

View file

@ -0,0 +1,127 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.List;
/**
* VascMenuGroup stores menu header item information.
*
* @author Willem Cazander
* @version 1.0 Nov 21, 2012
*/
public class VascMenuGroup implements Serializable {
private static final long serialVersionUID = -9154803561816570868L;
private String id = null;
private String title = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private List<VascMenu> menus = null;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roles
*/
public String getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(String roles) {
this.roles = roles;
}
/**
* @return the menuOrder
*/
public Integer getMenuOrder() {
return menuOrder;
}
/**
* @param menuOrder the menuOrder to set
*/
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menus
*/
public List<VascMenu> getMenus() {
return menus;
}
/**
* @param menus the menus to set
*/
public void setMenus(List<VascMenu> menus) {
this.menus = menus;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
/**
* VascMenuGroupComparator orders the menu group.
*
* @author Willem Cazander
* @version 1.0 nov 17, 2012
*/
public class VascMenuGroupComparator implements Serializable,Comparator<VascMenuGroup> {
private static final long serialVersionUID = 386631856823832371L;
public int compare(VascMenuGroup m1, VascMenuGroup m2) {
if (m1.getMenuOrder()==null) {
return 1;
}
if (m2.getMenuOrder()==null) {
return -1;
}
return m1.getMenuOrder().compareTo(m2.getMenuOrder());
}
}

View file

@ -0,0 +1,156 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
/**
* VascMenu stores menu item information.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenuWeb implements Serializable {
private static final long serialVersionUID = -4650021226959950898L;
private Integer id = null;
private String href = null;
private String title = null;
private String target = null;
private Boolean active = null;
private String roles = null;
private Integer menuOrder = null;
private VascMenuWebType menuType = null;
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the href
*/
public String getHref() {
return href;
}
/**
* @param href the href to set
*/
public void setHref(String href) {
this.href = href;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the target
*/
public String getTarget() {
return target;
}
/**
* @param target the target to set
*/
public void setTarget(String target) {
this.target = target;
}
/**
* @return the active
*/
public Boolean getActive() {
return active;
}
/**
* @param active the active to set
*/
public void setActive(Boolean active) {
this.active = active;
}
/**
* @return the roles
*/
public String getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(String roles) {
this.roles = roles;
}
/**
* @return the menuOrder
*/
public Integer getMenuOrder() {
return menuOrder;
}
/**
* @param menuOrder the menuOrder to set
*/
public void setMenuOrder(Integer menuOrder) {
this.menuOrder = menuOrder;
}
/**
* @return the menuType
*/
public VascMenuWebType getMenuType() {
return menuType;
}
/**
* @param menuType the menuType to set
*/
public void setMenuType(VascMenuWebType menuType) {
this.menuType = menuType;
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
import java.io.Serializable;
import java.util.Comparator;
/**
* VascMenuComparator orders the menu items.
*
* @author Willem Cazander
* @version 1.0 May 19, 2012
*/
public class VascMenuWebComparator implements Serializable,Comparator<VascMenuWeb> {
private static final long serialVersionUID = 386631856823832371L;
public int compare(VascMenuWeb m1, VascMenuWeb m2) {
if (m1.getMenuOrder()==null) {
return 1;
}
if (m2.getMenuOrder()==null) {
return -1;
}
return m1.getMenuOrder().compareTo(m2.getMenuOrder());
}
}

View file

@ -0,0 +1,42 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.ejb3.menu.model;
/**
* VascMenuType defines all menu lists on page.
*
* @author Willem Cazander
* @version 1.0 May 26, 2012
*/
public enum VascMenuWebType {
BAR_LEFT,
BAR_RIGHT,
BAR_BOTTOM,
PAGE_INDEX,
PAGE_USER_LEFT,
PAGE_USER_RIGHT,
PAGE_ADMIN,
PAGE_HELP
}

View file

@ -0,0 +1,21 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import javax.ejb.Remote;
public interface LoginUserController {
public String doClientLogin();
/*
public void doClientLogout();
public User getUser() throws Exception;
public List<RightRole> getClientRoles() throws Exception;
*/
}

View file

@ -0,0 +1,57 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.annotation.Resource;
import javax.annotation.security.RolesAllowed;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
@Stateless(name="loginUserController")
public class LoginUserControllerImpl implements LoginUserControllerLocal,LoginUserControllerRemote {
@Resource
private SessionContext session;
/**
* Tests for the login role
*/
@RolesAllowed("login")
public String doClientLogin() {
String name = session.getCallerPrincipal().getName();
return name;
/*
User u = null;
try {
u = getUser();
} catch (Exception e) {
throw new IllegalStateException("Could not lookup showplanner user from username: "+session.getCallerPrincipal().getName());
}
UserSession us = new UserSession();
us.setLoginDate(new Date());
us.setLogoutDate(null); // set when doing doClientLogout();
try {
Query q2 = xtesManager.getQuery("users.xml", "getUserSessionStatusByStatusKey");
q2.setQueryParameter("status_key", "success");
q2.setProperty("limit", 1);
UserSessionStatus userSessionStatus = (UserSessionStatus)xtesManager.executeObject(q2);
us.setUserSessionStatus(userSessionStatus);
} catch (Exception e) {
throw new IllegalStateException("Could not lookup session status of success.");
}
// current_time_in_secs + str_to_int(username)*10E20
long timeSS = us.getLoginDate().getTime();
int userSS = hashUserName(u.getUsername());
int modSS = 10230;
long sessionId = timeSS+userSS*modSS;
us.setSessionId(sessionId);
//System.out.println("Created sessionId: timeSS: "+timeSS+" userSS: "+userSS+" modSS: "+modSS);
us.setUser(u);
entityManager.persist(us);
return u.getUsername();
*/
}
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.ejb.Local;
@Local
public interface LoginUserControllerLocal extends LoginUserController {
}

View file

@ -0,0 +1,8 @@
package net.forwardfire.vasc.demo.tech.ejb3.user;
import javax.ejb.Remote;
@Remote
public interface LoginUserControllerRemote extends LoginUserController {
}

View file

@ -0,0 +1,17 @@
<ejb-jar 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/ejb-jar_3_0.xsd"
version="3.0">
<!--
<enterprise-beans>
<session>
<ejb-name>loginUserController</ejb-name>
<business-local>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserController$ILocal</business-local>
<business-remote>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserController$ILocal</business-remote>
<ejb-class>net.forwardfire.vasc.demo.tech.web.ejb3.LoginUserControllerImpl</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
-->
</ejb-jar>