Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 403243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:11:56+00:00 2026-05-12T17:11:56+00:00

I’m writing a wicket project for a social network.In my project i have authentication

  • 0

I’m writing a wicket project for a social network.In my project i have authentication so when a user enter address of the home page he is redirected to login page in this way:

public class MyApplication extends WebApplication {

    private Folder uploadFolder = null;

    @Override
    public Class getHomePage() {
        return UserHome.class;
    }

    public Folder getUploadFolder()
    {
        return uploadFolder;
    }

    @Override
    protected void init() {
        super.init();

        // Disable the Ajax debug label!
        //getDebugSettings().setAjaxDebugModeEnabled(false);


        this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
        this.getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
        mountBookmarkablePage("/BossPage", BossPage.class);
        mountBookmarkablePage("/Branch", EditProfile.class);
        mountBookmarkablePage("/SA", SuperAdmin.class);
        mountBookmarkablePage("/Admin", ir.pnusn.branch.ui.pages.administratorPages.EditProfile.class);
        mountBookmarkablePage("/Student", StudentSignUP.class);
        mountBookmarkablePage("/Student/Test", StudentSignUpConfirm.class);
        mountBookmarkablePage("/Branch/categories.xml", CategoriesXML.class);

        get().getPageSettings().setAutomaticMultiWindowSupport(true);
        getResourceSettings().setThrowExceptionOnMissingResource(false);
        uploadFolder = new Folder("C:\\", "wicket-uploads");
        uploadFolder.mkdirs();

        this.getSecuritySettings().setAuthorizationStrategy(WiaAuthorizationStrategy.getInstance());
        this.getSecuritySettings().setUnauthorizedComponentInstantiationListener(WiaAuthorizationStrategy.getInstance());
        addComponentInstantiationListener(new IComponentInstantiationListener() {

            public void onInstantiation(final Component component) {
                if (!getSecuritySettings().getAuthorizationStrategy().isInstantiationAuthorized(component.getClass())) {
                    try {
                        getSecuritySettings().getUnauthorizedComponentInstantiationListener().onUnauthorizedInstantiation(component);
                    } catch (Exception e) {
                        System.out.println("ERRORRRRRRR:" + e.toString());
                    }
                }
            }
        });

    }
}

and my WiaAuthorizationStrategy class is like this which will get page names and user roles from a xml file by name Realm.xml :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ir.pnusn.ui.library;

import ir.pnusn.authentication.RealmPolicy;
import ir.pnusn.authentication.ui.pages.Login;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseAtInterceptPageException;
import org.apache.wicket.authorization.Action;
import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;

public final class WiaAuthorizationStrategy implements
        IAuthorizationStrategy,
        IUnauthorizedComponentInstantiationListener {

    private RealmPolicy roleManager;
    private static WiaAuthorizationStrategy instance;

    private WiaAuthorizationStrategy() {
        roleManager = RealmPolicy.getInstance();
    }

    public static WiaAuthorizationStrategy getInstance() {
        if(instance == null)
            instance = new WiaAuthorizationStrategy();
        return instance;
    }

    public boolean isInstantiationAuthorized(Class componentClass) {

        if (ProtectedPage.class.isAssignableFrom(componentClass)) {
            if (WiaSession.get().getUser() == null) {
                return false;
            }
            if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), componentClass.getName()))//WiaSession.get().isAuthenticated();
            {
                WiaSession.get().setAccess(false);
                return false;
            }
            else
                return true;
        }

        return true;
    }

    public void onUnauthorizedInstantiation(Component component) {
        throw new RestartResponseAtInterceptPageException(
                Login.class);
    }

    public boolean isActionAuthorized(Component component, Action action) {
        //System.out.println("Name:" + component.getClass().getName() + "\n Action:" + action.getName() + "\nUser:" + WiaSession.get().getUser());
        if (action.equals(Component.RENDER)) {
            if (roleManager.containClass(component.getClass().getName()))
             {
                if (WiaSession.get().getUser() != null) {
                    if(!roleManager.isAuthorized(WiaSession.get().getUser().getRole(), component.getClass().getName()))
                    {
                        WiaSession.get().setAccess(false);
                        return false;
                    }
                    return true;
                }
                return false;
            }
        }
        return true;
    }
}

in this situation i have a googlemap in one of my protectedpage and because googlemap needs to read data for loading builing from a xml so i create a servlet which will create it dynamicly depending on the Username. this servlet is below:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ir.pnusn.branch.ui.pages;

import ir.pnusn.branch.database.BranchNotFoundException;



import ir.pnusn.branch.database.DatabaseException;
import ir.pnusn.branch.facade.admin.branchDataEnter.BranchDataSubmitFacade;
import ir.pnusn.branch.facade.admin.branchDataEnter.BuildingBean;


import java.util.Iterator;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.markup.html.WebPage;

/**
 *
 * @author mohammad
 */
public class CategoriesXML extends WebPage
{

    public CategoriesXML(PageParameters parameters)
    {
        System.out.println("user " + parameters.getString("user"));
        StringBuilder builder = new StringBuilder("<markers>");
        List<BuildingBean> buildings;
        try
        {
            buildings = BranchDataSubmitFacade.createBranchDataSubmitFacade(parameters.getString("user")).getBranchSecondPageData();
            for (Iterator<BuildingBean> it = buildings.iterator(); it.hasNext();)
            {
                BuildingBean buildingBean = it.next();
                builder.append("<marker lat=\"");
                builder.append(buildingBean.getLatit());
                builder.append("\" lng=\"");
                builder.append(buildingBean.getLongit());
                builder.append("\"");
                builder.append(" address=\"");
                builder.append(buildingBean.getDesctiption());
                builder.append("\" category=\"branch\" name=\"");
                builder.append(buildingBean.getBuildingName());
                builder.append("\"/>");

            }
            builder.append("</markers>");

        }
        catch (DatabaseException ex)
        {
            builder = new StringBuilder("<markers></markers>");
        }
        catch (BranchNotFoundException ex)
        {
            builder = new StringBuilder("<markers></markers>");
        }
        RequestCycle.get().getResponse().println(builder.toString());
        /*"<markers>" +
        "<marker lat=\"35.69187\" lng=\"51.413269\" address=\"Some stuff to display in the First Info Window\"  category=\"branch\" name=\"gholi\"/>" +
        "<marker lat=\"52.91892\"  lng=\"78.89231\" address=\"Some stuff to display in the Second Info Window\" category=\"branch\" name=\"taghi\"/>" +
        "<marker lat=\"40.82589\"  lng=\"35.10040\" address=\"Some stuff to display in the Third Info Window\"  category=\"branch\" name=\"naghi\"/>" +
        "</markers> "**/
    }
}

I have made this page at first protected and so the user had to loged in to have access this xml but after lot’s of debuging i found that googlemap can’t log in my system so instead of parsing the dataxml it pars login page html az input. so i changed the extention of the CategoriesXML to extend WebPage.
But now I have another problem:
When i go to the google map page in my Social site I can Not refresh the page because It expires and so I cannot add another building to my data xml.
what should I do?
tell me if you need more code or information

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:11:56+00:00Added an answer on May 12, 2026 at 5:11 pm

    In trying to close this question, which the OP seems to have pretty much abandoned, I’ll just post my old comment as an answer..:

    In your CategoriesXML I would highly advise against building and adding your tags as Strings and adding them to pages just like that. See if you can work this into a in your .xml(?) file instead, as that’s the Wicket way to do things (and as such just might solve the problems you’re having)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.