hsarweb/lib/ws-commons-util-1.0.2.jar | patch | view | raw | blame | history | |
hsarweb/lib/xmlrpc-client-3.1.3.jar | patch | view | raw | blame | history | |
hsarweb/lib/xmlrpc-common-3.1.3.jar | patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/Bean.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/Context.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/HsarwebException.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/Modules.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/Remote.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/webapp/hello/index.xhtml | ●●●●● patch | view | raw | blame | history | |
hsarweb/webapp/resources/styles/hsar.css | ●●●●● patch | view | raw | blame | history | |
hsarweb/webapp/templates/template.xhtml | ●●●●● patch | view | raw | blame | history |
hsarweb/lib/ws-commons-util-1.0.2.jarBinary files differ
hsarweb/lib/xmlrpc-client-3.1.3.jarBinary files differ
hsarweb/lib/xmlrpc-common-3.1.3.jarBinary files differ
hsarweb/src/de/hsadmin/web/Bean.java
@@ -2,22 +2,52 @@ import java.text.DateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.SessionScoped; @ManagedBean @ManagedBean(name="hello") @SessionScoped public class Bean { public final static DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT); @ManagedProperty(value="#{context}") private Context context; @ManagedProperty(value="#{remote}") private Remote remote; public String getMessage() { return "Hallo Welt"; Map<String, String> where = new HashMap<String, String>(); where.put("name", context.getUser()); String name = "Welt"; try { Object test = remote.callSearch("user", context.getUser(), where); if (test instanceof Object[] && ((Object[])test).length > 0 ) { if (((Object[])test)[0] instanceof Map) { name = (String) ((Map<?, ?>)((Object[])test)[0]).get("comment"); } } } catch (HsarwebException e) { e.printStackTrace(); } return "Hallo " + name; } public String getTime() { return df.format(new Date()); } public void setContext(Context context) { this.context = context; } public void setRemote(Remote remote) { this.remote = remote; } } hsarweb/src/de/hsadmin/web/Context.java
@@ -9,19 +9,29 @@ import org.jasig.cas.client.util.AbstractCasFilter; import org.jasig.cas.client.validation.Assertion; @ManagedBean @ManagedBean(name="context") @SessionScoped public class Context { private ExternalContext getContext() { private ExternalContext getExternalContext() { return FacesContext.getCurrentInstance().getExternalContext(); } public String getUser() { Assertion assertion = (Assertion) getContext().getSessionMap().get(AbstractCasFilter.CONST_CAS_ASSERTION); AttributePrincipal principal = assertion.getPrincipal(); String proxyTicket = principal.getProxyTicketFor("https://agnes.ostwall195.de/backend"); return principal.getName(); private AttributePrincipal getPrincipal() { ExternalContext context = getExternalContext(); Assertion assertion = (Assertion) context.getSessionMap().get(AbstractCasFilter.CONST_CAS_ASSERTION); return assertion.getPrincipal(); } public String getUser() { return getPrincipal().getName(); } public String getProxyTicket() { return getPrincipal().getProxyTicketFor("https://agnes.ostwall195.de:9443/hsar/backend"); } public String getContextPath() { return getExternalContext().getRequestContextPath(); } } hsarweb/src/de/hsadmin/web/HsarwebException.java
New file @@ -0,0 +1,20 @@ package de.hsadmin.web; public class HsarwebException extends Exception { private static final long serialVersionUID = 1L; public HsarwebException(String msg, Exception e) { super(msg, e); } public HsarwebException(Exception e) { super(e); } public HsarwebException(String msg) { super(msg); } } hsarweb/src/de/hsadmin/web/Modules.java
@@ -3,20 +3,31 @@ import java.util.ArrayList; import java.util.List; import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.SessionScoped; @ManagedBean @ApplicationScoped @ManagedBean(name="modules") @SessionScoped public class Modules { @ManagedProperty(value="#{context}") private Context context; public String[] pageNames = new String[] { "hello" }; public List<String> getPageNames() { ArrayList<String> names = new ArrayList<String>(); String path = context.getContextPath() + "/"; names.add(path + context.getUser()); for (String name : pageNames) { names.add(name); names.add(path + name); } return names; } public void setContext(Context context) { this.context = context; } } hsarweb/src/de/hsadmin/web/Remote.java
New file @@ -0,0 +1,52 @@ package de.hsadmin.web; import java.net.MalformedURLException; import java.net.URL; import java.util.Map; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.SessionScoped; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; @ManagedBean(name="remote") @SessionScoped public class Remote { private XmlRpcClient client; @ManagedProperty(value="#{context}") private Context context; public Remote() throws HsarwebException { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); try { config.setServerURL(new URL("https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin")); } catch (MalformedURLException e) { throw new HsarwebException("error in remote server url", e); } client = new XmlRpcClient(); client.setConfig(config); } public Object callSearch(String module, String user, Map<String, String> where) throws HsarwebException { Object[] params = new Object[3]; params[0] = user; params[1] = context.getProxyTicket(); params[2] = where; Object res; try { res = client.execute(module + ".search", params); } catch (XmlRpcException e) { throw new HsarwebException("error in remote server call", e); } return res; } public void setContext(Context context) { this.context = context; } } hsarweb/webapp/hello/index.xhtml
@@ -13,7 +13,7 @@ <ui:param name="title" value="Hallo schöne Welt"/> <ui:define name="content"> <f:view> Hallo  <h:outputText value="#{context.user}"/>, es ist jetzt  <h:outputText value="#{bean.time}"/> Uhr. <h:outputText value="#{hello.message}"/>, es ist jetzt  <h:outputText value="#{hello.time}"/> Uhr. </f:view> </ui:define> </ui:composition> hsarweb/webapp/resources/styles/hsar.css
@@ -54,6 +54,9 @@ padding-left:0px; padding-right:0px; } .dummy { clear:both; } .content { width:606px; margin-left:304px; hsarweb/webapp/templates/template.xhtml
@@ -24,6 +24,7 @@ <div class="content"> <ui:insert name="content">Default Content</ui:insert> </div> <div class="dummy"></div> </div> <div class="footer"> <ui:insert name="footer">Default Footer</ui:insert>