]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.e4/src/org/argeo/cms/e4/maintenance/SecurityDeploymentUi.java
1 package org
.argeo
.cms
.e4
.maintenance
;
5 import org
.argeo
.cms
.ui
.util
.CmsUiUtils
;
6 import org
.eclipse
.swt
.SWT
;
7 import org
.eclipse
.swt
.layout
.GridData
;
8 import org
.eclipse
.swt
.widgets
.Composite
;
9 import org
.eclipse
.swt
.widgets
.Label
;
10 import org
.osgi
.framework
.InvalidSyntaxException
;
11 import org
.osgi
.framework
.ServiceReference
;
12 import org
.osgi
.service
.useradmin
.Role
;
13 import org
.osgi
.service
.useradmin
.UserAdmin
;
15 class SecurityDeploymentUi
extends AbstractOsgiComposite
{
16 private static final long serialVersionUID
= 590221539553514693L;
18 public SecurityDeploymentUi(Composite parent
, int style
) {
23 protected void initUi(int style
) {
31 private void initNewUi(Composite parent
) {
32 new Label(parent
, SWT
.NONE
).setText("Security is not configured");
35 private void initCurrentUi(Composite parent
) {
36 ServiceReference
<UserAdmin
> userAdminRef
= bc
.getServiceReference(UserAdmin
.class);
37 UserAdmin userAdmin
= bc
.getService(userAdminRef
);
38 StringBuffer text
= new StringBuffer();
39 text
.append("<span style='font-variant: small-caps;'>Domains</span><br/>");
40 domains
: for (String key
: userAdminRef
.getPropertyKeys()) {
41 if (!key
.startsWith("/"))
46 } catch (Exception e
) {
47 // ignore non URI keys
51 String rootDn
= uri
.getPath().substring(1, uri
.getPath().length());
52 // FIXME make reading query options more robust, using utils
53 boolean readOnly
= uri
.getQuery().equals("readOnly=true");
55 text
.append("<span style='font-weight:bold;font-style: italic'>");
57 text
.append("<span style='font-weight:bold'>");
60 text
.append("</span><br/>");
62 Role
[] roles
= userAdmin
.getRoles("(dn=*," + rootDn
+ ")");
65 for (Role role
: roles
) {
66 if (role
.getType() == Role
.USER
)
71 text
.append(" " + userCount
+ " users, " + groupCount
+" groups.<br/>");
72 } catch (InvalidSyntaxException e
) {
73 log
.error("Invalid syntax", e
);
76 Label label
= new Label(parent
, SWT
.NONE
);
77 label
.setData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false));
78 CmsUiUtils
.markup(label
);
79 label
.setText(text
.toString());
82 protected boolean isDeployed() {
83 return bc
.getServiceReference(UserAdmin
.class) != null;