Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
ee52ef2b
Commit
ee52ef2b
authored
Nov 21, 2019
by
michael.simon
Browse files
create migration workflow and make scope configurable
parent
f4d4b630
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/nextcloud/NextcloudWorker.java
View file @
ee52ef2b
...
...
@@ -65,9 +65,9 @@ public class NextcloudWorker {
this
.
auditor
=
auditor
;
try
{
apiUrl
=
prop
.
readProp
(
"api_url"
);
apiUsername
=
prop
.
readProp
(
"api_username"
);
apiPassword
=
prop
.
readProp
(
"api_password"
);
apiUrl
=
prop
.
readProp
(
"
nc_
api_url"
);
apiUsername
=
prop
.
readProp
(
"
nc_
api_username"
);
apiPassword
=
prop
.
readProp
(
"
nc_
api_password"
);
}
catch
(
PropertyReaderException
e
)
{
throw
new
RegisterException
(
e
);
}
...
...
bwreg-service/src/main/java/edu/kit/scc/syncshare/reg/NextcloudProxyIdpRegisterWorkflow.java
View file @
ee52ef2b
...
...
@@ -66,8 +66,25 @@ public class NextcloudProxyIdpRegisterWorkflow implements RegisterUserWorkflow,
public
void
registerUser
(
UserEntity
user
,
ServiceEntity
service
,
RegistryEntity
registry
,
Auditor
auditor
)
throws
RegisterException
{
updateRegistry
(
user
,
service
,
registry
,
auditor
);
reconciliation
(
user
,
service
,
registry
,
auditor
);
PropertyReader
prop
=
PropertyReader
.
newRegisterPropReader
(
service
);
String
idKey
=
"nextcloud_user_id"
;
if
(
prop
.
readPropOrNull
(
"id_key"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_key"
);
}
String
scope
=
"bwidm.scc.kit.edu"
;
if
(
prop
.
readPropOrNull
(
"id_scope"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_scope"
);
}
if
(!
user
.
getGenericStore
().
containsKey
(
idKey
))
{
user
.
getGenericStore
().
put
(
idKey
,
UUID
.
randomUUID
().
toString
()
+
"@"
+
scope
);
logger
.
debug
(
"Generating new {} for user {}: {}"
,
idKey
,
user
.
getId
(),
user
.
getGenericStore
().
get
(
idKey
));
}
if
(!
registry
.
getRegistryValues
().
containsKey
(
"id"
))
{
registry
.
getRegistryValues
().
put
(
"id"
,
user
.
getGenericStore
().
get
(
idKey
));
}
}
@Override
...
...
@@ -85,21 +102,6 @@ public class NextcloudProxyIdpRegisterWorkflow implements RegisterUserWorkflow,
@Override
public
Boolean
updateRegistry
(
UserEntity
user
,
ServiceEntity
service
,
RegistryEntity
registry
,
Auditor
auditor
)
throws
RegisterException
{
PropertyReader
prop
=
PropertyReader
.
newRegisterPropReader
(
service
);
String
idKey
=
"nextcloud_user_id"
;
if
(
prop
.
readPropOrNull
(
"id_key"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_key"
);
}
if
(!
user
.
getGenericStore
().
containsKey
(
idKey
))
{
user
.
getGenericStore
().
put
(
idKey
,
UUID
.
randomUUID
().
toString
()
+
"@bwidm.de"
);
}
if
(!
registry
.
getRegistryValues
().
containsKey
(
"id"
))
{
registry
.
getRegistryValues
().
put
(
"id"
,
user
.
getGenericStore
().
get
(
idKey
));
}
return
false
;
}
}
bwreg-service/src/main/java/edu/kit/scc/syncshare/reg/PfNcMigrationRegisterWorkflow.java
0 → 100644
View file @
ee52ef2b
package
edu.kit.scc.syncshare.reg
;
import
java.util.UUID
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
edu.kit.scc.nextcloud.NextcloudAnswer
;
import
edu.kit.scc.nextcloud.NextcloudWorker
;
import
edu.kit.scc.webreg.audit.Auditor
;
import
edu.kit.scc.webreg.entity.RegistryEntity
;
import
edu.kit.scc.webreg.entity.ServiceEntity
;
import
edu.kit.scc.webreg.entity.UserEntity
;
import
edu.kit.scc.webreg.exc.RegisterException
;
import
edu.kit.scc.webreg.service.reg.Infotainment
;
import
edu.kit.scc.webreg.service.reg.InfotainmentCapable
;
import
edu.kit.scc.webreg.service.reg.InfotainmentTreeNode
;
import
edu.kit.scc.webreg.service.reg.RegisterUserWorkflow
;
import
edu.kit.scc.webreg.service.reg.ldap.PropertyReader
;
public
class
PfNcMigrationRegisterWorkflow
extends
PowerFolderRegisterWorkflow
implements
RegisterUserWorkflow
,
InfotainmentCapable
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PfNcMigrationRegisterWorkflow
.
class
);
@Override
public
void
registerUser
(
UserEntity
user
,
ServiceEntity
service
,
RegistryEntity
registry
,
Auditor
auditor
)
throws
RegisterException
{
super
.
registerUser
(
user
,
service
,
registry
,
auditor
);
PropertyReader
prop
=
PropertyReader
.
newRegisterPropReader
(
service
);
String
idKey
=
"nextcloud_user_id"
;
if
(
prop
.
readPropOrNull
(
"id_key"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_key"
);
}
String
scope
=
"bwidm.scc.kit.edu"
;
if
(
prop
.
readPropOrNull
(
"id_scope"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_scope"
);
}
if
(!
user
.
getGenericStore
().
containsKey
(
idKey
))
{
user
.
getGenericStore
().
put
(
idKey
,
UUID
.
randomUUID
().
toString
()
+
"@"
+
scope
);
logger
.
debug
(
"Generating new {} for user {}: {}"
,
idKey
,
user
.
getId
(),
user
.
getGenericStore
().
get
(
idKey
));
}
if
(!
registry
.
getRegistryValues
().
containsKey
(
"id"
))
{
registry
.
getRegistryValues
().
put
(
"id"
,
user
.
getGenericStore
().
get
(
idKey
));
}
}
@Override
public
void
reconciliation
(
UserEntity
user
,
ServiceEntity
service
,
RegistryEntity
registry
,
Auditor
auditor
)
throws
RegisterException
{
super
.
reconciliation
(
user
,
service
,
registry
,
auditor
);
PropertyReader
prop
=
PropertyReader
.
newRegisterPropReader
(
service
);
String
idKey
=
"nextcloud_user_id"
;
if
(
prop
.
readPropOrNull
(
"id_key"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_key"
);
}
String
scope
=
"bwidm.scc.kit.edu"
;
if
(
prop
.
readPropOrNull
(
"id_scope"
)
!=
null
)
{
idKey
=
prop
.
readPropOrNull
(
"id_scope"
);
}
if
(!
user
.
getGenericStore
().
containsKey
(
idKey
))
{
user
.
getGenericStore
().
put
(
idKey
,
UUID
.
randomUUID
().
toString
()
+
"@"
+
scope
);
logger
.
debug
(
"Generating new {} for user {}: {}"
,
idKey
,
user
.
getId
(),
user
.
getGenericStore
().
get
(
idKey
));
}
if
(!
registry
.
getRegistryValues
().
containsKey
(
"id"
))
{
registry
.
getRegistryValues
().
put
(
"id"
,
user
.
getGenericStore
().
get
(
idKey
));
}
}
@Override
public
Infotainment
getInfo
(
RegistryEntity
registry
,
UserEntity
user
,
ServiceEntity
service
)
throws
RegisterException
{
Infotainment
info
=
super
.
getInfo
(
registry
,
user
,
service
);
PropertyReader
prop
=
PropertyReader
.
newRegisterPropReader
(
service
);
NextcloudWorker
worker
=
new
NextcloudWorker
(
prop
);
NextcloudAnswer
answer
=
worker
.
loadAccount
(
registry
);
InfotainmentTreeNode
root
=
info
.
getRoot
();
/*
InfotainmentTreeNode node = new InfotainmentTreeNode("Status", root);
new InfotainmentTreeNode("StatusCode", "" + answer.getMeta().getStatusCode(), node);
new InfotainmentTreeNode("Status", answer.getMeta().getStatus(), node);
new InfotainmentTreeNode("Message", answer.getMeta().getMessage(), node);
*/
InfotainmentTreeNode
node
=
new
InfotainmentTreeNode
(
"Migration User Info"
,
root
);
if
((
answer
.
getUser
()
!=
null
)
&&
(
answer
.
getUser
().
getId
()
!=
null
))
{
new
InfotainmentTreeNode
(
"ID"
,
answer
.
getUser
().
getId
(),
node
);
new
InfotainmentTreeNode
(
"Name"
,
answer
.
getUser
().
getDisplayName
(),
node
);
new
InfotainmentTreeNode
(
"E-Mail"
,
answer
.
getUser
().
getEmail
(),
node
);
if
(
answer
.
getUser
().
getQuota
()
!=
null
&&
answer
.
getUser
().
getQuota
().
getRelative
()
!=
null
)
{
new
InfotainmentTreeNode
(
"Verbrauchter Platz"
,
""
+
answer
.
getUser
().
getQuota
().
getRelative
()
+
"%"
,
node
);
}
if
(
answer
.
getUser
().
getGroups
()
!=
null
)
{
for
(
String
group
:
answer
.
getUser
().
getGroups
().
getGroupList
())
{
new
InfotainmentTreeNode
(
"Gruppe"
,
group
,
node
);
}
}
}
else
{
new
InfotainmentTreeNode
(
"status"
,
"Account not initialized yet"
,
node
);
}
return
info
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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