summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/gui/core/LoginComposite.java
diff options
context:
space:
mode:
authorJonathan Bauer2015-07-03 18:47:55 +0200
committerJonathan Bauer2015-07-03 18:47:55 +0200
commit66080be14336a7d0b06bc244249fcf0d528ea449 (patch)
tree3f5a81734bfea8837efbb4793c5263b805c40fc2 /dozentenmodul/src/main/java/gui/core/LoginComposite.java
parentMerge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1 (diff)
downloadtutor-module-66080be14336a7d0b06bc244249fcf0d528ea449.tar.gz
tutor-module-66080be14336a7d0b06bc244249fcf0d528ea449.tar.xz
tutor-module-66080be14336a7d0b06bc244249fcf0d528ea449.zip
[client] bwIDM Authentication implemented, yet to be finalized.
Diffstat (limited to 'dozentenmodul/src/main/java/gui/core/LoginComposite.java')
-rw-r--r--dozentenmodul/src/main/java/gui/core/LoginComposite.java148
1 files changed, 45 insertions, 103 deletions
diff --git a/dozentenmodul/src/main/java/gui/core/LoginComposite.java b/dozentenmodul/src/main/java/gui/core/LoginComposite.java
index 5a387e8f..060b1c61 100644
--- a/dozentenmodul/src/main/java/gui/core/LoginComposite.java
+++ b/dozentenmodul/src/main/java/gui/core/LoginComposite.java
@@ -2,9 +2,8 @@ package gui.core;
import gui.GuiManager;
+import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.GridData;
@@ -19,21 +18,37 @@ import org.eclipse.swt.widgets.Text;
public class LoginComposite extends Composite {
+ private final static Logger LOGGER = Logger.getLogger(LoginComposite.class);
+
+ protected enum LOGIN_TYPE {
+ BWIDM, BWLP, SAT
+ }
+
+ protected LOGIN_TYPE loginType = LOGIN_TYPE.BWIDM;
+
private Image titleImage;
- // textfield of the username
- private Text usernameText;
+ // textfields for the username/password
+ protected Text usernameText;
+ protected Text passwordText;
- // textfield of the password
- private Text passwordText;
+ // ComboBox/label for the IDP
+ protected final Combo idpCombo;
+ protected final Label idpText;
- String title = "Dozmod - Login";
- String authenticationGroupLabel = "Authentifizierungsart";
+ // buttons
+ protected final Button loginButton;
+ protected final Button saveUsernameCheck;
+ protected final Button[] authButtons;
+ private static final String title = "Dozmod - Login";
+ private static final String authenticationGroupLabel = "Authentifizierungsart";
/**
* Create a new login composite
- * @param mainShell The shell it should be added to
+ *
+ * @param mainShell
+ * The shell it should be added to
*/
public LoginComposite(final Shell mainShell) {
super(mainShell, SWT.NONE);
@@ -67,8 +82,7 @@ public class LoginComposite extends Composite {
authGroup.setLayoutData(gridData);
// add the authentication method selection buttons
- Button[] authButtons = new Button[3];
-
+ authButtons = new Button[3];
authButtons[0] = new Button(authGroup, SWT.RADIO);
authButtons[0].setSelection(true);
authButtons[0].setText("Authentifizierung über bwIDM");
@@ -81,11 +95,10 @@ public class LoginComposite extends Composite {
authButtons[1].setLayoutData(gridData);
authButtons[2] = new Button(authGroup, SWT.RADIO);
- authButtons[2].setText("Direkte Verbindung zum Satteliten");
+ authButtons[2].setText("Direkte Verbindung zum Satelliten");
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
authButtons[2].setLayoutData(gridData);
-
// group for the login mask
final Group loginGroup = new Group(this, SWT.NONE);
loginGroup.setText("Zugangsdaten");
@@ -96,111 +109,40 @@ public class LoginComposite extends Composite {
gridData.heightHint = 150;
loginGroup.setLayoutData(gridData);
-
- final Label idpText = new Label(loginGroup, SWT.NONE);
+ idpText = new Label(loginGroup, SWT.NONE);
idpText.setText("IdP:");
-
- final Combo idpCombo = new Combo(loginGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
- idpCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
-
- fillIdPCombo(idpCombo);
-
+ idpCombo = new Combo(loginGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ idpCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true,
+ false));
new Label(loginGroup, SWT.NONE).setText("Benutzername:");
usernameText = new Text(loginGroup, SWT.SINGLE | SWT.BORDER);
- usernameText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
+ usernameText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
new Label(loginGroup, SWT.NONE).setText("Passwort:");
passwordText = new Text(loginGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
- passwordText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- Button loginButton = new Button(loginGroup, SWT.PUSH);
+ passwordText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
+ true, false));
+ // login button
+ loginButton = new Button(loginGroup, SWT.PUSH);
loginButton.setText("Login");
- Button saveUsernameCheck = new Button(loginGroup, SWT.CHECK);
+ saveUsernameCheck = new Button(loginGroup, SWT.CHECK);
saveUsernameCheck.setText("Benutzername speichern");
-
- // actions of the login button
- loginButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedLoginButton();
- }
- });
-
- // for save username checkbox.
- saveUsernameCheck.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clickedSaveUsernameCheck();
- }
- });
-
- // selecting the "Authentifizierung über bwIDM" radio button
- authButtons[0].addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- idpText.setVisible(true);
- idpCombo.setVisible(true);
- }
- });
-
- // selecting the "Test-Zugang über bwIDM" radio button
- authButtons[1].addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- idpText.setVisible(false);
- idpCombo.setVisible(false);
- }
- });
-
- authButtons[2].setEnabled(false);
- // selecting the "Direkte Verbindung zum Satteliten" radio button
- authButtons[2].addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- idpText.setVisible(false);
- idpCombo.setVisible(false);
- }
- });
}
-
-
- //
- // logical functions for GUI
- //
-
- /**
- * function to execute when checking the saveUsername checkbox
- */
- protected void clickedSaveUsernameCheck() {
- System.out.println("Checkboxtoggle");
- }
-
-
- /**
- * function to execute when clicking the login button
- */
- protected void clickedLoginButton() {
- GuiManager.addContent(new DisclaimerComposite(getShell()));
- }
-
-
- /**
- * fill the idpCombo with idpCombo.add(String)
- * @param idpCombo
- */
- protected void fillIdPCombo(Combo idpCombo) {
- idpCombo.add("No Entries!");
- }
-
-
- private void loadImage(){
+ private void loadImage() {
try {
- titleImage = new Image(GuiManager.getDisplay(), getClass().getResourceAsStream("/img/Logo_bwLehrpool.png"));
+ // TODO use the ResourceLoader class to load the logo
+ // this way, we can be sure to get an image
+ // (since the ResourceLoader always returns an image,
+ // even if it cannot load the specified one).
+ titleImage = new Image(GuiManager.getDisplay(), getClass()
+ .getResourceAsStream("/img/Logo_bwLehrpool.png"));
ImageData imgData = titleImage.getImageData();
- imgData = imgData.scaledTo(imgData.width/5, imgData.height/5);
+ imgData = imgData.scaledTo(imgData.width / 5, imgData.height / 5);
titleImage = new Image(GuiManager.getDisplay(), imgData);
} catch (Exception e) {
System.out.println("Cannot load image");