hi Christian,

i'm little bit confused..

following is my code for authentication

     showLoginDialog: function() {
        var panel = new Ext.FormPanel({
            url: "http://localhost/Ganesh/login_response.json";,
            frame: true,
            labelWidth: 60,
            defaultType: "textfield",

            errorReader: {
                read: function(response) {
                    var success = false;
                    var records = [];
                    if (response.status === 200) {
                        success = true;
                    } else {
                        records = [
                            {data: {id: "username", msg: "invalid Username
or password."}},
                            {data: {id: "password", msg: "invalid Username
or password."}}
                        ];
                    }
                    return {
                        success: success,
                        records: records
                    };
                }
            },
            items: [{
                fieldLabel: "User",
                name: "username",
                allowBlank: false
            }, {
                fieldLabel: "password",
                name: "password",
                inputType: "password",
                allowBlank: false
            }],
            buttons: [{
                text: "Login",
                formBind: true,
                handler: submitLogin,
                scope: this
            }],
            keys: [{
                key: [Ext.EventObject.ENTER],
                handler: submitLogin,
                scope: this
            }]
        });
         function submitLogin() {
            panel.buttons[0].disable();
            panel.getForm().submit({
                success: function(form, action) {
 var response = JSON.parse(action.response.responseText);
                    this.setAuthorizedRoles(["ROLE_ADMINISTRATOR"]);
                    app.mapPanel.getTopToolbar().items.each(function(tool) {
                        if (tool.needsAuthorization === true) {
                            tool.enable();
                        }
                    });
//                     var user = form.findField('username').getValue();
                    var user = response.username;
var pwd = response.password;

   var tok = user + ':' + pwd;
   var auth = "Basic "+ Base64.encode(tok);
   var url = 'http://localhost:8080/geoserver/j_spring_security_check';
 Ext.Ajax.request({
    url : url,
 method : 'POST',
scriptTag: true,
params: {
 username: user,
password: pwd
},
//     headers : { Authorization : auth },
success: function(response){
                     app.setCookieValue(app.cookieParamName, user);
                     app.showLogout(user);
 },
failure: function(response) {
app.clearCookieValue(app.cookieParamName);
 app.showLoginDialog();
}
});
                    win.close();
                },
                failure: function(form, action) {
                    this.authorizedRoles = [];
                    panel.buttons[0].enable();
                    form.markInvalid({
                        "username": "invalid Username or password.",
                        "password": "invalid Username or password."
                    });
                },
                scope: this
            });
        }

        var win = new Ext.Window({
            title: this.loginText,
            layout: "fit",
            width: 260,
            height: 130,
            plain: true,
            border: false,
            modal: true,
            items: [panel]
        });
        win.show();
    },

in which the url "http://localhost/Ganesh/login_response.json"; provides a
json which is created for test purpose as follows

{
"status" : true,
        "username": "admin",
        "password": "admin132",
        "message": "the login successful"
}

after that i make a request to the geoserver/j_spring_security_check as
shown in the code

but i do not get authenticated to the geoserver as the last two requests to
geoserver doesn't fulfill

if you can provide a  working example related to the geoserver basic http
authentication from client side apart from GeoExplorer one . i'll be very
thankful to you.. sir
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to