1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.pages;
20
21 import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
22 import java.util.ArrayList;
23 import java.util.List;
24 import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
25 import org.apache.syncope.client.console.SyncopeConsoleSession;
26 import org.apache.syncope.client.console.panels.ApplicationDirectoryPanel;
27 import org.apache.syncope.client.console.panels.DelegationDirectoryPanel;
28 import org.apache.syncope.client.console.panels.DynRealmDirectoryPanel;
29 import org.apache.syncope.client.console.panels.RoleDirectoryPanel;
30 import org.apache.syncope.client.console.panels.SecurityQuestionsPanel;
31 import org.apache.syncope.client.console.rest.ApplicationRestClient;
32 import org.apache.syncope.client.console.rest.DelegationRestClient;
33 import org.apache.syncope.client.console.rest.DynRealmRestClient;
34 import org.apache.syncope.client.console.rest.RealmRestClient;
35 import org.apache.syncope.client.console.rest.RoleRestClient;
36 import org.apache.syncope.client.console.rest.SecurityQuestionRestClient;
37 import org.apache.syncope.client.console.rest.UserRestClient;
38 import org.apache.syncope.client.console.wizards.DelegationWizardBuilder;
39 import org.apache.syncope.client.console.wizards.role.RoleWizardBuilder;
40 import org.apache.syncope.common.lib.to.DelegationTO;
41 import org.apache.syncope.common.lib.to.RoleTO;
42 import org.apache.syncope.common.lib.types.IdRepoEntitlement;
43 import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
44 import org.apache.wicket.extensions.markup.html.tabs.ITab;
45 import org.apache.wicket.markup.html.WebMarkupContainer;
46 import org.apache.wicket.markup.html.panel.Panel;
47 import org.apache.wicket.model.ResourceModel;
48 import org.apache.wicket.request.mapper.parameter.PageParameters;
49 import org.apache.wicket.spring.injection.annot.SpringBean;
50
51 public class Security extends BasePage {
52
53 private static final long serialVersionUID = -1100228004207271271L;
54
55 @SpringBean
56 protected RoleRestClient roleRestClient;
57
58 @SpringBean
59 protected RealmRestClient realmRestClient;
60
61 @SpringBean
62 protected DelegationRestClient delegationRestClient;
63
64 @SpringBean
65 protected DynRealmRestClient dynRealmRestClient;
66
67 @SpringBean
68 protected ApplicationRestClient applicationRestClient;
69
70 @SpringBean
71 protected SecurityQuestionRestClient securityQuestionRestClient;
72
73 @SpringBean
74 protected UserRestClient userRestClient;
75
76 public Security(final PageParameters parameters) {
77 super(parameters);
78
79 body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
80 WebMarkupContainer content = new WebMarkupContainer("content");
81 content.setOutputMarkupId(true);
82 content.setMarkupId("security");
83 content.add(new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList()));
84 body.add(content);
85 }
86
87 protected List<ITab> buildTabList() {
88 List<ITab> tabs = new ArrayList<>();
89
90 if (SyncopeConsoleSession.get().owns(IdRepoEntitlement.ROLE_LIST)) {
91 tabs.add(new AbstractTab(new ResourceModel("roles")) {
92
93 private static final long serialVersionUID = -6815067322125799251L;
94
95 @Override
96 public Panel getPanel(final String panelId) {
97 return new RoleDirectoryPanel.Builder(roleRestClient, getPageReference()) {
98
99 private static final long serialVersionUID = -5960765294082359003L;
100
101 }.addNewItemPanelBuilder(new RoleWizardBuilder(
102 new RoleTO(),
103 roleRestClient,
104 realmRestClient,
105 dynRealmRestClient,
106 applicationRestClient,
107 getPageReference()), true).build(panelId);
108 }
109 });
110 }
111
112 tabs.add(new AbstractTab(new ResourceModel("delegations")) {
113
114 private static final long serialVersionUID = 29722178554609L;
115
116 @Override
117 public Panel getPanel(final String panelId) {
118 return new DelegationDirectoryPanel.Builder(delegationRestClient, getPageReference()) {
119
120 private static final long serialVersionUID = 30231721305047L;
121
122 }.addNewItemPanelBuilder(new DelegationWizardBuilder(
123 new DelegationTO(),
124 userRestClient,
125 delegationRestClient,
126 getPageReference()),
127 true).build(panelId);
128 }
129 });
130
131 tabs.add(new AbstractTab(new ResourceModel("dynRealms")) {
132
133 private static final long serialVersionUID = -6815067322125799251L;
134
135 @Override
136 public Panel getPanel(final String panelId) {
137 return new DynRealmDirectoryPanel.Builder(dynRealmRestClient, getPageReference()) {
138
139 private static final long serialVersionUID = -5960765294082359003L;
140
141 }.build(panelId);
142 }
143 });
144
145 if (SyncopeConsoleSession.get().owns(IdRepoEntitlement.APPLICATION_LIST)) {
146 tabs.add(new AbstractTab(new ResourceModel("applications")) {
147
148 private static final long serialVersionUID = -6815067322125799251L;
149
150 @Override
151 public Panel getPanel(final String panelId) {
152 return new ApplicationDirectoryPanel.Builder(applicationRestClient, getPageReference()) {
153
154 private static final long serialVersionUID = -5960765294082359003L;
155
156 }.build(panelId);
157 }
158 });
159 }
160
161 tabs.add(new AbstractTab(new ResourceModel("securityQuestions")) {
162
163 private static final long serialVersionUID = -6815067322125799251L;
164
165 @Override
166 public Panel getPanel(final String panelId) {
167 return new SecurityQuestionsPanel(panelId, securityQuestionRestClient, getPageReference());
168 }
169 });
170
171 return tabs;
172 }
173 }