mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-21 21:25:38 +00:00
Added role management and login panel
This commit is contained in:
@@ -54,6 +54,8 @@
|
||||
<plugin id="com.sap.sailing.www.events" autoStart="true" startLevel="4" />
|
||||
<plugin id="com.sap.sailing.xmlexport" autoStart="true" startLevel="4" />
|
||||
<plugin id="com.sap.sailing.xrr.resultimport" autoStart="true" startLevel="3" />
|
||||
<plugin id="com.sap.sse.security.ui" autoStart="true" startLevel="5" />
|
||||
<plugin id="com.sap.sse.security.userstore.mongodb" autoStart="true" startLevel="4" />
|
||||
<plugin id="org.apache.felix.shell" autoStart="true" startLevel="0" />
|
||||
<plugin id="org.apache.felix.shell.remote" autoStart="true" startLevel="0" />
|
||||
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
|
||||
|
||||
@@ -166,6 +166,27 @@ Computes leaderboard information for sailing races and offers RESTful APIs to al
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.sap.sse.security.ui"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.sap.sse.security.userstore"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.sap.sse.security.userstore.mongodb"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.sap.sailing.gwt.ui"
|
||||
download-size="0"
|
||||
|
||||
+6
-1
@@ -43,7 +43,8 @@ public class GlobalNavigationPanel extends FlowPanel {
|
||||
}
|
||||
String leaderBoardLink = EntryPointLinkFactory.createLeaderboardLink(leaderboardLinkParameters);
|
||||
addNavigationLink(leaderboardName, leaderBoardLink, "leaderBoard", "Go to the overview and see all Races in one Leaderboard");
|
||||
}
|
||||
}
|
||||
addLoginPanel();
|
||||
}
|
||||
|
||||
private void addNavigationLink(String linkName, String linkUrl, String styleNameExtension, String htmlTitle) {
|
||||
@@ -54,4 +55,8 @@ public class GlobalNavigationPanel extends FlowPanel {
|
||||
linkHtml.setTitle(setHtmlTitle);
|
||||
add(linkHtml);
|
||||
}
|
||||
|
||||
private void addLoginPanel(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -126,6 +126,7 @@ public class LeaderboardEntryPoint extends AbstractEntryPoint {
|
||||
private void createUI(boolean showRaceDetails, boolean embedded, boolean hideToolbar) {
|
||||
DockLayoutPanel mainPanel = new DockLayoutPanel(Unit.PX);
|
||||
RootLayoutPanel.get().add(mainPanel);
|
||||
//RootLayoutPanel.get().add(new LoginPanel());
|
||||
LogoAndTitlePanel logoAndTitlePanel = null;
|
||||
if (!embedded) {
|
||||
// Hack to shorten the leaderboardName in case of overall leaderboards
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="false"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.barbados.resultimport@default:default,com.sap.sailing.datamining.shared@default:default,com.sap.sailing.datamining@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.igtimiadapter.persistence@default:default,com.sap.sailing.domain.igtimiadapter@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.racelogtrackingadapter@3:default,com.sap.sailing.domain.shared.android@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@4:true,com.sap.sailing.domain.swisstimingreplayadapter@4:true,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@4:true,com.sap.sailing.domain@default:default,com.sap.sailing.ess40.resultimport@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@5:true,com.sap.sailing.kiworesultimport@default:default,com.sap.sailing.manage2sail.resultimport@default:default,com.sap.sailing.manage2sail@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.nmeaconnector@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.resultimport@default:default,com.sap.sailing.sailwave.resultimport@default:default,com.sap.sailing.server.gateway.ess40@4:true,com.sap.sailing.server.gateway.serialization@default:default,com.sap.sailing.server.gateway@5:true,com.sap.sailing.server.replication@4:true,com.sap.sailing.server.trackfiles@default:default,com.sap.sailing.server@default:default,com.sap.sailing.simulator@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.velum.resultimport@default:default,com.sap.sailing.www.events@4:true,com.sap.sailing.www@4:true,com.sap.sailing.xrr.resultimport@default:default,com.sap.sse.common@default:default,com.sap.sse.datamining.shared@default:default,com.sap.sse.datamining@default:default,com.sap.sse.gwt@default:default,com.sap.sse.security.ui@4:true,com.sap.sse.security.userstore.mongodb@3:true,com.sap.sse.security.userstore@default:default,com.sap.sse.security@default:default,com.tractrac.clientmodule@default:default,net.sf.marineapi@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.barbados.resultimport@default:default,com.sap.sailing.datamining.shared@default:default,com.sap.sailing.datamining@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.igtimiadapter.persistence@default:default,com.sap.sailing.domain.igtimiadapter@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.racelogtrackingadapter@3:default,com.sap.sailing.domain.shared.android@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@4:true,com.sap.sailing.domain.swisstimingreplayadapter@4:true,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@4:true,com.sap.sailing.domain@default:default,com.sap.sailing.ess40.resultimport@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@5:true,com.sap.sailing.kiworesultimport@default:default,com.sap.sailing.manage2sail.resultimport@default:default,com.sap.sailing.manage2sail@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.nmeaconnector@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.resultimport@default:default,com.sap.sailing.sailwave.resultimport@default:default,com.sap.sailing.server.gateway.ess40@4:true,com.sap.sailing.server.gateway.serialization@default:default,com.sap.sailing.server.gateway@5:true,com.sap.sailing.server.replication@4:true,com.sap.sailing.server.trackfiles@default:default,com.sap.sailing.server@default:default,com.sap.sailing.simulator@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.velum.resultimport@default:default,com.sap.sailing.www.events@4:true,com.sap.sailing.www@4:true,com.sap.sailing.xrr.resultimport@default:default,com.sap.sse.common@default:default,com.sap.sse.datamining.shared@default:default,com.sap.sse.datamining@default:default,com.sap.sse.gwt@default:default,com.sap.sse.security*1.0.0.qualifier@default:default,com.sap.sse.security.ui@4:true,com.sap.sse.security.userstore.mongodb@3:true,com.sap.sse.security.userstore@default:default,com.tractrac.clientmodule@default:default,net.sf.marineapi@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
</launchConfiguration>
|
||||
|
||||
@@ -33,6 +33,6 @@
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="false"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.barbados.resultimport@default:default,com.sap.sailing.datamining.shared@default:default,com.sap.sailing.datamining@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.igtimiadapter.persistence@default:default,com.sap.sailing.domain.igtimiadapter@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.racelogtrackingadapter@3:true,com.sap.sailing.domain.shared.android@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@4:true,com.sap.sailing.domain.swisstimingreplayadapter@4:true,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@4:true,com.sap.sailing.domain@default:default,com.sap.sailing.ess40.resultimport@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@5:true,com.sap.sailing.kiworesultimport@default:default,com.sap.sailing.manage2sail.resultimport@default:default,com.sap.sailing.manage2sail@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.nmeaconnector@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.resultimport@default:default,com.sap.sailing.sailwave.resultimport@default:default,com.sap.sailing.server.gateway.ess40@4:true,com.sap.sailing.server.gateway.serialization@default:default,com.sap.sailing.server.gateway@5:true,com.sap.sailing.server.replication@4:true,com.sap.sailing.server.trackfiles@default:default,com.sap.sailing.server@default:default,com.sap.sailing.simulator@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.velum.resultimport@default:default,com.sap.sailing.www.events@4:true,com.sap.sailing.www@4:true,com.sap.sailing.xrr.resultimport@default:default,com.sap.sse.common@default:default,com.sap.sse.datamining.shared@default:default,com.sap.sse.datamining@default:default,com.sap.sse.gwt@default:default,com.tractrac.clientmodule@default:default,net.sf.marineapi@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.barbados.resultimport@default:default,com.sap.sailing.datamining.shared@default:default,com.sap.sailing.datamining@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.common@default:default,com.sap.sailing.domain.igtimiadapter.persistence@default:default,com.sap.sailing.domain.igtimiadapter@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.racelogtrackingadapter@3:true,com.sap.sailing.domain.shared.android@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter@4:true,com.sap.sailing.domain.swisstimingreplayadapter@4:true,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@4:true,com.sap.sailing.domain@default:default,com.sap.sailing.ess40.resultimport@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.freg.resultimport@default:default,com.sap.sailing.geocoding@default:default,com.sap.sailing.gwt.ui@5:true,com.sap.sailing.kiworesultimport@default:default,com.sap.sailing.manage2sail.resultimport@default:default,com.sap.sailing.manage2sail@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.nmeaconnector@default:default,com.sap.sailing.operationaltransformation@default:default,com.sap.sailing.resultimport@default:default,com.sap.sailing.sailwave.resultimport@default:default,com.sap.sailing.server.gateway.ess40@4:true,com.sap.sailing.server.gateway.serialization@default:default,com.sap.sailing.server.gateway@5:true,com.sap.sailing.server.replication@4:true,com.sap.sailing.server.trackfiles@default:default,com.sap.sailing.server@default:default,com.sap.sailing.simulator@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.velum.resultimport@default:default,com.sap.sailing.www.events@4:true,com.sap.sailing.www@4:true,com.sap.sailing.xrr.resultimport@default:default,com.sap.sse.common@default:default,com.sap.sse.datamining.shared@default:default,com.sap.sse.datamining@default:default,com.sap.sse.gwt@default:default,com.sap.sse.security*1.0.0.qualifier@default:default,com.sap.sse.security.ui@4:true,com.sap.sse.security.userstore.mongodb@3:true,com.sap.sse.security.userstore@default:default,com.tractrac.clientmodule@default:default,net.sf.marineapi@default:default,org.json.simple@default:default,org.moxieapps.gwt.highcharts@default:default"/>
|
||||
<stringAttribute key="yk-options" value=" additional-options2=onexit\=snapshot "/>
|
||||
</launchConfiguration>
|
||||
|
||||
@@ -53,6 +53,27 @@
|
||||
install-size="0"
|
||||
version="1.6.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.commons.beanutils"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="1.6.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.commons.collections"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="1.6.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.commons.logging"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="1.6.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.sun.mail.javax.mail"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="com.sap.sailing.target.jsp"
|
||||
label="Apache Shiro libraries"
|
||||
version="1.0.0">
|
||||
|
||||
<description>
|
||||
Java Server Pages libraries
|
||||
</description>
|
||||
|
||||
<license url="">
|
||||
NA.
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="org.apache.shiro"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="2.1.0.v201105211819"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.apache.shiro.web"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="2.1.0.v201105211819"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.scribe"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="2.1.0.v201105211819"
|
||||
unpack="false"/>
|
||||
</feature>
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,12 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
ECLIPSE_HOME=c:/apps/eclipse
|
||||
SAILING_GIT_HOME=c:/data/SAP/sailing/workspace
|
||||
ECLIPSE_HOME=C:/Users/D056866/Sailing/eclipse
|
||||
SAILING_GIT_HOME=C:/Users/D056866/Sailing/git
|
||||
TARGET_PLATFORM_BASE_DIR=${SAILING_GIT_HOME}/java/com.sap.sailing.targetplatform.base
|
||||
|
||||
ECLIPSE_VM_ARGS="-Xmx256m"
|
||||
ECLIPSE_LAUNCHER=${ECLIPSE_HOME}/plugins/org.eclipse.equinox.launcher_*.jar
|
||||
|
||||
echo TARGET_PLATFORM_BASE_DIR is $SAILING_GIT_HOME
|
||||
echo ECLIPSE_HOME is $ECLIPSE_HOME
|
||||
echo Eclipse Launcher $ECLIPSE_LAUNCHER
|
||||
|
||||
java -jar ${ECLIPSE_LAUNCHER} -consolelog -nosplash -verbose -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher \
|
||||
-metadataRepository file:/${TARGET_PLATFORM_BASE_DIR}/gen/p2 \
|
||||
-artifactRepository file:/${TARGET_PLATFORM_BASE_DIR}/gen/p2 \
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="WEB-INF/classes"/>
|
||||
<classpathentry exported="true" kind="lib" path="WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -1,209 +1,54 @@
|
||||
/** Add css rules here for your application. */
|
||||
|
||||
* {
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/** Example rules used by the template application (remove for your app) */
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
color: #777777;
|
||||
margin: 40px 0px 70px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
padding: 6px 6px;
|
||||
margin: 8px 3px 10px 2px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
padding: 0px 4px;
|
||||
.loginPanel {
|
||||
width: 200px;
|
||||
position: absolute;
|
||||
padding: 5px;
|
||||
padding-left: 10px;
|
||||
border-bottom-left-radius:10px;
|
||||
top: 0;
|
||||
right: 0;
|
||||
background: #cccccc; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #cccccc 0%, #999999 100%);
|
||||
/* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #cccccc),
|
||||
color-stop(100%, #999999)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #cccccc 0%, #999999 100%);
|
||||
/* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #cccccc 0%, #999999 100%);
|
||||
/* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #cccccc 0%, #999999 100%);
|
||||
/* IE10+ */
|
||||
background: linear-gradient(to bottom, #cccccc 0%, #999999 100%);
|
||||
/* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc',
|
||||
endColorstr='#999999', GradientType=0); /* IE6-9 */
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
|
||||
|
||||
-webkit-transition: height ease-in-out 2s;
|
||||
transition: height ease-in-out 1s;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chartLegend {
|
||||
float: left;
|
||||
margin-right: 4px;
|
||||
.loginPanel > * {
|
||||
float:left;
|
||||
}
|
||||
|
||||
.chartTitle {
|
||||
font: 20px bold;
|
||||
.loginPanel-collapsed {
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.sendButton {
|
||||
display: block;
|
||||
font-size: 16pt;
|
||||
.loginPanel-expanded {
|
||||
height: 170px;
|
||||
}
|
||||
|
||||
/** Most GWT widgets already have a style name defined */
|
||||
|
||||
.dialogVPanel {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.serverResponseLabelError {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/** Set ids using widget.getElement().setId("idOfElement") */
|
||||
#closeButton {
|
||||
margin: 15px 6px 6px;
|
||||
}
|
||||
|
||||
.gwt-TabPanelBottom {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.global-alert-message {
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
font-size: 120%;
|
||||
text-align: right;
|
||||
padding: 0px 50px 0px 0px;
|
||||
.loginPanel-infoPanel {
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.errorLabel {
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.linkNoBorder {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.refreshLink {
|
||||
border: none;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.valignMiddle {
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.boldLabel {
|
||||
font-size: 14px;
|
||||
.LoginPanel>.gwt-Label {
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.boldAnchor {
|
||||
font-weight: bold;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.gwt-ListBox {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.legColumnHeader {
|
||||
background-color: #FFFFFF;
|
||||
padding: 0 0 0 0;
|
||||
}
|
||||
|
||||
.dialogMessageLabel {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.gwt-DialogBox {
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .Caption {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogTopLeft {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogTopRight {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogMiddleLeft {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogMiddleRight {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogBottomCenter {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogBottomLeft {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-DialogBox .dialogBottomRight {
|
||||
background: none repeat scroll 0 0 #e5e5e5;
|
||||
}
|
||||
|
||||
.gwt-Button {
|
||||
margin: 3px 2px 3px 5px;
|
||||
}
|
||||
|
||||
.gwt-Button:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.gwt-Button[disabled] {
|
||||
color: #888888;
|
||||
cursor: default;
|
||||
background: #f1f1f1 !important;
|
||||
border: 1px solid #A3A3A3 !important;
|
||||
}
|
||||
|
||||
.gwt-Button[disabled]:hover {
|
||||
color: #888888;
|
||||
cursor: default;
|
||||
background: #f1f1f1 !important;
|
||||
border: 1px solid #A3A3A3 !important;
|
||||
}
|
||||
|
||||
.gwt-TextBox {
|
||||
font-family: Arial !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
select {
|
||||
font-family: Arial !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
.leftPaddedPanel {
|
||||
padding-left: 50px;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
.paddedPanel {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.gwt-SuggestBoxPopup {
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
border: 1px solid #666;
|
||||
border-top: 0;
|
||||
background-color: #fff;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.gwt-SuggestBoxPopup .item {
|
||||
border: 1px dotted #aaa;
|
||||
}
|
||||
|
||||
.gwt-SuggestBoxPopup .item-selected {
|
||||
background-color: #ffc;
|
||||
}
|
||||
|
||||
.wrap-cols td div {
|
||||
white-space: normal;
|
||||
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
@@ -9,10 +9,11 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Import-Package: org.osgi.framework;version="1.3.0",
|
||||
org.osgi.util.tracker;version="1.5.1"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: ., WEB-INF/classes/
|
||||
Bundle-ClassPath: WEB-INF/classes/
|
||||
Require-Bundle: javax.servlet;bundle-version="2.5.0",
|
||||
com.sap.sse.security.userstore;bundle-version="1.0.0",
|
||||
com.sap.sse.gwt;bundle-version="1.0.0",
|
||||
com.google.gwt.osgi;bundle-version="2.6.0",
|
||||
com.sap.sse.security;bundle-version="1.0.0"
|
||||
Web-ContextPath: /security/ui
|
||||
Export-Package: com.sap.sse.security.ui.loginpanel
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.google.gwt.logging.shared.RemoteLoggingService
|
||||
path: D8354F129B90BCD8991531844AB1022F.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: 15951CA4E2AABDC6EA2B74FBE8BCC2CA.gwt.rpc
|
||||
+2381
File diff suppressed because it is too large
Load Diff
+2389
File diff suppressed because it is too large
Load Diff
+2413
File diff suppressed because it is too large
Load Diff
+2379
File diff suppressed because it is too large
Load Diff
+2381
File diff suppressed because it is too large
Load Diff
+2413
File diff suppressed because it is too large
Load Diff
+2379
File diff suppressed because it is too large
Load Diff
+2374
File diff suppressed because it is too large
Load Diff
+2389
File diff suppressed because it is too large
Load Diff
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.google.gwt.logging.shared.RemoteLoggingService
|
||||
path: D8354F129B90BCD8991531844AB1022F.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: 15951CA4E2AABDC6EA2B74FBE8BCC2CA.gwt.rpc
|
||||
+4194
File diff suppressed because it is too large
Load Diff
+4205
File diff suppressed because it is too large
Load Diff
+4164
File diff suppressed because it is too large
Load Diff
+4177
File diff suppressed because it is too large
Load Diff
+4174
File diff suppressed because it is too large
Load Diff
+4164
File diff suppressed because it is too large
Load Diff
+4194
File diff suppressed because it is too large
Load Diff
+4205
File diff suppressed because it is too large
Load Diff
+4177
File diff suppressed because it is too large
Load Diff
+4174
File diff suppressed because it is too large
Load Diff
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.google.gwt.logging.shared.RemoteLoggingService
|
||||
path: D8354F129B90BCD8991531844AB1022F.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: 7690DE03A38D63E89C531FB1135196F4.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: 84825FE81E8250DD55F1869C2497D8EB.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: B87C2EDF46230A9FC14CACD02263D56F.gwt.rpc
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
serviceClass: com.sap.sse.security.ui.shared.UserManagementService
|
||||
path: 15951CA4E2AABDC6EA2B74FBE8BCC2CA.gwt.rpc
|
||||
@@ -5,5 +5,7 @@ bin.includes = META-INF/,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/web.xml,\
|
||||
UserManagement.css,\
|
||||
UserManagement.html
|
||||
UserManagement.html,\
|
||||
com.sap.sse.security.ui.UserManagement/,\
|
||||
com.sap.sse.security.ui.Login/
|
||||
output.. = WEB-INF/classes/
|
||||
|
||||
@@ -9,4 +9,62 @@
|
||||
</parent>
|
||||
<artifactId>com.sap.sse.security.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>2.6.0</version>
|
||||
<executions>
|
||||
<!-- GWT version detected from dependencyManagement -->
|
||||
<execution>
|
||||
<configuration>
|
||||
<extraJvmArgs>-Dgwt.persistentunitcache=false</extraJvmArgs>
|
||||
<!--
|
||||
<userAgents>chrome</userAgents>
|
||||
-->
|
||||
<modules>
|
||||
<module>com.sap.sse.security.ui.UserManagement</module>
|
||||
<module>com.sap.sse.security.ui.Login</module>
|
||||
</modules>
|
||||
<gen>${basedir}/.generated</gen>
|
||||
<localWorkers>3</localWorkers>
|
||||
<webappDirectory>${basedir}</webappDirectory>
|
||||
<warSourceDirectory>${basedir}/src/main/resources</warSourceDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>debug.no-gwt-compile</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>${gwt.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<configuration combine.self="override">
|
||||
<modules>
|
||||
</modules>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>help</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.sap.sse.security.ui.client.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.PasswordTextBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class CreateUserPanel extends FlowPanel {
|
||||
|
||||
private List<UserCreationEventHandler> handlers = new ArrayList<>();
|
||||
|
||||
|
||||
public CreateUserPanel(final UserManagementServiceAsync userManagementService) {
|
||||
Label title = new Label("Create a new user");
|
||||
title.getElement().getStyle().setFontSize(25, Unit.PX);
|
||||
Label name = new Label("Username:");
|
||||
this.add(name);
|
||||
final TextBox nameBox = new TextBox();
|
||||
this.add(nameBox);
|
||||
Label pw = new Label("Password:");
|
||||
this.add(pw);
|
||||
final TextBox pwBox = new PasswordTextBox();
|
||||
this.add(pwBox);
|
||||
Label pwRepeat = new Label("Repeat password:");
|
||||
this.add(pwRepeat);
|
||||
final TextBox pwRepeatBox = new PasswordTextBox();
|
||||
this.add(pwRepeatBox);
|
||||
Button create = new Button("Create", new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
String name = nameBox.getText();
|
||||
String pw = pwBox.getText();
|
||||
String pwRepeat = pwRepeatBox.getText();
|
||||
if (name.length() >= 3 && pw.equals(pwRepeat) && pw.length() >= 5){
|
||||
userManagementService.createSimpleUser(name, pw, new AsyncCallback<UserDTO>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(UserDTO result) {
|
||||
for (UserCreationEventHandler handler : handlers){
|
||||
handler.onUserCreation(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Could not create user!");
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
Window.alert("Invalid crendetials entered!");
|
||||
}
|
||||
}
|
||||
});
|
||||
this.add(create);
|
||||
}
|
||||
|
||||
public void addUserCreationEventHandler(UserCreationEventHandler handler){
|
||||
this.handlers.add(handler);
|
||||
}
|
||||
|
||||
public void removeUserCreationEventHandler(UserCreationEventHandler handler){
|
||||
this.handlers.remove(handler);
|
||||
}
|
||||
|
||||
public static interface UserCreationEventHandler extends EventHandler {
|
||||
|
||||
void onUserCreation(UserDTO user);
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.sap.sse.security.ui.client.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.cell.client.TextCell;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.cellview.client.CellList;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DecoratorPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.ProvidesKey;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sse.security.ui.client.component.UserDetailsView.UserChangeEventHandler;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class RolesList extends DecoratorPanel {
|
||||
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
private UserDTO userDTO;
|
||||
|
||||
private List<UserChangeEventHandler> handlers = new ArrayList<>();
|
||||
|
||||
ProvidesKey<String> keyProvider = new ProvidesKey<String>() {
|
||||
public Object getKey(String item) {
|
||||
// Always do a null check.
|
||||
return (item == null) ? null : item;
|
||||
}
|
||||
};
|
||||
|
||||
private ListDataProvider<String> rolesDataProvider;
|
||||
|
||||
SingleSelectionModel<String> singleSelectionModel = new SingleSelectionModel<>(keyProvider);
|
||||
|
||||
private CellList<String> roleList;
|
||||
private TextBox roleBox;
|
||||
|
||||
public RolesList(UserManagementServiceAsync userManagementService, UserDTO userDTO) {
|
||||
super();
|
||||
this.userManagementService = userManagementService;
|
||||
this.userDTO = userDTO;
|
||||
FlowPanel fp = new FlowPanel();
|
||||
fp.add(new Label("Roles:"));
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
roleBox = new TextBox();
|
||||
roleBox.getElement().setPropertyString("placeholder", "Add role...");
|
||||
hp.add(roleBox);
|
||||
Button addRole = new Button("Add role", new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
RolesList.this.userManagementService.addRoleForUser(RolesList.this.userDTO.getName(), roleBox.getText(), new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
if (result.isSuccessful()){
|
||||
Window.alert("Success: "+result.getMessage());
|
||||
for (UserChangeEventHandler handler : handlers){
|
||||
handler.onUserChange(RolesList.this.userDTO);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Window.alert("Failed: "+result.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("An error occured while adding the role: " + caught);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
hp.add(addRole);
|
||||
fp.add(hp);
|
||||
|
||||
rolesDataProvider = new ListDataProvider<>(userDTO.getRoles(), keyProvider);
|
||||
roleList = new CellList<>(new TextCell(), keyProvider);
|
||||
rolesDataProvider.addDataDisplay(roleList);
|
||||
|
||||
fp.add(roleList);
|
||||
|
||||
fp.setWidth("400px");
|
||||
this.setWidget(fp);
|
||||
}
|
||||
|
||||
public void addUserChangeEventHandler(UserChangeEventHandler handler){
|
||||
this.handlers.add(handler);
|
||||
}
|
||||
|
||||
public void removeUserChangeEventHandler(UserChangeEventHandler handler){
|
||||
this.handlers.remove(handler);
|
||||
}
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
package com.sap.sse.security.ui.client.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DecoratorPanel;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.ImageResourceRenderer;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sse.security.ui.client.UserManagementImageResources;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class UserDetailsView extends FlowPanel {
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
|
||||
private List<UserChangeEventHandler> handlers = new ArrayList<>();
|
||||
|
||||
public UserDetailsView(UserManagementServiceAsync userManagementService, UserDTO user) {
|
||||
this.userManagementService = userManagementService;
|
||||
updateUser(user);
|
||||
}
|
||||
|
||||
public void updateUser(final UserDTO user) {
|
||||
this.clear();
|
||||
Label title = new Label("User details");
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
title.getElement().getStyle().setFontSize(25, Unit.PX);
|
||||
this.add(title);
|
||||
|
||||
DecoratorPanel decoratorPanel = new DecoratorPanel();
|
||||
FlowPanel fp = new FlowPanel();
|
||||
fp.setWidth("400px");
|
||||
ImageResourceRenderer renderer = new ImageResourceRenderer();
|
||||
final ImageResource userImageResource = UserManagementImageResources.INSTANCE.userSmall();
|
||||
fp.add(new HTML(renderer.render(userImageResource)));
|
||||
Label name = new Label("Name: " + user.getName());
|
||||
fp.add(name);
|
||||
Label type = new Label("Account type: " + user.getAccountType());
|
||||
fp.add(type);
|
||||
decoratorPanel.setWidget(fp);
|
||||
this.add(decoratorPanel);
|
||||
|
||||
RolesList rolesList = new RolesList(userManagementService, user);
|
||||
rolesList.addUserChangeEventHandler(new UserChangeEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onUserChange(UserDTO user) {
|
||||
for (UserChangeEventHandler handler : handlers){
|
||||
handler.onUserChange(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.add(rolesList);
|
||||
Button delete = new Button("Delete user", new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
final DeleteUserConfimDialog deleteUserConfimDialog = new DeleteUserConfimDialog(userManagementService,
|
||||
user.getName());
|
||||
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
|
||||
public void execute() {
|
||||
deleteUserConfimDialog.center();
|
||||
}
|
||||
});
|
||||
deleteUserConfimDialog.show();
|
||||
for (UserChangeEventHandler handler : handlers){
|
||||
handler.onUserChange(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.add(delete);
|
||||
}
|
||||
|
||||
private static class DeleteUserConfimDialog extends DialogBox {
|
||||
|
||||
public DeleteUserConfimDialog(final UserManagementServiceAsync userManagementService, final String username) {
|
||||
setText("Delete user?");
|
||||
|
||||
setAnimationEnabled(true);
|
||||
setGlassEnabled(true);
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
vp.add(new Label("Do you really want to delete \"" + username + "\"?"));
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
Button ok = new Button("OK");
|
||||
ok.addClickHandler(new ClickHandler() {
|
||||
public void onClick(ClickEvent event) {
|
||||
userManagementService.deleteUser(username, new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
Window.alert(result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("An error happened while deleting the user.");
|
||||
}
|
||||
});
|
||||
DeleteUserConfimDialog.this.hide();
|
||||
}
|
||||
});
|
||||
hp.add(ok);
|
||||
Button cancel = new Button("cancel", new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
DeleteUserConfimDialog.this.hide();
|
||||
}
|
||||
});
|
||||
hp.add(cancel);
|
||||
vp.add(hp);
|
||||
setWidget(vp);
|
||||
}
|
||||
}
|
||||
|
||||
public void addUserChangeEventHandler(UserChangeEventHandler handler) {
|
||||
this.handlers.add(handler);
|
||||
}
|
||||
|
||||
public void removeUserChangeEventHandler(UserChangeEventHandler handler) {
|
||||
this.handlers.remove(handler);
|
||||
}
|
||||
|
||||
public static interface UserChangeEventHandler extends EventHandler {
|
||||
|
||||
void onUserChange(UserDTO user);
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -5,13 +5,14 @@ import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.cellview.client.CellList;
|
||||
import com.google.gwt.user.client.ui.ImageResourceRenderer;
|
||||
import com.google.gwt.view.client.ProvidesKey;
|
||||
import com.sap.sse.security.ui.client.UserManagementImageResources;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
|
||||
public class UserList extends CellList<UserDTO> {
|
||||
|
||||
public UserList() {
|
||||
super(new UserCell());
|
||||
public UserList(ProvidesKey<UserDTO> keyProvider) {
|
||||
super(new UserCell(), keyProvider);
|
||||
}
|
||||
|
||||
public static class UserCell extends AbstractCell<UserDTO> {
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.sap.sse.security.ui.client.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.view.client.AbstractDataProvider;
|
||||
import com.google.gwt.view.client.HasData;
|
||||
import com.google.gwt.view.client.ProvidesKey;
|
||||
import com.google.gwt.view.client.Range;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class UserListDataProvider extends AbstractDataProvider<UserDTO> {
|
||||
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
private TextBox filterBox;
|
||||
|
||||
public UserListDataProvider(UserManagementServiceAsync userManagementService, TextBox filterBox, ProvidesKey<UserDTO> keyProvider) {
|
||||
super(keyProvider);
|
||||
this.userManagementService = userManagementService;
|
||||
this.filterBox = filterBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRangeChanged(HasData<UserDTO> display) {
|
||||
final Range range = display.getVisibleRange();
|
||||
userManagementService.getFilteredSortedUserList(filterBox.getText(), new AsyncCallback<Collection<UserDTO>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Collection<UserDTO> result) {
|
||||
List<UserDTO> resultList = new ArrayList<>(result);
|
||||
List<UserDTO> show = new ArrayList<>();
|
||||
int start = range.getStart();
|
||||
int end = range.getStart() + range.getLength();
|
||||
for (int i = start; i < end && i < resultList.size(); i++){
|
||||
show.add(resultList.get(i));
|
||||
}
|
||||
updateRowData(start, show);
|
||||
updateRowCount(result.size(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateDisplays(){
|
||||
for (HasData<UserDTO> hd : getDataDisplays()){
|
||||
onRangeChanged(hd);
|
||||
}
|
||||
// //TODO SelectionChangeEvent.fire(singleSelectionModel);
|
||||
}
|
||||
}
|
||||
+25
-15
@@ -3,17 +3,21 @@ package com.sap.sse.security.ui.login;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.google.gwt.user.client.ui.DockLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.FormPanel;
|
||||
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
|
||||
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.PasswordTextBox;
|
||||
import com.google.gwt.user.client.ui.RootLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.SubmitButton;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.sap.sse.security.ui.loginpanel.LoginPanel;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
@@ -26,10 +30,14 @@ public class LoginEntryPoint implements EntryPoint {
|
||||
registerASyncService((ServiceDefTarget) userManagementService, "service/usermanagement");
|
||||
|
||||
RootLayoutPanel rootPanel = RootLayoutPanel.get();
|
||||
DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.EM);
|
||||
DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
|
||||
rootPanel.add(dockPanel);
|
||||
|
||||
FlowPanel fp = new FlowPanel();
|
||||
|
||||
LoginPanel loginPanel = new LoginPanel();
|
||||
rootPanel.add(loginPanel);
|
||||
|
||||
Label nameLabel = new Label("Name: ");
|
||||
fp.add(nameLabel);
|
||||
final TextBox nameText = new TextBox();
|
||||
@@ -38,16 +46,19 @@ public class LoginEntryPoint implements EntryPoint {
|
||||
|
||||
Label pwLabel = new Label("Password: ");
|
||||
fp.add(pwLabel);
|
||||
final TextBox pwText = new TextBox();
|
||||
final PasswordTextBox pwText = new PasswordTextBox();
|
||||
pwText.setName("password");
|
||||
fp.add(pwText);
|
||||
|
||||
SubmitButton submit = new SubmitButton("login");
|
||||
submit.addClickHandler(new ClickHandler() {
|
||||
fp.add(submit);
|
||||
|
||||
FormPanel formPanel = new FormPanel();
|
||||
formPanel.addSubmitHandler(new SubmitHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
userManagementService.login(nameText.getText(), pwText.getText(), new AsyncCallback<String>() {
|
||||
public void onSubmit(SubmitEvent event) {
|
||||
userManagementService.login(nameText.getText(), pwText.getText(), new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
@@ -55,24 +66,23 @@ public class LoginEntryPoint implements EntryPoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
if (result != null && !result.equals("")){
|
||||
Window.Location.replace(result);
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
if (result.isSuccessful() && !result.getMessage().equals("")){
|
||||
Window.Location.replace(result.getMessage());
|
||||
}
|
||||
else if (result != null && result.equals("")) {
|
||||
else if (result.isSuccessful()) {
|
||||
Window.alert("Logged in!");
|
||||
}
|
||||
else {
|
||||
Window.alert("Invalid Credentials!");
|
||||
Window.alert(result.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
fp.add(submit);
|
||||
|
||||
dockPanel.add(fp);
|
||||
formPanel.add(fp);
|
||||
dockPanel.add(formPanel);
|
||||
}
|
||||
|
||||
protected void registerASyncService(ServiceDefTarget serviceToRegister, String servicePath) {
|
||||
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
package com.sap.sse.security.ui.loginpanel;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.FormPanel;
|
||||
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
|
||||
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.PasswordTextBox;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.SubmitButton;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
|
||||
public class LoginPanel extends FlowPanel {
|
||||
|
||||
private UserManagementServiceAsync userManagementService = GWT.create(UserManagementService.class);
|
||||
|
||||
private FormPanel loginPanel;
|
||||
private FlowPanel userPanel;
|
||||
private SimplePanel infoPanel;
|
||||
|
||||
private boolean expanded = false;
|
||||
private UserDTO currentUser = null;
|
||||
|
||||
private Label loginTitle1;
|
||||
private Anchor loginLink;
|
||||
private Label loginTitle2;
|
||||
|
||||
private TextBox name;
|
||||
|
||||
private PasswordTextBox password;
|
||||
|
||||
private FlowPanel wrapperPanel;
|
||||
|
||||
public LoginPanel() {
|
||||
registerASyncService((ServiceDefTarget) userManagementService, "service/usermanagement");
|
||||
|
||||
wrapperPanel = new FlowPanel();
|
||||
wrapperPanel.addStyleName("loginPanel");
|
||||
wrapperPanel.addStyleName("loginPanel-collapsed");
|
||||
loginTitle1 = new Label("");
|
||||
loginTitle2 = new Label("");
|
||||
loginLink = new Anchor("Login");
|
||||
loginLink.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (currentUser != null){
|
||||
userManagementService.logout(new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
Window.alert(result.getMessage());
|
||||
currentUser = null;
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
toggleLoginPanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
wrapperPanel.add(loginTitle1);
|
||||
wrapperPanel.add(loginLink);
|
||||
wrapperPanel.add(loginTitle2);
|
||||
infoPanel = new SimplePanel();
|
||||
infoPanel.addStyleName("loginPanel-infoPanel");
|
||||
initLoginContent();
|
||||
initUserContent();
|
||||
infoPanel.setWidget(loginPanel);
|
||||
wrapperPanel.add(infoPanel);
|
||||
add(wrapperPanel);
|
||||
updateUser();
|
||||
}
|
||||
|
||||
private void initLoginContent() {
|
||||
loginPanel = new FormPanel();
|
||||
loginPanel.addSubmitHandler(new SubmitHandler() {
|
||||
|
||||
@Override
|
||||
public void onSubmit(SubmitEvent event) {
|
||||
userManagementService.login(name.getText(), password.getText(), new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
if (result.isSuccessful()) {
|
||||
updateUser();
|
||||
} else {
|
||||
Window.alert(result.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
FlowPanel formContent = new FlowPanel();
|
||||
|
||||
Label nameLabel = new Label("Name: ");
|
||||
formContent.add(nameLabel);
|
||||
name = new TextBox();
|
||||
formContent.add(name);
|
||||
Label passwordLabel = new Label("Password: ");
|
||||
formContent.add(passwordLabel);
|
||||
password = new PasswordTextBox();
|
||||
formContent.add(password);
|
||||
SubmitButton submit = new SubmitButton("Login");
|
||||
formContent.add(submit);
|
||||
|
||||
loginPanel.setWidget(formContent);
|
||||
}
|
||||
|
||||
private void initUserContent() {
|
||||
userPanel = new FlowPanel();
|
||||
}
|
||||
|
||||
private void updateUserContent() {
|
||||
if (currentUser != null) {
|
||||
userPanel.clear();
|
||||
Label name = new Label(currentUser.getName());
|
||||
userPanel.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUser() {
|
||||
userManagementService.getCurrentUser(new AsyncCallback<UserDTO>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(UserDTO result) {
|
||||
currentUser = result;
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
if (currentUser != null) {
|
||||
infoPanel.setWidget(userPanel);
|
||||
loginTitle1.setText("Welcome, " + currentUser.getName() + "! (");
|
||||
loginLink.setText("Logout");
|
||||
loginTitle2.setText(")");
|
||||
updateUserContent();
|
||||
} else {
|
||||
infoPanel.setWidget(loginPanel);
|
||||
loginTitle1.setText("");
|
||||
loginLink.setText("Login");
|
||||
loginTitle2.setText("");
|
||||
}
|
||||
expanded = false;
|
||||
wrapperPanel.addStyleName("loginPanel-collapsed");
|
||||
wrapperPanel.removeStyleName("loginPanel-expanded");
|
||||
}
|
||||
|
||||
private void toggleLoginPanel() {
|
||||
if (expanded) {
|
||||
expanded = false;
|
||||
wrapperPanel.addStyleName("loginPanel-collapsed");
|
||||
wrapperPanel.removeStyleName("loginPanel-expanded");
|
||||
} else {
|
||||
expanded = true;
|
||||
wrapperPanel.addStyleName("loginPanel-expanded");
|
||||
wrapperPanel.removeStyleName("loginPanel-collapsed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void registerASyncService(ServiceDefTarget serviceToRegister, String servicePath) {
|
||||
String moduleBaseURL = GWT.getModuleBaseURL();
|
||||
String baseURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf('/', moduleBaseURL.length()-2)+1);
|
||||
|
||||
serviceToRegister.setServiceEntryPoint(baseURL + servicePath);
|
||||
}
|
||||
}
|
||||
+93
-19
@@ -2,8 +2,9 @@ package com.sap.sse.security.ui.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
@@ -14,9 +15,13 @@ import org.osgi.framework.ServiceReference;
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.ui.Activator;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.userstore.shared.SimpleUser;
|
||||
import com.sap.sse.security.userstore.shared.User;
|
||||
import com.sap.sse.security.userstore.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.shared.UserStore;
|
||||
|
||||
public class UserManagementServiceImpl extends RemoteServiceServlet implements UserManagementService {
|
||||
|
||||
@@ -24,16 +29,14 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
|
||||
private final BundleContext context;
|
||||
private SecurityService securityService;
|
||||
|
||||
|
||||
public UserManagementServiceImpl() {
|
||||
context = Activator.getContext();
|
||||
ServiceReference<?> serviceReference = context.
|
||||
getServiceReference(SecurityService.class.getName());
|
||||
securityService = (SecurityService) context.
|
||||
getService(serviceReference);
|
||||
ServiceReference<?> serviceReference = context.getServiceReference(SecurityService.class.getName());
|
||||
securityService = (SecurityService) context.getService(serviceReference);
|
||||
SecurityUtils.setSecurityManager(securityService.getSecurityManager());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String sayHello() {
|
||||
return "Hello";
|
||||
@@ -42,8 +45,10 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
@Override
|
||||
public Collection<UserDTO> getUserList() {
|
||||
List<UserDTO> users = new ArrayList<>();
|
||||
for (User u : securityService.getUserList()){
|
||||
users.add(new UserDTO(u.getName(), u.getAccountType().getName()));
|
||||
for (User u : securityService.getUserList()) {
|
||||
UserDTO userDTO = new UserDTO(u.getName(), u.getAccountType().getName());
|
||||
userDTO.addRoles(u.getRoles());
|
||||
users.add(userDTO);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
@@ -51,35 +56,104 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
@Override
|
||||
public UserDTO getCurrentUser() {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
if (subject == null){
|
||||
if (subject == null) {
|
||||
return null;
|
||||
}
|
||||
Object principal = subject.getPrincipal();
|
||||
UserDTO userDTO;
|
||||
if (principal != null){
|
||||
if (principal != null) {
|
||||
User u = securityService.getUserByName(principal.toString());
|
||||
userDTO = new UserDTO(u.getName(), u.getAccountType().getName());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
userDTO = null;
|
||||
}
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login(String username, String password) {
|
||||
public SuccessInfo login(String username, String password) {
|
||||
try {
|
||||
return securityService.login(username, password);
|
||||
return new SuccessInfo(true, securityService.login(username, password));
|
||||
} catch (AuthenticationException e) {
|
||||
Logger.getLogger(UserManagementServiceImpl.class.getName()).info("Could not login: " + e);
|
||||
return new SuccessInfo(false, "Failed to login.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() {
|
||||
public SuccessInfo logout() {
|
||||
securityService.logout();
|
||||
return new SuccessInfo(true, "Logged out.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO createSimpleUser(String name, String password) {
|
||||
SimpleUser su = null;
|
||||
try {
|
||||
su = securityService.createSimpleUser(name, password);
|
||||
} catch (UserManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (su == null) {
|
||||
return null;
|
||||
}
|
||||
return new UserDTO(su.getName(), su.getAccountType().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UserDTO> getFilteredSortedUserList(String filter) {
|
||||
List<UserDTO> users = new ArrayList<>();
|
||||
for (User u : securityService.getUserList()) {
|
||||
if (filter != null && !"".equals(filter)) {
|
||||
if (u.getName().contains(filter)) {
|
||||
UserDTO userDTO = new UserDTO(u.getName(), u.getAccountType().getName());
|
||||
userDTO.addRoles(u.getRoles());
|
||||
users.add(userDTO);
|
||||
}
|
||||
} else {
|
||||
UserDTO userDTO = new UserDTO(u.getName(), u.getAccountType().getName());
|
||||
userDTO.addRoles(u.getRoles());
|
||||
users.add(userDTO);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(users, new Comparator<UserDTO>() {
|
||||
|
||||
@Override
|
||||
public int compare(UserDTO u1, UserDTO u2) {
|
||||
return u1.getName().compareTo(u2.getName());
|
||||
}
|
||||
});
|
||||
return users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessInfo addRoleForUser(String username, String role) {
|
||||
Subject currentUser = SecurityUtils.getSubject();
|
||||
|
||||
if (currentUser.hasRole(UserStore.DefaultRoles.ADMIN.getName())) {
|
||||
User u = securityService.getUserByName(username);
|
||||
if (u == null) {
|
||||
return new SuccessInfo(false, "User does not exist.");
|
||||
}
|
||||
try {
|
||||
securityService.addRoleForUser(username, role);
|
||||
return new SuccessInfo(true, "Added role: " + role + ".");
|
||||
} catch (UserManagementException e) {
|
||||
return new SuccessInfo(false, e.getMessage());
|
||||
}
|
||||
} else {
|
||||
return new SuccessInfo(false, "You don't have the required permissions to add a role.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessInfo deleteUser(String username) {
|
||||
try {
|
||||
securityService.deleteUser(username);
|
||||
return new SuccessInfo(true, "Deleted user: " + username + ".");
|
||||
} catch (UserManagementException e) {
|
||||
return new SuccessInfo(false, "Could not delete user.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.sap.sse.security.ui.shared;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class SuccessInfo implements IsSerializable {
|
||||
|
||||
public static final long serialVersionUID = -3044914225885460520L;
|
||||
|
||||
private boolean successful;
|
||||
private String message;
|
||||
|
||||
public SuccessInfo() {
|
||||
}
|
||||
|
||||
public SuccessInfo(boolean successful, String message) {
|
||||
super();
|
||||
this.successful = successful;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
return successful;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+14
@@ -1,5 +1,9 @@
|
||||
package com.sap.sse.security.ui.shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class UserDTO implements IsSerializable {
|
||||
@@ -8,6 +12,8 @@ public class UserDTO implements IsSerializable {
|
||||
private String name;
|
||||
private String accountType;
|
||||
|
||||
private List<String> roles = new ArrayList<>();
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
@@ -32,6 +38,14 @@ public class UserDTO implements IsSerializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void addRoles(Collection<String> roles) {
|
||||
this.roles.addAll(roles);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+10
-2
@@ -10,9 +10,17 @@ public interface UserManagementService extends RemoteService {
|
||||
|
||||
Collection<UserDTO> getUserList();
|
||||
|
||||
Collection<UserDTO> getFilteredSortedUserList(String filter);
|
||||
|
||||
UserDTO getCurrentUser();
|
||||
|
||||
String login(String username, String password);
|
||||
SuccessInfo login(String username, String password);
|
||||
|
||||
void logout();
|
||||
UserDTO createSimpleUser(String name, String password);
|
||||
|
||||
SuccessInfo deleteUser(String username);
|
||||
|
||||
SuccessInfo logout();
|
||||
|
||||
SuccessInfo addRoleForUser(String username, String role);
|
||||
}
|
||||
|
||||
+10
-2
@@ -12,8 +12,16 @@ public interface UserManagementServiceAsync {
|
||||
|
||||
void getCurrentUser(AsyncCallback<UserDTO> callback);
|
||||
|
||||
void login(String username, String password, AsyncCallback<String> callback);
|
||||
void login(String username, String password, AsyncCallback<SuccessInfo> callback);
|
||||
|
||||
void logout(AsyncCallback<Void> callback);
|
||||
void logout(AsyncCallback<SuccessInfo> callback);
|
||||
|
||||
void createSimpleUser(String name, String password, AsyncCallback<UserDTO> callback);
|
||||
|
||||
void getFilteredSortedUserList(String filter, AsyncCallback<Collection<UserDTO>> callback);
|
||||
|
||||
void addRoleForUser(String username, String role, AsyncCallback<SuccessInfo> callback);
|
||||
|
||||
void deleteUser(String username, AsyncCallback<SuccessInfo> callback);
|
||||
|
||||
}
|
||||
|
||||
+114
-28
@@ -1,23 +1,36 @@
|
||||
package com.sap.sse.security.ui.usermanagement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.ServiceDefTarget;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.DockLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.RootLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||
import com.google.gwt.user.client.ui.SimpleLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.view.client.ProvidesKey;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sse.security.ui.client.component.CreateUserPanel;
|
||||
import com.sap.sse.security.ui.client.component.CreateUserPanel.UserCreationEventHandler;
|
||||
import com.sap.sse.security.ui.client.component.UserDetailsView;
|
||||
import com.sap.sse.security.ui.client.component.UserDetailsView.UserChangeEventHandler;
|
||||
import com.sap.sse.security.ui.client.component.UserList;
|
||||
import com.sap.sse.security.ui.client.component.UserListDataProvider;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserManagementService;
|
||||
import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
@@ -25,54 +38,114 @@ import com.sap.sse.security.ui.shared.UserManagementServiceAsync;
|
||||
public class UserManagementEntryPoint implements EntryPoint {
|
||||
|
||||
private final UserManagementServiceAsync userManagementService = GWT.create(UserManagementService.class);
|
||||
|
||||
|
||||
private SimpleLayoutPanel center;
|
||||
|
||||
private TextBox filterBox = new TextBox();
|
||||
|
||||
ProvidesKey<UserDTO> keyProvider = new ProvidesKey<UserDTO>() {
|
||||
public Object getKey(UserDTO item) {
|
||||
// Always do a null check.
|
||||
return (item == null) ? null : item.getName();
|
||||
}
|
||||
};
|
||||
|
||||
private UserListDataProvider userListDataProvider = new UserListDataProvider(userManagementService, filterBox, keyProvider);
|
||||
|
||||
SingleSelectionModel<UserDTO> singleSelectionModel = new SingleSelectionModel<>(keyProvider);
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
registerASyncService((ServiceDefTarget) userManagementService, "service/usermanagement");
|
||||
|
||||
center = new SimpleLayoutPanel();
|
||||
|
||||
RootLayoutPanel rootPanel = RootLayoutPanel.get();
|
||||
DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.EM);
|
||||
DockLayoutPanel dockPanel = new DockLayoutPanel(Unit.PX);
|
||||
rootPanel.add(dockPanel);
|
||||
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
final TextBox textbox = new TextBox();
|
||||
textbox.setText("Not logged in");
|
||||
vp.add(textbox);
|
||||
final Anchor aLogin = new Anchor(new SafeHtmlBuilder().appendEscaped("logout").toSafeHtml(), "/security/ui/Login.html?gwt.codesvr=127.0.0.1:9997");
|
||||
aLogin.addClickHandler(new ClickHandler() {
|
||||
hp.add(textbox);
|
||||
Button logout = new Button("logout");
|
||||
logout.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
userManagementService.logout(new AsyncCallback<Void>() {
|
||||
userManagementService.logout(new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
public void onSuccess(SuccessInfo result) {
|
||||
}
|
||||
});
|
||||
Window.Location.replace("/security/ui/Login.html?gwt.codesvr=127.0.0.1:9997");
|
||||
}
|
||||
});
|
||||
vp.add(aLogin);
|
||||
final UserList userList = new UserList();
|
||||
vp.add(userList);
|
||||
dockPanel.add(vp);
|
||||
|
||||
|
||||
userManagementService.getUserList(new AsyncCallback<Collection<UserDTO>>() {
|
||||
|
||||
hp.add(logout);
|
||||
Button createButton = new Button("Create User", new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Could not load users.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Collection<UserDTO> result) {
|
||||
userList.setRowData(new ArrayList<UserDTO>(result));
|
||||
public void onClick(ClickEvent event) {
|
||||
CreateUserPanel createUserPanel = new CreateUserPanel(userManagementService);
|
||||
createUserPanel.addUserCreationEventHandler(new UserCreationEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onUserCreation(UserDTO user) {
|
||||
userListDataProvider.updateDisplays();
|
||||
if (user != null){
|
||||
singleSelectionModel.setSelected(user, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
center.setWidget(createUserPanel);
|
||||
}
|
||||
});
|
||||
hp.add(createButton);
|
||||
dockPanel.addNorth(hp, 50);
|
||||
|
||||
final UserList userList = new UserList(keyProvider);
|
||||
userList.setSelectionModel(singleSelectionModel);
|
||||
singleSelectionModel.addSelectionChangeHandler(new Handler() {
|
||||
|
||||
@Override
|
||||
public void onSelectionChange(SelectionChangeEvent event) {
|
||||
final UserDetailsView userDetailsView = new UserDetailsView(userManagementService, singleSelectionModel.getSelectedObject());
|
||||
userDetailsView.addUserChangeEventHandler(new UserChangeEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onUserChange(UserDTO user) {
|
||||
userListDataProvider.updateDisplays();
|
||||
}
|
||||
});
|
||||
center.setWidget(userDetailsView);
|
||||
}
|
||||
});
|
||||
userList.setPageSize(4);
|
||||
userListDataProvider.addDataDisplay(userList);
|
||||
SimplePager pager = new SimplePager(TextLocation.CENTER, false, 10, true);
|
||||
pager.setDisplay(userList);
|
||||
ScrollPanel scrollPanel = new ScrollPanel(userList);
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
filterBox.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
userListDataProvider.updateDisplays();
|
||||
}
|
||||
});
|
||||
filterBox.getElement().setPropertyString("placeholder", "Filter users...");
|
||||
vp.add(filterBox);
|
||||
vp.add(pager);
|
||||
vp.add(scrollPanel);
|
||||
dockPanel.addWest(vp, 350);
|
||||
|
||||
|
||||
|
||||
userManagementService.getCurrentUser(new AsyncCallback<UserDTO>() {
|
||||
|
||||
@Override
|
||||
@@ -91,6 +164,19 @@ public class UserManagementEntryPoint implements EntryPoint {
|
||||
}
|
||||
}
|
||||
});
|
||||
dockPanel.add(center);
|
||||
CreateUserPanel createUserPanel = new CreateUserPanel(userManagementService);
|
||||
createUserPanel.addUserCreationEventHandler(new UserCreationEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onUserCreation(UserDTO user) {
|
||||
userListDataProvider.updateDisplays();
|
||||
if (user != null){
|
||||
singleSelectionModel.setSelected(user, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
center.setWidget(createUserPanel);
|
||||
}
|
||||
|
||||
protected void registerASyncService(ServiceDefTarget serviceToRegister, String servicePath) {
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Could not determine the version of your GWT SDK; using the module DTD from GWT 1.6.4. You may want to change this. -->
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module rename-to="login">
|
||||
<module>
|
||||
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
@@ -20,6 +20,7 @@
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
<inherits name="com.google.gwt.logging.Logging"/>
|
||||
|
||||
<inherits name="com.sap.sse.security.ui.LoginPanel"/>
|
||||
|
||||
|
||||
<super-source path="jre" />
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Could not determine the version of your GWT SDK; using the module DTD from GWT 1.6.4. You may want to change this. -->
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
|
||||
<!-- Inherit the core Web Toolkit stuff. -->
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
|
||||
<!-- Inherit the default GWT style sheet. You can change -->
|
||||
<!-- the theme of your GWT application by uncommenting -->
|
||||
<!-- any one of the following lines. -->
|
||||
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
|
||||
<inherits name='com.google.gwt.debug.Debug'/>
|
||||
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
<stylesheet src="../Login.css" />
|
||||
|
||||
|
||||
<inherits name="com.google.gwt.resources.Resources" />
|
||||
<inherits name="com.google.gwt.logging.Logging"/>
|
||||
|
||||
|
||||
|
||||
<super-source path="jre" />
|
||||
|
||||
<set-property name="gwt.logging.enabled" value="TRUE"/>
|
||||
<set-property name="gwt.logging.logLevel" value="FINE"/>
|
||||
|
||||
<set-property name="gwt.logging.firebugHandler" value="ENABLED" />
|
||||
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
|
||||
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
|
||||
<set-property name="gwt.logging.developmentModeHandler" value="DISABLED" />
|
||||
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
|
||||
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<extend-property name="locale" values="de"/>
|
||||
<source path='loginpanel'/>
|
||||
<source path='shared'/>
|
||||
</module>
|
||||
+54
-11
@@ -2,6 +2,7 @@ package com.sap.sse.security.userstore.mongodb;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.shiro.crypto.RandomNumberGenerator;
|
||||
@@ -10,6 +11,7 @@ import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
|
||||
import com.sap.sse.security.userstore.shared.SimpleUser;
|
||||
import com.sap.sse.security.userstore.shared.User;
|
||||
import com.sap.sse.security.userstore.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.shared.UserStore;
|
||||
|
||||
|
||||
@@ -19,9 +21,18 @@ public class UserStoreImpl implements UserStore {
|
||||
|
||||
public UserStoreImpl() {
|
||||
users = new ConcurrentHashMap<>();
|
||||
createUser("Ben", "ben123");
|
||||
createUser("Peter", "peter123");
|
||||
createUser("Hans", "hans123");
|
||||
try {
|
||||
createSimpleUser("Ben", "ben123");
|
||||
addRoleForUser("Ben", "admin");
|
||||
addRoleForUser("Ben", "moderator");
|
||||
createSimpleUser("Peter", "peter123");
|
||||
addRoleForUser("Peter", "moderator");
|
||||
createSimpleUser("Hans", "hans123");
|
||||
createSimpleUser("Hubert", "hubert123");
|
||||
createSimpleUser("Franz", "franz123");
|
||||
} catch (UserManagementException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,33 +41,33 @@ public class UserStoreImpl implements UserStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createUser(String name, String password) {
|
||||
public SimpleUser createSimpleUser(String name, String password) throws UserManagementException {
|
||||
if (users.get(name) != null){
|
||||
return false; // This user already exists
|
||||
throw new UserManagementException(UserManagementException.USER_ALREADY_EXISTS);
|
||||
}
|
||||
if (name == null || password == null || name.length() < 3 || password.length() < 5){
|
||||
return false; //Invalid credentials
|
||||
throw new UserManagementException(UserManagementException.INVALID_CREDENTIALS);
|
||||
}
|
||||
RandomNumberGenerator rng = new SecureRandomNumberGenerator();
|
||||
Object salt = rng.nextBytes();
|
||||
String hashedPasswordBase64 = new Sha256Hash(password, salt, 1024).toBase64();
|
||||
SimpleUser user = new SimpleUser(name, hashedPasswordBase64, salt);
|
||||
users.put(name, user);
|
||||
return true;
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSalt(String name) {
|
||||
public Object getSalt(String name) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
return null;
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
return users.get(name).getSalt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSaltedPassword(String name) {
|
||||
public String getSaltedPassword(String name) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
return null;
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
return users.get(name).getSaltedPassword();
|
||||
}
|
||||
@@ -71,4 +82,36 @@ public class UserStoreImpl implements UserStore {
|
||||
return users.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRolesFromUser(String name) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
return users.get(name).getRoles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRoleForUser(String name, String role) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
users.get(name).addRole(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoleFromUser(String name, String role) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
users.get(name).removeRole(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String name) throws UserManagementException {
|
||||
if (users.get(name) == null){
|
||||
throw new UserManagementException(UserManagementException.USER_DOES_NOT_EXIST);
|
||||
}
|
||||
users.remove(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
@@ -1,9 +1,14 @@
|
||||
package com.sap.sse.security.userstore.shared;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class User {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected Set<String> roles = new HashSet<>();
|
||||
|
||||
public User(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
@@ -17,6 +22,18 @@ public abstract class User {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void addRole(String role){
|
||||
roles.add(role);
|
||||
}
|
||||
|
||||
public void removeRole(String role){
|
||||
roles.remove(role);
|
||||
}
|
||||
|
||||
public abstract AccountType getAccountType();
|
||||
|
||||
public enum AccountType {
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.sap.sse.security.userstore.shared;
|
||||
|
||||
public class UserManagementException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 7555799541580565866L;
|
||||
|
||||
public static final String USER_DOES_NOT_EXIST = "User does not exist.";
|
||||
public static final String USER_ALREADY_EXISTS = "User already exists.";
|
||||
public static final String INVALID_CREDENTIALS = "Invalid Credentials.";
|
||||
|
||||
public UserManagementException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UserManagementException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
+26
-4
@@ -1,19 +1,41 @@
|
||||
package com.sap.sse.security.userstore.shared;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public interface UserStore {
|
||||
|
||||
String getName();
|
||||
|
||||
boolean createUser(String name, String password);
|
||||
Object getSalt(String name) throws UserManagementException;
|
||||
|
||||
Object getSalt(String name);
|
||||
|
||||
String getSaltedPassword(String name);
|
||||
String getSaltedPassword(String name) throws UserManagementException;
|
||||
|
||||
Collection<User> getUserCollection();
|
||||
|
||||
User getUserByName(String name);
|
||||
|
||||
SimpleUser createSimpleUser(String name, String password) throws UserManagementException;
|
||||
|
||||
Set<String> getRolesFromUser(String name) throws UserManagementException;
|
||||
|
||||
void addRoleForUser(String name, String role) throws UserManagementException;
|
||||
void removeRoleFromUser(String name, String role) throws UserManagementException;
|
||||
|
||||
void deleteUser(String name) throws UserManagementException;
|
||||
|
||||
public static enum DefaultRoles {
|
||||
ADMIN("admin");
|
||||
|
||||
private final String name;
|
||||
|
||||
private DefaultRoles(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-collections-3.2.1.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.3.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/slf4j-simple-1.7.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/scribe-1.3.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/shiro-core-1.2.2.jar" sourcepath="C:/Users/D056866/Downloads/shiro-root-1.2.2-source-release.zip"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/shiro-web-1.2.2.jar" sourcepath="C:/Users/D056866/Downloads/shiro-root-1.2.2-source-release.zip"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/org.apache.servicemix.bundles.scribe-1.3.3_1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -8,22 +8,22 @@ Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Import-Package: org.osgi.framework;version="1.3.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: lib/scribe-1.3.5.jar,
|
||||
lib/shiro-core-1.2.2.jar,
|
||||
Bundle-ClassPath: lib/shiro-core-1.2.2.jar,
|
||||
lib/shiro-web-1.2.2.jar,
|
||||
.,
|
||||
lib/slf4j-api-1.7.5.jar,
|
||||
lib/slf4j-simple-1.7.5.jar,
|
||||
lib/commons-beanutils-1.9.0.jar,
|
||||
lib/commons-logging-1.1.3.jar,
|
||||
lib/commons-collections-3.2.1.jar
|
||||
lib/commons-collections-3.2.1.jar,
|
||||
lib/org.apache.servicemix.bundles.scribe-1.3.3_1.jar
|
||||
Require-Bundle: javax.servlet;bundle-version="2.5.0",
|
||||
com.sap.sse.security.userstore;bundle-version="1.0.0",
|
||||
com.google.gwt.osgi
|
||||
com.google.gwt.osgi,
|
||||
slf4j.api;bundle-version="1.6.4"
|
||||
Web-ContextPath: /security
|
||||
Export-Package: com.sap.sse.security,
|
||||
org.apache.shiro,
|
||||
org.apache.shiro.authc,
|
||||
org.apache.shiro.authz.annotation,
|
||||
org.apache.shiro.crypto,
|
||||
org.apache.shiro.crypto.hash,
|
||||
org.apache.shiro.subject,
|
||||
|
||||
@@ -2,12 +2,10 @@ source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
lib/scribe-1.3.5.jar,\
|
||||
lib/shiro-core-1.2.2.jar,\
|
||||
lib/shiro-web-1.2.2.jar,\
|
||||
lib/slf4j-api-1.7.5.jar,\
|
||||
lib/slf4j-simple-1.7.5.jar,\
|
||||
WEB-INF/,\
|
||||
lib/commons-beanutils-1.9.0.jar,\
|
||||
lib/commons-collections-3.2.1.jar,\
|
||||
lib/commons-logging-1.1.3.jar,\
|
||||
lib/commons-collections-3.2.1.jar
|
||||
lib/org.apache.servicemix.bundles.scribe-1.3.3_1.jar,\
|
||||
lib/shiro-core-1.2.2.jar,\
|
||||
lib/shiro-web-1.2.2.jar
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,11 +4,8 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
|
||||
import com.sap.sse.security.userstore.shared.UserStore;
|
||||
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
private static BundleContext context;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.sap.sse.security;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
|
||||
import com.sap.sse.security.userstore.shared.SimpleUser;
|
||||
import com.sap.sse.security.userstore.shared.User;
|
||||
import com.sap.sse.security.userstore.shared.UserManagementException;
|
||||
|
||||
public interface SecurityService {
|
||||
|
||||
@@ -15,7 +18,16 @@ public interface SecurityService {
|
||||
|
||||
User getUserByName(String name);
|
||||
|
||||
String login(String username, String password);
|
||||
String login(String username, String password) throws AuthenticationException;
|
||||
|
||||
void logout();
|
||||
|
||||
SimpleUser createSimpleUser(String name, String password) throws UserManagementException;
|
||||
|
||||
void deleteUser(String username) throws UserManagementException;
|
||||
|
||||
Set<String> getRolesFromUser(String name) throws UserManagementException;
|
||||
|
||||
void addRoleForUser(String name, String role) throws UserManagementException;
|
||||
void removeRoleFromUser(String name, String role) throws UserManagementException;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.sap.sse.security;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.config.IniSecurityManagerFactory;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
@@ -17,7 +19,9 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.sap.sse.security.userstore.shared.SimpleUser;
|
||||
import com.sap.sse.security.userstore.shared.User;
|
||||
import com.sap.sse.security.userstore.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.shared.UserStore;
|
||||
|
||||
public class SecurityServiceImpl extends RemoteServiceServlet implements SecurityService {
|
||||
@@ -53,7 +57,7 @@ public class SecurityServiceImpl extends RemoteServiceServlet implements Securi
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login(String username, String password) {
|
||||
public String login(String username, String password) throws AuthenticationException {
|
||||
String redirectUrl;
|
||||
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
|
||||
System.out.println("Trying to login: " + username);
|
||||
@@ -83,4 +87,29 @@ public class SecurityServiceImpl extends RemoteServiceServlet implements Securi
|
||||
return store.getUserByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleUser createSimpleUser(String name, String password) throws UserManagementException {
|
||||
return store.createSimpleUser(name, password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRolesFromUser(String name) throws UserManagementException {
|
||||
return store.getRolesFromUser(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRoleForUser(String name, String role) throws UserManagementException {
|
||||
store.addRoleForUser(name, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRoleFromUser(String name, String role) throws UserManagementException {
|
||||
store.removeRoleFromUser(name, role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser(String username) throws UserManagementException {
|
||||
store.deleteUser(username);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.sap.sse.security;
|
||||
|
||||
import org.apache.shiro.authc.SaltedAuthenticationInfo;
|
||||
import org.apache.shiro.codec.Base64;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.util.ByteSource;
|
||||
import org.apache.shiro.util.SimpleByteSource;
|
||||
|
||||
public class SimpleSaltedAuthenticationInfo implements SaltedAuthenticationInfo {
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.sap.sse.security;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
import org.apache.shiro.authc.AuthenticationToken;
|
||||
@@ -13,6 +16,7 @@ import org.apache.shiro.util.ByteSource;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
import com.sap.sse.security.userstore.shared.UserManagementException;
|
||||
import com.sap.sse.security.userstore.shared.UserStore;
|
||||
|
||||
public class UsernamePasswordRealm extends AuthorizingRealm {
|
||||
@@ -29,8 +33,18 @@ public class UsernamePasswordRealm extends AuthorizingRealm {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
SimpleAuthorizationInfo ai = new SimpleAuthorizationInfo();
|
||||
List<String> roles = new ArrayList<>();
|
||||
for (Object r : principals.asList()){
|
||||
String name = r.toString();
|
||||
try {
|
||||
roles.addAll(store.getRolesFromUser(name));
|
||||
} catch (UserManagementException e) {
|
||||
throw new AuthenticationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
ai.addRoles(roles);
|
||||
return ai;
|
||||
}
|
||||
|
||||
@@ -44,12 +58,22 @@ public class UsernamePasswordRealm extends AuthorizingRealm {
|
||||
}
|
||||
|
||||
// read password hash and salt from db
|
||||
final String saltedPassword = store.getSaltedPassword(username);
|
||||
String saltedPassword = null;
|
||||
try {
|
||||
saltedPassword = store.getSaltedPassword(username);
|
||||
} catch (UserManagementException e) {
|
||||
throw new AuthenticationException(e.getMessage());
|
||||
}
|
||||
if (saltedPassword == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ByteSource salt = (ByteSource) store.getSalt(username);
|
||||
ByteSource salt = null;
|
||||
try {
|
||||
salt = (ByteSource) store.getSalt(username);
|
||||
} catch (UserManagementException e) {
|
||||
throw new AuthenticationException(e.getMessage());
|
||||
}
|
||||
if (salt == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user