Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
RoiArthurB
openmole
Commits
4ee59e68
Commit
4ee59e68
authored
Mar 11, 2016
by
Mathieu Leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GUI] Fix authentications
parent
7b76616a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
174 additions
and
157 deletions
+174
-157
openmole/gui/client/org.openmole.gui.client.core/src/main/scala/org/openmole/gui/client/core/authentications/EGIP12AuthenticationPanel.scala
...ient/core/authentications/EGIP12AuthenticationPanel.scala
+0
-1
openmole/gui/client/org.openmole.gui.client.core/src/main/scala/org/openmole/gui/client/core/authentications/package.scala
...rg/openmole/gui/client/core/authentications/package.scala
+5
-1
openmole/gui/ext/org.openmole.gui.ext.data/src/main/scala/org/openmole/gui/ext/data/Factory.scala
...ta/src/main/scala/org/openmole/gui/ext/data/Factory.scala
+0
-33
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/ApiImpl.scala
...src/main/scala/org/openmole/gui/server/core/ApiImpl.scala
+3
-5
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/AuthenticationFactories.scala
...rg/openmole/gui/server/core/AuthenticationFactories.scala
+159
-0
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/CoreFactory.scala
...main/scala/org/openmole/gui/server/core/CoreFactory.scala
+0
-34
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/ServerFactories.scala
.../scala/org/openmole/gui/server/core/ServerFactories.scala
+0
-77
openmole/project/src/main/scala/root/gui/GuiClient.scala
openmole/project/src/main/scala/root/gui/GuiClient.scala
+5
-5
openmole/project/src/main/scala/root/gui/GuiServer.scala
openmole/project/src/main/scala/root/gui/GuiServer.scala
+2
-1
No files found.
openmole/gui/client/org.openmole.gui.client.core/src/main/scala/org/openmole/gui/client/core/authentications/EGIP12AuthenticationPanel.scala
View file @
4ee59e68
...
...
@@ -31,7 +31,6 @@ import scalatags.JsDom.tags
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@JSExport
(
"org.openmole.gui.plugin.environment.egi.client.EGIP12AuthenticationPanelUI"
)
class
EGIP12AuthenticationPanel
(
data
:
EGIP12AuthenticationData
)
extends
PanelUI
{
val
password
=
bs
.
input
(
data
.
cypheredPassword
,
key
(
"spacer5"
))(
...
...
openmole/gui/client/org.openmole.gui.client.core/src/main/scala/org/openmole/gui/client/core/authentications/package.scala
View file @
4ee59e68
...
...
@@ -29,7 +29,11 @@ package object authentications {
}
def
panelWithID
(
data
:
AuthenticationData
)
=
new
PanelWithID
{
val
name
=
data
.
synthetic
val
name
=
data
match
{
case
e
:
EGIP12AuthenticationData
⇒
"
EGI
P12
certificate
"
case
lp:
LoginPasswordAuthenticationData
⇒
"
SSH
login/password
"
case
_
⇒
"
SSH
key
"
}
val
panel
:
PanelUI
=
authentications
.
panel
(
data
)
}
...
...
openmole/gui/ext/org.openmole.gui.ext.data/src/main/scala/org/openmole/gui/ext/data/Factory.scala
deleted
100644 → 0
View file @
7b76616a
package
org.openmole.gui.ext.data
/*
* Copyright (C) 13/02/15 // mathieu.leclaire@openmole.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
scala.util.Try
trait
Factory
trait
CoreObjectFactory
extends
Factory
{
def
coreObject
()
:
Try
[
Any
]
}
trait
AuthenticationFactory
extends
Factory
{
def
coreObject
(
data
:
AuthenticationData
)
:
Option
[
Any
]
def
buildAuthentication
(
data
:
AuthenticationData
)
:
Unit
def
allAuthenticationData
:
Seq
[
AuthenticationData
]
def
removeAuthentication
(
data
:
AuthenticationData
)
:
Unit
}
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/ApiImpl.scala
View file @
4ee59e68
...
...
@@ -52,13 +52,11 @@ object ApiImpl extends Api {
implicit
def
authProvider
=
Workspace
.
authenticationProvider
//AUTHENTICATIONS
def
addAuthentication
(
data
:
AuthenticationData
)
:
Unit
=
ServerFactories
.
a
uthenticationFactories
(
data
.
getClass
).
buil
dAuthentication
(
data
)
def
addAuthentication
(
data
:
AuthenticationData
)
:
Unit
=
A
uthenticationFactories
.
ad
dAuthentication
(
data
)
def
authentications
()
:
Seq
[
AuthenticationData
]
=
ServerFactories
.
authenticationFactories
.
values
.
flatMap
{
_
.
allAuthenticationData
}.
toSeq
def
authentications
()
:
Seq
[
AuthenticationData
]
=
AuthenticationFactories
.
allAuthentications
def
removeAuthentication
(
data
:
AuthenticationData
)
=
ServerFactories
.
a
uthenticationFactories
(
data
.
getClass
)
.
removeAuthentication
(
data
)
def
removeAuthentication
(
data
:
AuthenticationData
)
=
A
uthenticationFactories
.
removeAuthentication
(
data
)
//WORKSPACE
def
isPasswordCorrect
(
pass
:
String
)
:
Boolean
=
Workspace
.
passwordIsCorrect
(
pass
)
...
...
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/AuthenticationFactories.scala
0 → 100644
View file @
4ee59e68
package
org.openmole.gui.server.core
/*
* Copyright (C) 24/09/14 // mathieu.leclaire@openmole.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
org.openmole.core.workspace.Workspace
import
org.openmole.gui.ext.data._
import
org.openmole.gui.server.core.Utils._
import
org.openmole.plugin.environment.egi.
{
EGIAuthentication
,
P12Certificate
}
import
org.openmole.plugin.environment.ssh.
{
PrivateKey
,
SSHAuthentication
,
LoginPassword
}
object
AuthenticationFactories
{
implicit
def
dataToFactory
(
data
:
AuthenticationData
)
:
AuthenticationFactory
=
data
match
{
case
e
:
EGIP12AuthenticationData
⇒
EGIP12Factory
case
l
:
LoginPasswordAuthenticationData
⇒
SSHLoginPasswordFactory
case
_
⇒
SSHPrivateKeyFactory
}
def
addAuthentication
(
data
:
AuthenticationData
)
=
data
.
buildAuthentication
(
data
)
def
allAuthentications
(
data
:
AuthenticationData
)
=
data
.
allAuthenticationData
def
allAuthentications
=
EGIP12Factory
.
allAuthenticationData
++
SSHLoginPasswordFactory
.
allAuthenticationData
++
SSHPrivateKeyFactory
.
allAuthenticationData
def
removeAuthentication
(
data
:
AuthenticationData
)
=
data
.
removeAuthentication
(
data
)
trait
AuthenticationFactory
{
def
coreObject
(
data
:
AuthenticationData
)
:
Option
[
Any
]
def
buildAuthentication
(
data
:
AuthenticationData
)
:
Unit
def
allAuthenticationData
:
Seq
[
AuthenticationData
]
def
removeAuthentication
(
data
:
AuthenticationData
)
:
Unit
}
object
EGIP12Factory
extends
AuthenticationFactory
{
implicit
def
authProvider
=
Workspace
.
authenticationProvider
def
buildAuthentication
(
data
:
AuthenticationData
)
=
{
val
auth
=
coreObject
(
data
)
auth
.
foreach
{
a
⇒
EGIAuthentication
.
update
(
a
)
}
}
def
allAuthenticationData
:
Seq
[
AuthenticationData
]
=
{
EGIAuthentication
()
match
{
case
Some
(
p12
:
P12Certificate
)
⇒
Seq
(
EGIP12AuthenticationData
(
Workspace
.
decrypt
(
p12
.
cypheredPassword
),
Some
(
p12
.
certificate
.
getName
)
))
case
x
:
Any
⇒
Seq
()
}
}
def
coreObject
(
data
:
AuthenticationData
)
:
Option
[
P12Certificate
]
=
data
match
{
case
p12
:
EGIP12AuthenticationData
⇒
p12.privateKey
match
{
case
Some
(
pk:
String
)
⇒
Some
(
P12Certificate
(
Workspace.encrypt
(
p12.cypheredPassword
),
authenticationFile
(
pk
)
))
case
_
⇒
None
}
case
_
⇒
None
}
def
removeAuthentication
(
data
:
AuthenticationData
)
=
EGIAuthentication
.
clear
}
object
SSHLoginPasswordFactory
extends
AuthenticationFactory
{
implicit
def
authProvider
=
Workspace
.
authenticationProvider
def
buildAuthentication
(
data
:
AuthenticationData
)
=
{
val
auth
=
coreObject
(
data
)
auth
.
map
{
a
⇒
SSHAuthentication
+=
a
}
}
def
allAuthenticationData
:
Seq
[
AuthenticationData
]
=
SSHAuthentication
().
flatMap
{
_
match
{
case
lp
:
LoginPassword
⇒
Some
(
LoginPasswordAuthenticationData
(
lp.login
,
Workspace.decrypt
(
lp.cypheredPassword
),
lp.target
))
case
_
⇒
None
}
}
def
coreObject
(
data
:
AuthenticationData
)
:
Option
[
LoginPassword
]
=
data
match
{
case
lp
:
LoginPasswordAuthenticationData
⇒
Some
(
LoginPassword
(
lp.login
,
Workspace.encrypt
(
lp.cypheredPassword
),
lp.target
))
case
_
⇒
None
}
def
removeAuthentication
(
data
:
AuthenticationData
)
=
coreObject
(
data
).
map
{
e
⇒
SSHAuthentication
-=
e
}
}
object
SSHPrivateKeyFactory
extends
AuthenticationFactory
{
implicit
def
authProvider
=
Workspace
.
authenticationProvider
def
buildAuthentication
(
data
:
AuthenticationData
)
=
{
val
auth
=
coreObject
(
data
)
auth
.
map
{
a
⇒
SSHAuthentication
+=
a
}
}
def
allAuthenticationData
:
Seq
[
AuthenticationData
]
=
SSHAuthentication
().
flatMap
{
_
match
{
case
key
:
PrivateKey
⇒
Some
(
PrivateKeyAuthenticationData
(
Some
(
key.privateKey.getName
),
key.login
,
Workspace.decrypt
(
key.cypheredPassword
),
key
.
target
))
case
_
⇒
None
}
}
def
coreObject
(
data
:
AuthenticationData
)
:
Option
[
PrivateKey
]
=
data
match
{
case
keyData
:
PrivateKeyAuthenticationData
⇒
keyData.privateKey
match
{
case
Some
(
pk:
String
)
⇒
Some
(
PrivateKey
(
authenticationFile
(
pk
),
keyData.login
,
Workspace.encrypt
(
keyData.cypheredPassword
),
keyData.target
))
case
_
⇒
None
}
case
_
⇒
None
}
def
removeAuthentication
(
data
:
AuthenticationData
)
=
coreObject
(
data
).
map
{
e
⇒
SSHAuthentication
-=
e
}
}
}
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/CoreFactory.scala
deleted
100644 → 0
View file @
7b76616a
package
org.openmole.gui.server.core
import
org.openmole.gui.ext.data.
{
DataBag
,
ErrorData
}
import
scala.util.Failure
/*
* Copyright (C) 26/09/14 // mathieu.leclaire@openmole.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
object
CoreFactory
{
def
check
(
dataBag
:
Seq
[
DataBag
])
:
Seq
[
ErrorData
]
=
{
dataBag
.
map
{
d
⇒
d
->
ServerFactories
.
coreObject
(
d
)
}.
collect
{
case
(
data
:
DataBag
,
f
:
Failure
[
_
])
⇒
ErrorData
(
data
,
f
.
exception
.
getMessage
,
f
.
exception
.
getStackTrace
.
mkString
(
"\n"
))
}
}
// def prototype(prototypeData: PrototypeData): Prototype[_] =
}
openmole/gui/server/org.openmole.gui.server.core/src/main/scala/org/openmole/gui/server/core/ServerFactories.scala
deleted
100644 → 0
View file @
7b76616a
package
org.openmole.gui.server.core
/*
* Copyright (C) 24/09/14 // mathieu.leclaire@openmole.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
org.openmole.gui.ext.data._
import
org.openmole.gui.ext.dataui.
{
FactoryWithPanelUI
,
FactoryWithDataUI
}
import
scala.collection.mutable
import
scala.util.
{
Failure
,
Try
}
object
ServerFactories
{
lazy
private
val
instance
=
new
ServerFactories
def
coreObject
(
dataBag
:
DataBag
)
:
Try
[
Any
]
=
instance
.
factories
.
synchronized
{
instance
.
factories
.
get
(
dataBag
.
data
.
getClass
())
match
{
case
Some
(
f
:
CoreObjectFactory
)
⇒
f
.
coreObject
()
case
_
⇒
Failure
(
new
Throwable
(
"The data "
+
dataBag
.
name
+
" cannot be recontructed on the server."
))
}
}
def
coreObject
(
className
:
String
)
:
Try
[
Any
]
=
instance
.
factories
.
synchronized
{
instance
.
factories
.
filterKeys
(
_
==
Class
.
forName
(
className
)).
headOption
.
map
{
_
.
_2
}
match
{
case
Some
(
f
:
CoreObjectFactory
)
⇒
f
.
coreObject
()
case
_
⇒
Failure
(
new
Throwable
(
"The data "
+
className
+
" cannot be recontructed on the server."
))
}
}
def
add
(
dataClass
:
Class
[
_
],
factory
:
Factory
,
factoryUI
:
FactoryWithDataUI
)
=
instance
.
factories
.
synchronized
{
instance
.
factories
+=
dataClass
->
factory
instance
.
factoriesUI
+=
dataClass
.
getName
->
factoryUI
}
def
addAuthenticationFactory
(
dataClass
:
Class
[
_
],
factory
:
AuthenticationFactory
,
factoryUI
:
FactoryWithPanelUI
)
=
instance
.
authenticationFactoriesUI
.
synchronized
{
instance
.
authenticationFactories
+=
dataClass
->
factory
instance
.
authenticationFactoriesUI
+=
dataClass
.
getName
->
factoryUI
}
def
remove
(
dataClass
:
Class
[
_
])
=
instance
.
factories
.
synchronized
{
instance
.
factories
-=
dataClass
instance
.
factoriesUI
-=
dataClass
.
getName
}
def
removeAuthenticationFactory
(
dataClass
:
Class
[
_
])
=
instance
.
authenticationFactoriesUI
.
synchronized
{
instance
.
authenticationFactories
-=
dataClass
instance
.
authenticationFactoriesUI
-=
dataClass
.
getName
}
def
factories
=
instance
.
factories
.
toMap
def
factoriesUI
=
instance
.
factoriesUI
.
toMap
def
authenticationFactories
=
instance
.
authenticationFactories
.
toMap
def
authenticationFactoriesUI
=
instance
.
authenticationFactoriesUI
.
toMap
}
class
ServerFactories
{
val
factories
=
new
mutable
.
WeakHashMap
[
Class
[
_
]
,
Factory
]
val
factoriesUI
=
new
mutable
.
WeakHashMap
[
String
,
FactoryWithDataUI
]
val
authenticationFactories
=
new
mutable
.
WeakHashMap
[
Class
[
_
]
,
AuthenticationFactory
]
val
authenticationFactoriesUI
=
new
mutable
.
WeakHashMap
[
String
,
FactoryWithPanelUI
]
}
openmole/project/src/main/scala/root/gui/GuiClient.scala
View file @
4ee59e68
...
...
@@ -14,16 +14,16 @@ object Client extends GuiDefaults {
val
acePath
=
s
"META-INF/resources/webjars/ace/$aceVersion/src-min/ace.js"
lazy
val
core
=
OsgiProject
(
"org.openmole.gui.client.core"
)
enablePlugins
(
ScalaJSPlugin
)
dependsOn
(
Ext
.
dataui
,
Shared
.
shared
,
Misc
.
utils
,
Misc
.
js
,
root
.
Doc
.
doc
)
settings
(
(
Ext
.
dataui
,
Shared
.
shared
,
Misc
.
utils
,
Misc
.
js
,
root
.
Doc
.
doc
)
settings
(
libraryDependencies
++=
Seq
(
autowire
,
upickle
,
scalaTags
,
rx
,
scalajsDom
,
scaladget
,
async
),
skip
in
packageJSDependencies
:=
false
,
jsDependencies
+=
jquery
/
jqueryPath
,
jsDependencies
+=
jquery
/
jqueryPath
minified
jqueryPath
.
replace
(
".js"
,
".min.js"
)
,
jsDependencies
+=
ace
/
acePath
,
jsDependencies
+=
ace
/
"src-min/mode-sh.js"
dependsOn
acePath
,
jsDependencies
+=
ace
/
"src-min/mode-scala.js"
dependsOn
acePath
,
jsDependencies
+=
ace
/
"src-min/theme-github.js"
dependsOn
acePath
,
jsDependencies
+=
bootstrap
/
"js/bootstrap.
min.
js"
dependsOn
jqueryPath
,
jsDependencies
+=
d3
/
"d3.
min.
js"
dependsOn
jqueryPath
,
jsDependencies
+=
tooltipster
/
"js/jquery.tooltipster.
min.
js"
dependsOn
jqueryPath
jsDependencies
+=
bootstrap
/
"js/bootstrap.js"
dependsOn
jqueryPath
minified
"js/bootstrap.min.js"
,
jsDependencies
+=
d3
/
"d3.js"
dependsOn
jqueryPath
minified
"d3.min.js"
,
jsDependencies
+=
tooltipster
/
"js/jquery.tooltipster.js"
dependsOn
jqueryPath
minified
"js/jquery.tooltipster.min.js"
)
}
\ No newline at end of file
openmole/project/src/main/scala/root/gui/GuiServer.scala
View file @
4ee59e68
...
...
@@ -7,7 +7,6 @@ import sbt._
import
root._
import
root.Libraries._
import
sbt.Keys._
import
com.typesafe.sbt.osgi.OsgiKeys._
import
ThirdParties._
object
Server
extends
GuiDefaults
{
...
...
@@ -28,6 +27,8 @@ object Server extends GuiDefaults {
root
.
Runtime
.
console
,
Core
.
dsl
,
Core
.
batch
,
_root_
.
plugin
.
Environment
.
egi
,
_root_
.
plugin
.
Environment
.
ssh
,
Misc
.
utils
,
ThirdParties
.
openmoleStream
,
openmoleCrypto
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment