diff options
| author | Jonathan Bauer | 2015-08-20 16:45:54 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-08-20 16:45:54 +0200 |
| commit | c7037719ff7754b983c2bd2d3dbe0c0e2d1eb2a3 (patch) | |
| tree | b854cef3f3c5548c53d0abd1fb93bbc323989361 /dozentenmodul/src/main/java/org | |
| parent | [client] Upload stuff ThriftActions'ed [WIP] (diff) | |
| parent | [client] Minor fixes (diff) | |
| download | tutor-module-c7037719ff7754b983c2bd2d3dbe0c0e2d1eb2a3.tar.gz tutor-module-c7037719ff7754b983c2bd2d3dbe0c0e2d1eb2a3.tar.xz tutor-module-c7037719ff7754b983c2bd2d3dbe0c0e2d1eb2a3.zip | |
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
Diffstat (limited to 'dozentenmodul/src/main/java/org')
4 files changed, 37 insertions, 13 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java index 5b7b1ccd..31ac8cc4 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/EcpAuthenticator.java @@ -3,15 +3,18 @@ package org.openslx.dozmod.authentication; import java.io.IOException; import java.net.MalformedURLException; import java.net.URISyntaxException; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import org.apache.commons.codec.binary.Base64; import org.apache.http.ParseException; import org.apache.http.client.ClientProtocolException; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.Satellite; import org.openslx.bwlp.thrift.iface.TAuthorizationException; +import org.openslx.dozmod.authentication.ServiceProviderResponse.JSatellite; import org.openslx.dozmod.authentication.ShibbolethEcp.ReturnCode; import com.google.gson.JsonSyntaxException; @@ -66,8 +69,12 @@ public class EcpAuthenticator implements Authenticator { List<Satellite> sats = new ArrayList<>(); // TODO: Handle cert fingerprint if (response.satellites2 != null) { - for (Entry<String, List<String>> it : response.satellites2.entrySet()) { - sats.add(new Satellite(it.getValue(), it.getKey(), null)); + Base64 base64 = new Base64(); + for (Entry<String, JSatellite> it : response.satellites2.entrySet()) { + JSatellite jsat = it.getValue(); + ByteBuffer hash = jsat.certHash == null ? null + : ByteBuffer.wrap(base64.decode(jsat.certHash)); + sats.add(new Satellite(jsat.addresses, it.getKey(), hash)); } } data = new AuthenticationData(response.token, response.sessionId, sats); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java index 52bcefe8..a2aca5c4 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/authentication/ServiceProviderResponse.java @@ -4,11 +4,17 @@ import java.util.HashMap; import java.util.List; public class ServiceProviderResponse { + + public static class JSatellite { + public List<String> addresses; + public String certHash; + } + public String status; public String firstName; public String lastName; public String mail; - public HashMap<String, List<String>> satellites2; + public HashMap<String, JSatellite> satellites2; public String token; public String sessionId; public String userId; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java index 2d04ba3b..50aae9e2 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java @@ -10,7 +10,6 @@ import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -38,6 +37,7 @@ import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.window.layout.LoginWindowLayout; import org.openslx.dozmod.thrift.Session; +import org.openslx.dozmod.thrift.Sorters; import org.openslx.dozmod.thrift.cache.OrganizationCache; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.QuickTimer; @@ -135,15 +135,11 @@ public class LoginWindow extends LoginWindowLayout { Iterator<Organization> iterator = orgs.iterator(); while (iterator.hasNext()) { Organization current = iterator.next(); - if (current == null | !current.isSetEcpUrl() | current.getEcpUrl().isEmpty()) + if (current == null || !current.isSetEcpUrl() || current.getEcpUrl().isEmpty()) iterator.remove(); } // all fine, lets sort it - Collections.sort(orgs, new Comparator<Organization>() { - public int compare(Organization o1, Organization o2) { - return o1.getDisplayName().compareTo(o2.getDisplayName()); - } - }); + Collections.sort(orgs, Sorters.organization); // now send the organisations back to the LoginWindow // through populateIdpCombo() Gui.asyncExec(new Runnable() { @@ -334,8 +330,8 @@ public class LoginWindow extends LoginWindowLayout { // TODO: Show satellite selection if > 1 //String satAddress = data.satellites.get(0).addressList.get(0); String satAddress = "132.230.8.113"; // TODO: HACK HACK - Client client = ThriftManager.getNewSatelliteClient(GraphicalCertHandler.getSslContext(satAddress), satAddress, - App.THRIFT_SSL_PORT, App.THRIFT_TIMEOUT_MS); + Client client = ThriftManager.getNewSatelliteClient(GraphicalCertHandler.getSslContext(satAddress), + satAddress, App.THRIFT_SSL_PORT, App.THRIFT_TIMEOUT_MS); if (client == null) { Gui.showMessageBox(this, "Login erfolgreich, aber der Satellit antwortet nicht", MessageType.ERROR, LOGGER, null); @@ -362,7 +358,8 @@ public class LoginWindow extends LoginWindowLayout { } if (whoami != null) { Session.initialize(whoami, satAddress, data.satelliteToken, data.masterToken); - ThriftManager.setSatelliteAddress(GraphicalCertHandler.getSslContext(Session.getSatelliteAddress()), + ThriftManager.setSatelliteAddress( + GraphicalCertHandler.getSslContext(Session.getSatelliteAddress()), Session.getSatelliteAddress(), App.THRIFT_SSL_PORT, App.THRIFT_TIMEOUT_MS); // now read the config to see if the user already agreed to the disclaimer // if (DisclaimerWindow.shouldBeShown()) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java index 8a0559f2..af5e9e9f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Sorters.java @@ -3,6 +3,7 @@ package org.openslx.dozmod.thrift; import java.util.Comparator; import org.openslx.bwlp.thrift.iface.OperatingSystem; +import org.openslx.bwlp.thrift.iface.Organization; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.thrift.cache.UserCache; @@ -48,4 +49,17 @@ public class Sorters { } }; + public static Comparator<Organization> organization = new Comparator<Organization>() { + public int compare(Organization o1, Organization o2) { + if (o1 == null || o1.displayName == null) { + if (o2 == null) + return 0; + return -1; + } else if (o2 == null) { + return 1; + } + return o1.displayName.compareTo(o2.displayName); + } + }; + } |
