Skip to content

Commit 38eedf2

Browse files
authored
[SYNCOPE-1893] SCIM Group extension + SCIM AnyObject extension (#1145)
1 parent e901668 commit 38eedf2

31 files changed

Lines changed: 1347 additions & 176 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.syncope.client.console.panels;
20+
21+
import java.util.Optional;
22+
import org.apache.syncope.common.lib.scim.SCIMConf;
23+
import org.apache.syncope.common.lib.scim.SCIMExtensionAnyConf;
24+
import org.apache.syncope.common.lib.scim.SCIMExtensionAnyObjectConf;
25+
26+
public class SCIMConfExtensionAnyObjectPanel extends SCIMConfExtensionAnyPanel {
27+
28+
private static final long serialVersionUID = -1540432800132655369L;
29+
30+
public SCIMConfExtensionAnyObjectPanel(final String id, final SCIMConf scimConf, final String anyTypeKey) {
31+
super(id, scimConf, anyTypeKey);
32+
}
33+
34+
@Override
35+
public SCIMExtensionAnyConf getExtensionAnyConf(final SCIMConf scimConf) {
36+
Optional<SCIMExtensionAnyObjectConf> scimExtAnyObjectConf =
37+
scimConf.getExtensionAnyObjectsConf().stream()
38+
.filter(scimExtensionAnyObjectConf -> scimExtensionAnyObjectConf.getType().equals(anyTypeKey))
39+
.findFirst();
40+
if (scimExtAnyObjectConf.isPresent()) {
41+
return scimExtAnyObjectConf.get();
42+
}
43+
SCIMExtensionAnyObjectConf scimExtensionAnyObjectConf = new SCIMExtensionAnyObjectConf();
44+
scimExtensionAnyObjectConf.setType(anyTypeKey);
45+
scimConf.getExtensionAnyObjectsConf().add(scimExtensionAnyObjectConf);
46+
return scimExtensionAnyObjectConf;
47+
}
48+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.syncope.client.console.panels;
20+
21+
import org.apache.syncope.client.console.panels.mapping.SCIMExtensionMappingPanel;
22+
import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
23+
import org.apache.syncope.common.lib.scim.SCIMConf;
24+
import org.apache.syncope.common.lib.scim.SCIMExtensionAnyConf;
25+
import org.apache.wicket.markup.html.form.Form;
26+
import org.apache.wicket.model.Model;
27+
import org.apache.wicket.model.PropertyModel;
28+
import org.apache.wicket.model.util.ListModel;
29+
30+
public abstract class SCIMConfExtensionAnyPanel extends SCIMConfTabPanel {
31+
32+
private static final long serialVersionUID = 2459231778083046011L;
33+
34+
protected final String anyTypeKey;
35+
36+
protected SCIMConfExtensionAnyPanel(final String id, final SCIMConf scimConf, final String anyTypeKey) {
37+
super(id);
38+
this.anyTypeKey = anyTypeKey;
39+
40+
SCIMExtensionAnyConf scimExtensionAnyConf = getExtensionAnyConf(scimConf);
41+
42+
AjaxTextFieldPanel namePanel = new AjaxTextFieldPanel("name", "name", new PropertyModel<>("name", "name") {
43+
44+
private static final long serialVersionUID = 7389942851813193481L;
45+
46+
@Override
47+
public String getObject() {
48+
return scimExtensionAnyConf.getName();
49+
}
50+
51+
@Override
52+
public void setObject(final String object) {
53+
scimExtensionAnyConf.setName(object);
54+
}
55+
});
56+
add(namePanel);
57+
58+
AjaxTextFieldPanel descriptionPanel = new AjaxTextFieldPanel(
59+
"description", "description", new PropertyModel<>("description", "description") {
60+
61+
private static final long serialVersionUID = -5911179251497048661L;
62+
63+
@Override
64+
public String getObject() {
65+
return scimExtensionAnyConf.getDescription();
66+
}
67+
68+
@Override
69+
public void setObject(final String object) {
70+
scimExtensionAnyConf.setDescription(object);
71+
}
72+
});
73+
add(descriptionPanel);
74+
75+
SCIMExtensionMappingPanel extensionMappingPanel = new SCIMExtensionMappingPanel(
76+
"mapping", new ListModel<>(scimExtensionAnyConf.getAttributes()), anyTypeKey);
77+
Form<SCIMExtensionAnyConf> form = new Form<>("form", new Model<>(scimExtensionAnyConf));
78+
form.add(extensionMappingPanel);
79+
add(form);
80+
}
81+
82+
abstract SCIMExtensionAnyConf getExtensionAnyConf(SCIMConf scimConf);
83+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.syncope.client.console.panels;
20+
21+
import org.apache.syncope.common.lib.scim.SCIMConf;
22+
import org.apache.syncope.common.lib.scim.SCIMExtensionAnyConf;
23+
24+
public class SCIMConfExtensionGroupPanel extends SCIMConfExtensionAnyPanel {
25+
26+
private static final long serialVersionUID = -3719006384765921047L;
27+
28+
public SCIMConfExtensionGroupPanel(final String id, final SCIMConf scimConf, final String anyTypeKey) {
29+
super(id, scimConf, anyTypeKey);
30+
}
31+
32+
@Override
33+
public SCIMExtensionAnyConf getExtensionAnyConf(final SCIMConf scimConf) {
34+
if (scimConf.getExtensionGroupConf() == null) {
35+
scimConf.setExtensionGroupConf(new SCIMExtensionAnyConf());
36+
}
37+
return scimConf.getExtensionGroupConf();
38+
}
39+
}

ext/scimv2/client-console/src/main/java/org/apache/syncope/client/console/panels/SCIMConfExtensionUserPanel.java

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,64 +18,22 @@
1818
*/
1919
package org.apache.syncope.client.console.panels;
2020

21-
import org.apache.syncope.client.console.panels.mapping.SCIMExtensionMappingPanel;
22-
import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
2321
import org.apache.syncope.common.lib.scim.SCIMConf;
24-
import org.apache.syncope.common.lib.scim.SCIMExtensionUserConf;
25-
import org.apache.wicket.markup.html.form.Form;
26-
import org.apache.wicket.model.Model;
27-
import org.apache.wicket.model.PropertyModel;
28-
import org.apache.wicket.model.util.ListModel;
22+
import org.apache.syncope.common.lib.scim.SCIMExtensionAnyConf;
2923

30-
public class SCIMConfExtensionUserPanel extends SCIMConfTabPanel {
24+
public class SCIMConfExtensionUserPanel extends SCIMConfExtensionAnyPanel {
3125

32-
private static final long serialVersionUID = 2459231778083046011L;
26+
private static final long serialVersionUID = -94504185795020353L;
3327

34-
public SCIMConfExtensionUserPanel(final String id, final SCIMConf scimConf) {
35-
super(id);
28+
public SCIMConfExtensionUserPanel(final String id, final SCIMConf scimConf, final String anyTypeKey) {
29+
super(id, scimConf, anyTypeKey);
30+
}
3631

32+
@Override
33+
public SCIMExtensionAnyConf getExtensionAnyConf(final SCIMConf scimConf) {
3734
if (scimConf.getExtensionUserConf() == null) {
38-
scimConf.setExtensionUserConf(new SCIMExtensionUserConf());
35+
scimConf.setExtensionUserConf(new SCIMExtensionAnyConf());
3936
}
40-
SCIMExtensionUserConf scimExtensionUserConf = scimConf.getExtensionUserConf();
41-
42-
AjaxTextFieldPanel namePanel = new AjaxTextFieldPanel("name", "name", new PropertyModel<>("name", "name") {
43-
44-
private static final long serialVersionUID = 7389942851813193481L;
45-
46-
@Override
47-
public String getObject() {
48-
return scimExtensionUserConf.getName();
49-
}
50-
51-
@Override
52-
public void setObject(final String object) {
53-
scimExtensionUserConf.setName(object);
54-
}
55-
});
56-
add(namePanel);
57-
58-
AjaxTextFieldPanel descriptionPanel = new AjaxTextFieldPanel(
59-
"description", "description", new PropertyModel<>("description", "description") {
60-
61-
private static final long serialVersionUID = -5911179251497048661L;
62-
63-
@Override
64-
public String getObject() {
65-
return scimExtensionUserConf.getDescription();
66-
}
67-
68-
@Override
69-
public void setObject(final String object) {
70-
scimExtensionUserConf.setDescription(object);
71-
}
72-
});
73-
add(descriptionPanel);
74-
75-
SCIMExtensionMappingPanel extensionMappingPanel = new SCIMExtensionMappingPanel(
76-
"mapping", new ListModel<>(scimExtensionUserConf.getAttributes()));
77-
Form<SCIMExtensionUserConf> form = new Form<>("form", new Model<>(scimExtensionUserConf));
78-
form.add(extensionMappingPanel);
79-
add(form);
37+
return scimConf.getExtensionUserConf();
8038
}
8139
}

ext/scimv2/client-console/src/main/java/org/apache/syncope/client/console/panels/SCIMConfPanel.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424
import org.apache.syncope.client.console.SyncopeConsoleSession;
2525
import org.apache.syncope.client.console.commons.ITabComponent;
2626
import org.apache.syncope.client.console.pages.BasePage;
27+
import org.apache.syncope.client.console.rest.AnyTypeRestClient;
2728
import org.apache.syncope.client.console.rest.SCIMConfRestClient;
2829
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
2930
import org.apache.syncope.client.ui.commons.Constants;
3031
import org.apache.syncope.common.lib.scim.SCIMConf;
32+
import org.apache.syncope.common.lib.types.AnyTypeKind;
3133
import org.apache.wicket.PageReference;
3234
import org.apache.wicket.ajax.AjaxRequestTarget;
3335
import org.apache.wicket.ajax.markup.html.AjaxLink;
3436
import org.apache.wicket.extensions.markup.html.tabs.ITab;
3537
import org.apache.wicket.markup.html.WebMarkupContainer;
3638
import org.apache.wicket.markup.html.panel.Panel;
3739
import org.apache.wicket.model.Model;
40+
import org.apache.wicket.model.ResourceModel;
3841
import org.apache.wicket.spring.injection.annot.SpringBean;
3942
import org.slf4j.Logger;
4043
import org.slf4j.LoggerFactory;
@@ -48,6 +51,9 @@ public class SCIMConfPanel extends WizardMgtPanel<SCIMConf> {
4851
@SpringBean
4952
protected SCIMConfRestClient scimConfRestClient;
5053

54+
@SpringBean
55+
protected AnyTypeRestClient anyTypeRestClient;
56+
5157
protected final SCIMConf scimConf;
5258

5359
public SCIMConfPanel(
@@ -124,7 +130,7 @@ public WebMarkupContainer getPanel(final String panelId) {
124130

125131
@Override
126132
public WebMarkupContainer getPanel(final String panelId) {
127-
return new SCIMConfExtensionUserPanel(panelId, scimConf);
133+
return new SCIMConfExtensionUserPanel(panelId, scimConf, AnyTypeKind.USER.name());
128134
}
129135
});
130136

@@ -138,6 +144,30 @@ public WebMarkupContainer getPanel(final String panelId) {
138144
}
139145
});
140146

147+
tabs.add(new ITabComponent(new Model<>(getString("tab6")), getString("tab6")) {
148+
149+
private static final long serialVersionUID = -7858187494595192532L;
150+
151+
@Override
152+
public WebMarkupContainer getPanel(final String panelId) {
153+
return new SCIMConfExtensionGroupPanel(panelId, scimConf, AnyTypeKind.GROUP.name());
154+
}
155+
});
156+
157+
anyTypeRestClient.listAnyTypes().stream()
158+
.filter(anyTypeTO -> AnyTypeKind.ANY_OBJECT.equals(anyTypeTO.getKind()))
159+
.forEach(anyTypeTO ->
160+
tabs.add(new ITabComponent(
161+
new ResourceModel("anyType." + anyTypeTO.getKey(), anyTypeTO.getKey())) {
162+
163+
private static final long serialVersionUID = 6429988338658964324L;
164+
165+
@Override
166+
public WebMarkupContainer getPanel(final String panelId) {
167+
return new SCIMConfExtensionAnyObjectPanel(panelId, scimConf, anyTypeTO.getKey());
168+
}
169+
}));
170+
141171
return tabs;
142172
}
143173
}

ext/scimv2/client-console/src/main/java/org/apache/syncope/client/console/panels/mapping/SCIMExtensionMappingPanel.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
3636
import org.apache.syncope.common.lib.scim.SCIMItem;
3737
import org.apache.syncope.common.lib.scim.SCIMReturned;
38-
import org.apache.syncope.common.lib.types.AnyTypeKind;
3938
import org.apache.wicket.ajax.AjaxRequestTarget;
4039
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
4140
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
@@ -79,11 +78,15 @@ public class SCIMExtensionMappingPanel extends Panel {
7978

8079
protected final WebMarkupContainer mappingContainer;
8180

81+
protected final String anyTypeKey;
82+
8283
public SCIMExtensionMappingPanel(
8384
final String id,
84-
final IModel<List<SCIMItem>> model) {
85+
final IModel<List<SCIMItem>> model,
86+
final String anyTypeKey) {
8587

8688
super(id);
89+
this.anyTypeKey = anyTypeKey;
8790
setOutputMarkupId(true);
8891

8992
mappingContainer = new WebMarkupContainer("mappingContainer");
@@ -264,9 +267,18 @@ protected void onSubmit(final AjaxRequestTarget target) {
264267
}
265268

266269
protected IModel<List<String>> getExtAttrNames() {
267-
List<String> choices = new ArrayList<>(ClassPathScanImplementationLookup.USER_FIELD_NAMES);
268-
269-
anyTypeClassRestClient.list(anyTypeRestClient.read(AnyTypeKind.USER.name()).getClasses()).
270+
List<String> choices = new ArrayList<>();
271+
switch (anyTypeKey) {
272+
case "USER":
273+
choices.addAll(ClassPathScanImplementationLookup.USER_FIELD_NAMES);
274+
break;
275+
case "GROUP":
276+
choices.addAll(ClassPathScanImplementationLookup.GROUP_FIELD_NAMES);
277+
break;
278+
default:
279+
choices.addAll(ClassPathScanImplementationLookup.ANY_OBJECT_FIELD_NAMES);
280+
}
281+
anyTypeClassRestClient.list(anyTypeRestClient.read(anyTypeKey).getClasses()).
270282
forEach(anyTypeClassTO -> {
271283
choices.addAll(anyTypeClassTO.getPlainSchemas());
272284
choices.addAll(anyTypeClassTO.getDerSchemas());

ext/scimv2/client-console/src/main/resources/org/apache/syncope/client/console/panels/SCIMConfExtensionUserPanel.html renamed to ext/scimv2/client-console/src/main/resources/org/apache/syncope/client/console/panels/SCIMConfExtensionAnyPanel.html

File renamed without changes.

ext/scimv2/client-console/src/main/resources/org/apache/syncope/client/console/panels/SCIMConfPanel.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ tab3=EnterpriseUser
2121
saveButton=Save
2222
tab4=ExtensionUser
2323
tab5=Group
24+
tab6=ExtensionGroup

ext/scimv2/client-console/src/main/resources/org/apache/syncope/client/console/panels/SCIMConfPanel_it.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ tab3=EnterpriseUser
2121
saveButton=Save
2222
tab4=ExtensionUser
2323
tab5=Group
24+
tab6=ExtensionGroup

ext/scimv2/client-console/src/main/resources/org/apache/syncope/client/console/panels/SCIMConfPanel_pt_BR.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ tab3=EnterpriseUser
2121
saveButton=Save
2222
tab4=ExtensionUser
2323
tab5=Group
24+
tab6=ExtensionGroup

0 commit comments

Comments
 (0)