import java.util.List;
import java.util.Locale;
+import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.LanguageCallback;
private final CmsView cmsView;
+ // optional subject to be set explicitly
+ private Subject subject = null;
+
public CmsLogin(CmsView cmsView) {
this.cmsView = cmsView;
defaultLocale = Activator.getNodeState().getDefaultLocale();
Locale locale = localeChoice == null ? this.defaultLocale : localeChoice.getSelectedLocale();
credentialsBlock = new Composite(parent, SWT.NONE);
credentialsBlock.setLayout(new GridLayout());
- credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ // credentialsBlock.setLayoutData(CmsUtils.fillAll());
specificUserUi(credentialsBlock);
// We need a composite for the traversal
credentialsBlock = new Composite(parent, SWT.NONE);
credentialsBlock.setLayout(new GridLayout());
- credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ // credentialsBlock.setLayoutData(CmsUtils.fillAll());
+ CmsUtils.style(credentialsBlock, CMS_LOGIN_DIALOG);
Integer textWidth = 120;
- CmsUtils.style(parent, CMS_USER_MENU);
+ if (parent instanceof Shell)
+ CmsUtils.style(parent, CMS_USER_MENU);
// new Label(this, SWT.NONE).setText(CmsMsg.username.lead());
usernameT = new Text(credentialsBlock, SWT.BORDER);
usernameT.setMessage(username.lead(locale));
}
/**
- * To be overridden in order to provide custome login button and other links.
+ * To be overridden in order to provide custom login button and other links.
*/
protected void extendsCredentialsBlock(Composite credentialsBlock, Locale selectedLocale,
SelectionListener loginSelectionListener) {
protected Composite createLocalesBlock(final Composite parent) {
Composite c = new Composite(parent, SWT.NONE);
+ CmsUtils.style(c, CMS_USER_MENU_ITEM);
c.setLayout(CmsUtils.noSpaceGridLayout());
c.setLayoutData(CmsUtils.fillAll());
for (Integer i = 0; i < locales.size(); i++) {
Locale locale = locales.get(i);
Button button = new Button(c, SWT.RADIO);
+ CmsUtils.style(button, CMS_USER_MENU_ITEM);
button.setData(i);
button.setText(LocaleUtils.lead(locale.getDisplayName(locale), locale) + " (" + locale + ")");
// button.addListener(SWT.Selection, listener);
}
protected boolean login() {
+ // TODO use CmsVie in order to retrieve subject?
// Subject subject = cmsView.getLoginContext().getSubject();
// LoginContext loginContext = cmsView.getLoginContext();
try {
// LOGIN
//
// loginContext.logout();
- LoginContext loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, this);
+ LoginContext loginContext;
+ if (subject == null)
+ loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, this);
+ else
+ loginContext = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, this);
loginContext.login();
cmsView.authChange(loginContext);
return true;
}
}
+ public void setSubject(Subject subject) {
+ this.subject = subject;
+ }
+
}