diff options
Diffstat (limited to 'dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java')
| -rw-r--r-- | dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java b/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java deleted file mode 100644 index 40c1d2eb..00000000 --- a/dozentenmodul/src/main/java/auth/BWIDMAuthenticator.java +++ /dev/null @@ -1,89 +0,0 @@ -package auth; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URISyntaxException; - -import org.apache.http.ParseException; -import org.apache.http.client.ClientProtocolException; -import org.apache.log4j.Logger; -import org.apache.thrift.TException; -import org.openslx.bwlp.thrift.iface.TAuthenticationException; -import org.openslx.bwlp.thrift.iface.TInvalidTokenException; -import org.openslx.bwlp.thrift.iface.UserInfo; -import org.openslx.thrifthelper.ThriftManager; - -import com.google.gson.JsonSyntaxException; - -import util.ShibbolethECP; -import util.ShibbolethECP.ReturnCode; - -/** - * @author Jonathan Bauer - * - */ -public class BWIDMAuthenticator implements BaseAuthenticator { - - /** - * Logger instance for this class - */ - private final static Logger LOGGER = Logger.getLogger(BWIDMAuthenticator.class); - - private final String ecpUrl; - - public BWIDMAuthenticator(String ecpUrl) { - // first lets check the given ecpUrl - if (!ecpUrl.isEmpty()) - this.ecpUrl = ecpUrl; - else - this.ecpUrl = null; - // NOTE: the actual check for a correct URI will be done by - // the ECP client. - } - - @Override - public void login(String username, String password, - AuthenticatorCallback callback) throws TAuthenticationException { - // try to login - ReturnCode ret = null; - try { - ret = ShibbolethECP.doLogin(this.ecpUrl, username, password); - } catch (JsonSyntaxException e) { - LOGGER.error("Could not parse JSON response from the service provider: ", e); - } catch (ClientProtocolException e) { - LOGGER.error("HTTP client protocol error: ", e); - } catch (ParseException e) { - LOGGER.error("Error parsing the raw response body from the service provider: ", e); - } catch (MalformedURLException e) { - LOGGER.error("Bad syntax of the registration URL returned by the service provider: ", e); - } catch (URISyntaxException e) { - LOGGER.error("Bad syntax of the URL to the identity provider: ", e); - } catch (IOException e) { - LOGGER.error("IO Error while communicating with the service provider: ", e); - } - // if ret is still null, some exception happened, so abort. - if (ret == null) { - LOGGER.error("Error during the ECP authentication process."); - return; - } - - // else, we do have a valid ReturnCode - if (ret == ReturnCode.NO_ERROR) { - UserInfo userInfo; - try { - userInfo = ThriftManager.getMasterClient().getUserFromToken(ShibbolethECP.getResponse().token); - } catch (TInvalidTokenException e) { - LOGGER.error("Masterserver does not accepts the token received from the Service Provider. See trace: ", e); - return; - } catch (TException e) { - LOGGER.error("Thrift transport error, see trace: ", e); - return; - } - callback.postLogin(ReturnCode.NO_ERROR, userInfo); - } else { - // else just return the ReturnCode to the GUI - // it should then show a corresponding error message! - callback.postLogin(ret, null); - } - } -} |
