Search in sources :

Example 76 with Secured

use of org.springframework.security.access.annotation.Secured in project cia by Hack23.

the class ConfigurationManagerImpl method getUserConfiguration.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public UserConfiguration getUserConfiguration(final String url, final String locale) {
    final Agency agency = agencyDAO.getAll().get(0);
    Portal usePortal = null;
    final LanguageData languageData = findLanguage(locale);
    for (final Portal portal : agency.getPortals()) {
        if (usePortal == null && PortalType.DEFAULT == portal.getPortalType() || url.contains(portal.getPortalName())) {
            usePortal = portal;
        }
    }
    return new UserConfigurationImpl(agency, usePortal, languageData);
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) LanguageData(com.hack23.cia.model.internal.application.system.impl.LanguageData) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 77 with Secured

use of org.springframework.security.access.annotation.Secured in project cia by Hack23.

the class ConfigurationManagerImpl method createDefaultConfigIfEmpty.

@Secured({ "ROLE_ADMIN" })
@Override
public void createDefaultConfigIfEmpty() {
    if (agencyDAO.getAll().isEmpty()) {
        final List<Portal> portals = new ArrayList<>();
        final Portal defaulPortal = new Portal().withPortalType(PortalType.DEFAULT).withDescription("Global Portal").withPortalName("Default");
        portals.add(defaulPortal);
        final Portal domainPortal = new Portal().withPortalType(PortalType.DOMAIN).withDescription("Hack23.com").withPortalName("www.hack23.com");
        portals.add(domainPortal);
        final Agency agency = new Agency().withAgencyName("Citizen Intelligence Agency").withDescription("Tracking politicians like bugs");
        agency.setPortals(portals);
        agencyDAO.persist(agency);
    }
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) ArrayList(java.util.ArrayList) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 78 with Secured

use of org.springframework.security.access.annotation.Secured in project cia by Hack23.

the class MainViewLoginPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    panel.setCaption(NAME + "::" + CITIZEN_INTELLIGENCE_AGENCY_MAIN);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    final VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSizeFull();
    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    loginLayout.addComponent(formPanel);
    final FormLayout formContent = new FormLayout();
    formContent.setIcon(VaadinIcons.SIGN_IN);
    formPanel.setContent(formContent);
    final LoginRequest loginRequest = new LoginRequest();
    loginRequest.setOtpCode("");
    loginRequest.setEmail("");
    loginRequest.setUserpassword("");
    loginRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    final ClickListener loginListener = new ApplicationLoginListener(loginRequest);
    getFormFactory().addRequestInputFormFields(formContent, loginRequest, LoginRequest.class, AS_LIST, LOGIN, loginListener);
    final VerticalLayout overviewLayout = new VerticalLayout();
    overviewLayout.setSizeFull();
    content.addComponent(overviewLayout);
    content.setExpandRatio(overviewLayout, ContentRatio.LARGE);
    final ResponsiveRow grid = createGridLayout(overviewLayout);
    createRowComponent(grid, loginLayout, REGISTER_A_NEW_USER);
    panel.setCaption(NAME + "::" + CITIZEN_INTELLIGENCE_AGENCY_MAIN);
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MAIN_VIEW, ApplicationEventGroup.USER, CommonsViews.MAIN_VIEW_NAME, parameters, pageId);
    return content;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Panel(com.vaadin.ui.Panel) ApplicationLoginListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.ApplicationLoginListener) ResponsiveRow(com.jarektoro.responsivelayout.ResponsiveRow) VerticalLayout(com.vaadin.ui.VerticalLayout) LoginRequest(com.hack23.cia.service.api.action.application.LoginRequest) ClickListener(com.vaadin.ui.Button.ClickListener) Secured(org.springframework.security.access.annotation.Secured)

Example 79 with Secured

use of org.springframework.security.access.annotation.Secured in project cia by Hack23.

the class MainViewRegisterPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    final VerticalLayout registerLayout = new VerticalLayout();
    registerLayout.setSizeFull();
    final Panel formPanel = new Panel();
    formPanel.setSizeFull();
    registerLayout.addComponent(formPanel);
    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);
    final RegisterUserRequest reqisterRequest = new RegisterUserRequest();
    reqisterRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    reqisterRequest.setUsername("");
    reqisterRequest.setEmail("");
    reqisterRequest.setCountry("");
    reqisterRequest.setUserpassword("");
    final ClickListener reqisterListener = new RegisterUserClickListener(reqisterRequest);
    getFormFactory().addRequestInputFormFields(formContent, reqisterRequest, RegisterUserRequest.class, AS_LIST, REGISTER, reqisterListener);
    final VerticalLayout overviewLayout = new VerticalLayout();
    overviewLayout.setSizeFull();
    content.addComponent(overviewLayout);
    content.setExpandRatio(overviewLayout, ContentRatio.LARGE);
    final ResponsiveRow grid = createGridLayout(overviewLayout);
    createRowComponent(grid, registerLayout, "Register a new user");
    panel.setCaption(NAME + "::" + CITIZEN_INTELLIGENCE_AGENCY_MAIN);
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MAIN_VIEW, ApplicationEventGroup.USER, CommonsViews.MAIN_VIEW_NAME, parameters, pageId);
    return content;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Panel(com.vaadin.ui.Panel) RegisterUserRequest(com.hack23.cia.service.api.action.application.RegisterUserRequest) ResponsiveRow(com.jarektoro.responsivelayout.ResponsiveRow) VerticalLayout(com.vaadin.ui.VerticalLayout) RegisterUserClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.RegisterUserClickListener) ClickListener(com.vaadin.ui.Button.ClickListener) RegisterUserClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.RegisterUserClickListener) Secured(org.springframework.security.access.annotation.Secured)

Example 80 with Secured

use of org.springframework.security.access.annotation.Secured in project cia by Hack23.

the class BallotOverviewPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    final String pageId = getPageId(parameters);
    final DataContainer<ViewRiksdagenVoteDataBallotSummary, RiksdagenVoteDataBallotEmbeddedId> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenVoteDataBallotSummary.class);
    final DataContainer<ViewRiksdagenVoteDataBallotPartySummary, RiksdagenVoteDataBallotPartyEmbeddedId> dataPartyContainer = getApplicationManager().getDataContainer(ViewRiksdagenVoteDataBallotPartySummary.class);
    final DataContainer<ViewRiksdagenCommitteeBallotDecisionSummary, ViewRiksdagenCommitteeBallotDecisionEmbeddedId> dataDecisionContainer = getApplicationManager().getDataContainer(ViewRiksdagenCommitteeBallotDecisionSummary.class);
    final List<ViewRiksdagenVoteDataBallotSummary> ballots = dataContainer.findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotSummary.class, ViewRiksdagenVoteDataBallotSummary_.embeddedId, RiksdagenVoteDataBallotEmbeddedId.class, RiksdagenVoteDataBallotEmbeddedId_.ballotId, pageId);
    final List<ViewRiksdagenVoteDataBallotPartySummary> partyBallotList = dataPartyContainer.findListByEmbeddedProperty(ViewRiksdagenVoteDataBallotPartySummary.class, ViewRiksdagenVoteDataBallotPartySummary_.embeddedId, RiksdagenVoteDataBallotPartyEmbeddedId.class, RiksdagenVoteDataBallotPartyEmbeddedId_.ballotId, pageId);
    final List<ViewRiksdagenCommitteeBallotDecisionSummary> decisionSummaries = dataDecisionContainer.getAllBy(ViewRiksdagenCommitteeBallotDecisionSummary_.ballotId, pageId);
    if (!ballots.isEmpty()) {
        getBallotMenuItemFactory().createBallotMenuBar(menuBar, pageId);
        LabelFactory.createHeader2Label(panelContent, OVERVIEW);
        for (final ViewRiksdagenVoteDataBallotSummary viewRiksdagenVoteDataBallotSummary : ballots) {
            if (!decisionSummaries.isEmpty()) {
                getFormFactory().addFormPanelTextFields(panelContent, decisionSummaries.get(FIRST_OBJECT), ViewRiksdagenCommitteeBallotDecisionSummary.class, AS_LIST);
            } else {
                getFormFactory().addFormPanelTextFields(panelContent, viewRiksdagenVoteDataBallotSummary, ViewRiksdagenVoteDataBallotSummary.class, AS_LIST2);
            }
        }
        getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent, ViewRiksdagenVoteDataBallotPartySummary.class, partyBallotList, PARTY_BALLOT_SUMMARY, NESTED_PROPERTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, EMBEDDED_ID_PARTY, null);
        final VerticalLayout overviewLayout = new VerticalLayout();
        overviewLayout.setSizeFull();
        panelContent.addComponent(overviewLayout);
        panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);
        getBallotMenuItemFactory().createOverviewPage(overviewLayout, pageId);
        panel.setCaption(NAME + "::" + BALLOT + pageId);
        getPageActionEventHelper().createPageEvent(ViewAction.VISIT_BALLOT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    }
    return panelContent;
}
Also used : RiksdagenVoteDataBallotPartyEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotPartyEmbeddedId) ViewRiksdagenVoteDataBallotPartySummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotPartySummary) ViewRiksdagenCommitteeBallotDecisionEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionEmbeddedId) ViewRiksdagenCommitteeBallotDecisionSummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionSummary) ViewRiksdagenVoteDataBallotSummary(com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenVoteDataBallotSummary) VerticalLayout(com.vaadin.ui.VerticalLayout) RiksdagenVoteDataBallotEmbeddedId(com.hack23.cia.model.internal.application.data.committee.impl.RiksdagenVoteDataBallotEmbeddedId) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

Secured (org.springframework.security.access.annotation.Secured)260 VerticalLayout (com.vaadin.ui.VerticalLayout)117 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)52 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)23 HorizontalLayout (com.vaadin.ui.HorizontalLayout)20 CollectSurvey (org.openforis.collect.model.CollectSurvey)20 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)18 Contract (org.asqatasun.entity.contract.Contract)17 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)16 Timed (com.codahale.metrics.annotation.Timed)14 ViewRiksdagenParty (com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty)14 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)14 URI (java.net.URI)14 User (org.asqatasun.entity.user.User)14 ViewRiksdagenCommittee (com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee)13 ViewRiksdagenPolitician (com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician)13 SessionState (org.openforis.collect.web.session.SessionState)13 CollectRecord (org.openforis.collect.model.CollectRecord)12 DocumentElement (com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement)11 ArrayList (java.util.ArrayList)11