Example usage for com.google.gwt.user.client Cookies getCookie

List of usage examples for com.google.gwt.user.client Cookies getCookie

Introduction

In this page you can find the example usage for com.google.gwt.user.client Cookies getCookie.

Prototype

public static String getCookie(String name) 

Source Link

Document

Gets the cookie associated with the given name.

Usage

From source file:anzsoft.xmpp4gwt.client.Bosh2Connector.java

License:Open Source License

public boolean isCacheAvailable() {
    return Cookies.getCookie(user.getResource() + "sid") != null
            && Cookies.getCookie(user.getResource() + "rid") != null;
}

From source file:anzsoft.xmpp4gwt.client.Bosh2Connector.java

License:Open Source License

public boolean resume() {
    makeNewRequestBuilder(defaultTimeout + 7);
    this.sid = Cookies.getCookie(user.getResource() + "sid");
    try {//from  ww w  . j a v  a  2  s .c  om
        this.rid = Long.parseLong(Cookies.getCookie(user.getResource() + "rid"));
    } catch (Exception e) {
        this.rid = 0;
    }

    if (this.sid == null || this.rid == 0)
        return false;

    this.state = State.connected;

    Packet e0 = new PacketImp("body");
    e0.setAttribute("xmlns", "http://jabber.org/protocol/httpbind");
    e0.setAttribute("sid", sid);
    //e0.setAttribute("rid", ""+this.rid);
    e0.setAttribute("rid", this.getNextRid());

    /*
    Packet e = new PacketImp("body");
    e.setAttribute("xmlns", "http://jabber.org/protocol/httpbind");
    e.setAttribute("rid", getNextRid());
    e.setAttribute("sid", sid);
            
    e.setAttribute("cache", "get_all");
     */

    if (crossDomain) {
        send(renderer.render(e0), scriptHandler);
        //send(renderer.render(e),scriptHandler);
    } else {
        send(renderer.render(e0), standardHandler);
        //send(renderer.render(e), standardHandler);
    }

    return true;
}

From source file:anzsoft.xmpp4gwt.client.User.java

License:Open Source License

public boolean resume() {
    String cookie = Cookies.getCookie(COOKIENAME);
    if (cookie == null || cookie.length() == 0)
        return false;
    JSONObject jUser = JSONParser.parse(cookie).isObject();
    if (jUser == null)
        return false;

    this.username = jUser.get(STORAGE_USERNAME).isString().stringValue();
    this.domainname = jUser.get(STORAGE_DOMAIN).isString().stringValue();
    //this.password = jUser.get("password").isString().stringValue();  
    //jUser.put("priority", new JSONString(String.valueOf(priority)));
    this.resource = jUser.get(STORAGE_RESOURCE).isString().stringValue();
    this.priority = Integer.parseInt(jUser.get(STORAGE_PRIORITY).isString().stringValue());
    Cookies.removeCookie(COOKIENAME);//from  w w w.  ja  v a 2s  .  c  om
    if (username.length() == 0 || domainname.length() == 0)
        return false;
    return true;
}

From source file:at.ait.dme.yuma.client.Application.java

License:EUPL

/**
 * returns the provided name of the user 
 * //from  w w w  .  j a  va 2 s.  c  o m
 * @return user name
 */
public static String getUser() {
    String userName = authenticatedUser.getName();
    if (!userName.equalsIgnoreCase(Cookies.getCookie(LEMO_COOKIE_NAME))) {
        Cookies.setCookie(LEMO_COOKIE_NAME, userName, null, null, "/", false);
    }
    return userName;
}

From source file:bingo.client.Bingo.java

License:Open Source License

/**
 * This is the entry point method.//  w w  w  .j  a  v  a  2 s. c  o  m
 */
public void onModuleLoad() {
    Label titleLabel = new Label();
    titleLabel.setText(strings.title());
    RootPanel.get("title").add(titleLabel);

    // This is the general notification text box
    RootPanel.get("message").add(message);

    // Cheking if the user has already an user id
    final String cookie = Cookies.getCookie(COOKIE_ID);

    // Validating the cookie
    bingoService.statusUserId(cookie, new AsyncCallback<Integer>() {
        @Override
        public void onFailure(Throwable caught) {
            message.setText(caught.getMessage());
            Cookies.removeCookie(COOKIE_ID);
        }

        @Override
        public void onSuccess(Integer status) {
            // TODO: Control the logged status (I should not get a user if s/he is already logged)
            if (status.intValue() == BingoService.NO_LOGGED || status.intValue() == BingoService.LOGGED) {
                bingoService.getUserId(new AsyncCallback<String>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(strings.errorUserCreation());
                    }

                    @Override
                    public void onSuccess(String result) {
                        userId = result;
                    }
                });

                message.setHTML("");

                // Showing image to enter
                ImageResource imageResource = BingoResources.INSTANCE.entry();
                Image entryImage = new Image(imageResource.getSafeUri());
                RootPanel.get("buttons").add(entryImage);

                // Selecting behavior (admin / voter) 
                HorizontalPanel entryPoint = new HorizontalPanel();

                entryPoint.setStyleName("mainSelectorPanel");
                entryPoint.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.setSpacing(50);

                // 
                // CREATING A BINGO
                //
                VerticalPanel leftPanel = new VerticalPanel();
                leftPanel.setStyleName("selectorPanel");

                Label leftPanelTitle = new Label();
                leftPanelTitle.setStyleName("selectorPanelTitle");
                leftPanelTitle.setText(strings.leftPanelTitle());
                leftPanel.add(leftPanelTitle);
                leftPanel.setCellHorizontalAlignment(leftPanelTitle, HasHorizontalAlignment.ALIGN_CENTER);

                Grid leftSubPanel = new Grid(2, 2);
                leftSubPanel.setWidget(0, 0, new Label(strings.createBingoName()));
                final TextBox bingoNameBox = new TextBox();
                leftSubPanel.setWidget(0, 1, bingoNameBox);

                leftSubPanel.setWidget(1, 0, new Label(strings.createBingoPassword()));
                final PasswordTextBox bingoPasswordBox = new PasswordTextBox();
                leftSubPanel.setWidget(1, 1, bingoPasswordBox);
                leftPanel.add(leftSubPanel);

                final Button createButton = new Button("Create");
                createButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        bingoService.createBingo(userId, bingoNameBox.getText(), bingoPasswordBox.getText(),
                                new AsyncCallback<String>() {
                                    @Override
                                    public void onFailure(Throwable caught) {
                                        message.setText(caught.getMessage());
                                    }

                                    @Override
                                    public void onSuccess(final String gameId) {
                                        final BingoGrid bingoGrid = new BingoGrid();
                                        initAdminGrid(userId, bingoGrid, false);
                                        RootPanel.get("bingoTable").clear();
                                        RootPanel.get("bingoTable").add(bingoGrid);
                                        message.setText(strings.welcomeMessageCreation());

                                        // Setting the cookie
                                        Date expirationDate = new Date();
                                        expirationDate.setHours(expirationDate.getHours() + EXPIRATION_VALUE);
                                        Cookies.setCookie(COOKIE_ID, userId, expirationDate);
                                    }
                                });
                    }
                });
                leftPanel.add(createButton);
                leftPanel.setCellHorizontalAlignment(createButton, HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.add(leftPanel);

                // 
                // JOINING
                //
                VerticalPanel rightPanel = new VerticalPanel();
                rightPanel.setStyleName("selectorPanel");

                Label rightPanelTitle = new Label();
                rightPanelTitle.setStyleName("selectorPanelTitle");
                rightPanelTitle.setText(strings.rightPanelTitle());
                rightPanel.add(rightPanelTitle);
                rightPanel.setCellHorizontalAlignment(rightPanelTitle, HasHorizontalAlignment.ALIGN_CENTER);

                Grid rightSubPanel = new Grid(2, 2);
                rightSubPanel.setWidget(0, 0, new Label(strings.joinToBingoName()));
                final ListBox joinExistingBingoBox = new ListBox();
                bingoService.getBingos(new AsyncCallback<String[][]>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        joinExistingBingoBox.addItem(strings.noBingos());
                    }

                    @Override
                    public void onSuccess(String[][] result) {
                        if (result == null) {
                            joinExistingBingoBox.addItem(strings.noBingos());
                        } else {
                            for (int i = 0; i < result.length; i++) {
                                String gameName = result[i][0];
                                String gameId = result[i][1];
                                joinExistingBingoBox.addItem(gameName, gameId);
                            }
                        }
                    }
                });
                rightSubPanel.setWidget(0, 1, joinExistingBingoBox);

                rightSubPanel.setWidget(1, 0, new Label(strings.joinToBingoPassword()));
                final PasswordTextBox joinBingoPasswordBox = new PasswordTextBox();
                rightSubPanel.setWidget(1, 1, joinBingoPasswordBox);
                rightPanel.add(rightSubPanel);

                final Button joinButton = new Button("Join");
                joinButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        int index = joinExistingBingoBox.getSelectedIndex();
                        if (index < 0)
                            message.setText(strings.noSelectedItem());
                        else {
                            final String gameId = joinExistingBingoBox.getValue(index);
                            if (gameId == null)
                                message.setText(strings.noSelectedItem());
                            else {
                                bingoService.joinBingo(userId, gameId, joinBingoPasswordBox.getText(),
                                        new AsyncCallback<Void>() {
                                            @Override
                                            public void onFailure(Throwable caught) {
                                                message.setText(caught.getMessage());
                                            }

                                            @Override
                                            public void onSuccess(Void result) {
                                                final BingoGrid bingoGrid = new BingoGrid();
                                                initUserGrid(bingoGrid);
                                                RootPanel.get("bingoTable").clear();
                                                RootPanel.get("bingoTable").add(bingoGrid);

                                                message.setText(strings.welcomeMessageJoin());

                                                // Setting the cookie
                                                Date expirationDate = new Date();
                                                expirationDate
                                                        .setHours(expirationDate.getHours() + EXPIRATION_VALUE);
                                                Cookies.setCookie(COOKIE_ID, userId, expirationDate);
                                            }
                                        });
                            }
                        }
                    }
                });
                rightPanel.add(joinButton);
                rightPanel.setCellHorizontalAlignment(joinButton, HasHorizontalAlignment.ALIGN_CENTER);
                entryPoint.add(rightPanel);

                RootPanel.get("bingoTable").add(entryPoint);

            } else if (status.intValue() == BingoService.ADMIN) {
                message.setText("Detected cookie: " + cookie + " as admin");
                userId = cookie;

                bingoService.statusBingo(userId, new AsyncCallback<Integer>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Integer result) {
                        int status = result.intValue();
                        final BingoGrid bingoGrid = new BingoGrid();
                        if (status == BingoService.RUNNING) {
                            initAdminGrid(userId, bingoGrid, false);
                            message.setText(strings.welcomeMessageCreation());
                        } else if (status == BingoService.FINISHED) {
                            initAdminGrid(userId, bingoGrid, true);
                            message.setText(strings.finishMessage());
                        }
                        RootPanel.get("bingoTable").clear();
                        RootPanel.get("bingoTable").add(bingoGrid);
                    }
                });

            } else if (status.intValue() == BingoService.PARTICIPANT) {
                message.setText("Detected cookie: " + cookie + " as participant");
                userId = cookie;

                final BingoGrid bingoGrid = new BingoGrid();
                initUserGrid(bingoGrid);
                updateUserGrid(bingoGrid, null);
                RootPanel.get("bingoTable").clear();
                RootPanel.get("bingoTable").add(bingoGrid);
            }
        }
    });
}

From source file:ca.qc.cegepoutaouais.tge.pige.client.ClientApp.java

License:Open Source License

/**
 * Point d'entr du module./*from   w  w w.  j av  a2 s . c  o  m*/
 */
@Override
public void onModuleLoad() {

    GXT.setDefaultTheme(Theme.BLUE, true);

    // Crer et enregistrer les services RPC.
    LoginServiceAsync loginService = (LoginServiceAsync) GWT.create(LoginService.class);
    UserServiceAsync userService = (UserServiceAsync) GWT.create(UserService.class);
    ManagementServiceAsync managementService = (ManagementServiceAsync) GWT.create(ManagementService.class);
    Registry.register(PIGE.LOGIN_SERVICE, loginService);
    Registry.register(PIGE.USER_SERVICE, userService);
    Registry.register(PIGE.MANAGEMENT_SERVICE, managementService);

    String jSessionId = Cookies.getCookie(PIGE.SESSION_COOKIE);
    Registry.register(PIGE.SESSION_COOKIE, jSessionId);

    initializeApp();
}

From source file:cc.alcina.framework.gwt.persistence.client.ClientSession.java

License:Apache License

public boolean isInitialObjectsPersisted() {
    String s = Cookies.getCookie(hasPersistedInitialObjectsCookieName);
    return s != null && Boolean.valueOf(s);
}

From source file:cc.alcina.framework.gwt.persistence.client.ClientSession.java

License:Apache License

public boolean isPersistingChunk() {
    String s = Cookies.getCookie(this.persistingChunkCookieName);
    return s != null && Boolean.valueOf(s);
}

From source file:cc.kune.core.client.auth.WaveClientSimpleAuthenticator.java

License:GNU Affero Public License

/**
 * Gets the cookie token value.
 * 
 * @return the cookie token value
 */
public String getCookieTokenValue() {
    return Cookies.getCookie("JSESSIONID");
}

From source file:cc.kune.core.client.cookies.CookiesManagerImpl.java

License:GNU Affero Public License

@Override
public String getAnonCookie() {
    return Cookies.getCookie(ANON);
}