summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9ab0830)
org.argeo.cms,\
org.argeo.cms.auth,\
org.argeo.security.ui,\
org.argeo.cms,\
org.argeo.cms.auth,\
org.argeo.security.ui,\
import org.argeo.cms.CmsException;
import org.argeo.cms.CmsStyles;
import org.argeo.cms.CmsUiProvider;
import org.argeo.cms.CmsException;
import org.argeo.cms.CmsStyles;
import org.argeo.cms.CmsUiProvider;
-import org.eclipse.gemini.blueprint.context.BundleContextAware;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.osgi.framework.BundleContext;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.osgi.framework.BundleContext;
-import org.springframework.beans.factory.InitializingBean;
+import org.osgi.framework.FrameworkUtil;
/** A link to an internal or external location. */
/** A link to an internal or external location. */
-public class CmsLink implements CmsUiProvider, InitializingBean,
- BundleContextAware {
+public class CmsLink implements CmsUiProvider {
private final static Log log = LogFactory.getLog(CmsLink.class);
private final static Log log = LogFactory.getLog(CmsLink.class);
+ private BundleContext bc = FrameworkUtil.getBundle(getClass())
+ .getBundleContext();
private String label;
private String custom;
private String label;
private String custom;
// private Boolean isUrl = false;
private Integer imageWidth, imageHeight;
// private Boolean isUrl = false;
private Integer imageWidth, imageHeight;
- private BundleContext bundleContext;
-
public CmsLink() {
super();
}
public CmsLink() {
super();
}
this.label = label;
this.target = target;
this.custom = custom;
this.label = label;
this.target = target;
this.custom = custom;
- @Override
- public void afterPropertiesSet() {
- // if (target != null) {
- // if (target.startsWith("/")) {
- // isUrl = true;
- // } else {
- // try {
- // new URL(target);
- // isUrl = true;
- // } catch (MalformedURLException e1) {
- // isUrl = false;
- // }
- // }
- // }
-
if (image != null) {
ImageData image = loadImage();
imageWidth = image.width;
if (image != null) {
ImageData image = loadImage();
imageWidth = image.width;
// pure URL
url = new URL(image);
} catch (MalformedURLException e1) {
// pure URL
url = new URL(image);
} catch (MalformedURLException e1) {
- // in OSGi bundle
- if (bundleContext == null)
- throw new CmsException("No bundle context available");
- url = bundleContext.getBundle().getResource(image);
+ url = bc.getBundle().getResource(image);
- @Override
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
public void setMouseListener(MouseListener mouseListener) {
this.mouseListener = mouseListener;
}
public void setMouseListener(MouseListener mouseListener) {
this.mouseListener = mouseListener;
}
+ " (must be: top, bottom or center)");
}
}
+ " (must be: top, bottom or center)");
}
}
-
- // private class MListener extends MouseAdapter {
- // private static final long serialVersionUID = 3634864186295639792L;
- //
- // @Override
- // public void mouseDown(MouseEvent e) {
- // if (e.button == 1) {
- // }
- // }
- // }
- //
- // private class DListener implements DisposeListener {
- // private static final long serialVersionUID = -3808587499269394812L;
- // private final Image img;
- //
- // public DListener(Image img) {
- // super();
- // this.img = img;
- // }
- //
- // @Override
- // public void widgetDisposed(DisposeEvent event) {
- // img.dispose();
- // }
- //
- // }
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.jcr.ArgeoJcrConstants;
import org.argeo.jcr.JcrUtils;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.jcr.ArgeoJcrConstants;
import org.argeo.jcr.JcrUtils;
+import org.argeo.node.NodeAuthenticated;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
import org.eclipse.swt.SWT;
* this call.
*/
public static CmsView getCmsView() {
* this call.
*/
public static CmsView getCmsView() {
- return UiContext.getData(CmsView.KEY);
+ return UiContext.getData(NodeAuthenticated.KEY);
}
public static StringBuilder getServerBaseUrl(HttpServletRequest request) {
}
public static StringBuilder getServerBaseUrl(HttpServletRequest request) {
import org.argeo.cms.widgets.auth.CmsLogin;
import org.argeo.cms.widgets.auth.CmsLoginShell;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.cms.widgets.auth.CmsLogin;
import org.argeo.cms.widgets.auth.CmsLoginShell;
import org.argeo.eclipse.ui.specific.UiContext;
+import org.argeo.node.NodeAuthenticated;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.EntryPoint;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.EntryPoint;
import org.eclipse.swt.events.SelectionListener;
@Override
public int createUI() {
final Display display = createDisplay();
@Override
public int createUI() {
final Display display = createDisplay();
- UiContext.setData(CmsView.KEY, this);
+ UiContext.setData(NodeAuthenticated.KEY, this);
try {
// try pre-auth
loginContext = new LoginContext(AuthConstants.LOGIN_CONTEXT_USER,
try {
// try pre-auth
loginContext = new LoginContext(AuthConstants.LOGIN_CONTEXT_USER,
import org.argeo.cms.auth.HttpRequestCallbackHandler;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.jcr.JcrUtils;
import org.argeo.cms.auth.HttpRequestCallbackHandler;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.jcr.JcrUtils;
+import org.argeo.node.NodeAuthenticated;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.rap.rwt.client.WebClient;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.rap.rwt.client.WebClient;
@Override
protected final void createContents(final Composite parent) {
@Override
protected final void createContents(final Composite parent) {
- UiContext.setData(CmsView.KEY, this);
+ UiContext.setData(NodeAuthenticated.KEY, this);
Subject.doAs(subject, new PrivilegedAction<Void>() {
@Override
public Void run() {
Subject.doAs(subject, new PrivilegedAction<Void>() {
@Override
public Void run() {
-import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginContext;
-/** Provides interaction with the CMS system. UNSTABLE API at this stage. */
-public interface CmsView {
- public final static String KEY = "org.argeo.cms.view";
+import org.argeo.node.NodeAuthenticated;
+/** Provides interaction with the CMS system. UNSTABLE API at this stage. */
+public interface CmsView extends NodeAuthenticated {
UxContext getUxContext();
// NAVIGATION
UxContext getUxContext();
// NAVIGATION
- public void navigateTo(String state);
+ void navigateTo(String state);
- public void authChange(LoginContext loginContext);
-
- public Subject getSubject();
+ void authChange(LoginContext loginContext);
- public void exception(Throwable e);
+ void exception(Throwable e);
- public CmsImageManager getImageManager();
+ CmsImageManager getImageManager();
import javax.security.auth.x500.X500Principal;
import org.argeo.cms.CmsException;
import javax.security.auth.x500.X500Principal;
import org.argeo.cms.CmsException;
-import org.argeo.cms.CmsView;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.eclipse.ui.specific.UiContext;
+import org.argeo.node.NodeAuthenticated;
import org.osgi.service.useradmin.Authorization;
/** Static utilities */
import org.osgi.service.useradmin.Authorization;
/** Static utilities */
public static boolean isAnonymous(Subject subject) {
String username = getUsername(subject);
public static boolean isAnonymous(Subject subject) {
String username = getUsername(subject);
- return username == null || username.equalsIgnoreCase(AuthConstants.ROLE_ANONYMOUS);
+ return username == null
+ || username.equalsIgnoreCase(AuthConstants.ROLE_ANONYMOUS);
}
private static Subject currentSubject() {
}
private static Subject currentSubject() {
- CmsView cmsView = getCmsView();
+ NodeAuthenticated cmsView = getNodeAuthenticated();
if (cmsView != null)
return cmsView.getSubject();
Subject subject = Subject.getSubject(AccessController.getContext());
if (cmsView != null)
return cmsView.getSubject();
Subject subject = Subject.getSubject(AccessController.getContext());
- * The CMS view related to this display, or null if none is available from
- * this call.
+ * The node authenticated component (typically a CMS view) related to this
+ * display, or null if none is available from this call.
- private static CmsView getCmsView() {
- return UiContext.getData(CmsView.KEY);
+ public static NodeAuthenticated getNodeAuthenticated() {
+ return UiContext.getData(NodeAuthenticated.KEY);
}
public final static String getUsername(Subject subject) {
}
public final static String getUsername(Subject subject) {
- // Subject subject = Subject.getSubject(AccessController.getContext());
- // if (subject == null)
- // return null;
if (subject.getPrincipals(X500Principal.class).size() != 1)
return null;
if (subject.getPrincipals(X500Principal.class).size() != 1)
return null;
- Principal principal = subject.getPrincipals(X500Principal.class).iterator().next();
+ Principal principal = subject.getPrincipals(X500Principal.class)
+ .iterator().next();
return principal.getName();
return principal.getName();
}
public final static String getDisplayName(Subject subject) {
}
public final static String getDisplayName(Subject subject) {
}
private static Authorization getAuthorization(Subject subject) {
}
private static Authorization getAuthorization(Subject subject) {
- return subject.getPrivateCredentials(Authorization.class).iterator().next();
+ return subject.getPrivateCredentials(Authorization.class).iterator()
+ .next();
}
public final static Set<String> roles() {
}
public final static Set<String> roles() {
public final static Set<String> roles(Subject subject) {
Set<String> roles = new HashSet<String>();
public final static Set<String> roles(Subject subject) {
Set<String> roles = new HashSet<String>();
- X500Principal userPrincipal = subject.getPrincipals(X500Principal.class).iterator().next();
+ X500Principal userPrincipal = subject
+ .getPrincipals(X500Principal.class).iterator().next();
roles.add(userPrincipal.getName());
for (Principal group : subject.getPrincipals(Group.class)) {
roles.add(group.getName());
roles.add(userPrincipal.getName());
for (Principal group : subject.getPrincipals(Group.class)) {
roles.add(group.getName());
--- /dev/null
+package org.argeo.node;
+
+import javax.security.auth.Subject;
+
+public interface NodeAuthenticated {
+ String KEY = "org.argeo.node.authenticated";
+
+ Subject getSubject();
+
+}
<!-- Eclipse -->
<module>org.argeo.eclipse.ui</module>
<module>org.argeo.eclipse.ui.rap</module>
<!-- Eclipse -->
<module>org.argeo.eclipse.ui</module>
<module>org.argeo.eclipse.ui.rap</module>
-<!-- <module>org.argeo.eclipse.ui.workbench</module> -->
<!-- CMS -->
<module>org.argeo.node.api</module>
<module>org.argeo.cms</module>
<!-- CMS -->
<module>org.argeo.node.api</module>
<module>org.argeo.cms</module>