Android Open Source - ACM_Pi_Cloud Own Cloud Saml Sso Credentials

From Project

Back to project page ACM_Pi_Cloud.


The source code is released under:

MIT License

If you think the Android project ACM_Pi_Cloud listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

//from   w  w w  .ja va2  s.c om
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.cookie.CookiePolicy;


public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials {

  private String mSessionCookie;

  public OwnCloudSamlSsoCredentials(String sessionCookie) {
    mSessionCookie = sessionCookie != null ? sessionCookie : "";

  public void applyTo(OwnCloudClient client) {
      Uri serverUri = client.getBaseUri();
        String[] cookies = mSessionCookie.split(";");
        if (cookies.length > 0) {
          Cookie cookie = null;
            for (int i=0; i<cookies.length; i++) {
              int equalPos = cookies[i].indexOf('=');
              if (equalPos >= 0) {
                  cookie = new Cookie();
                cookie.setName(cookies[i].substring(0, equalPos));
                cookie.setValue(cookies[i].substring(equalPos + 1));
                cookie.setDomain(serverUri.getHost());  // VERY IMPORTANT 
                cookie.setPath(serverUri.getPath());  // VERY IMPORTANT

  public String getUsername() {
    // its unknown
    return null;
  public String getAuthToken() {
    return mSessionCookie;

  public boolean authTokenExpires() {
    return true;


Java Source Code List