Example usage for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy MetaDataRoleAuthorizationStrategy

List of usage examples for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy MetaDataRoleAuthorizationStrategy

Introduction

In this page you can find the example usage for org.apache.wicket.authroles.authorization.strategies.role.metadata MetaDataRoleAuthorizationStrategy MetaDataRoleAuthorizationStrategy.

Prototype

public MetaDataRoleAuthorizationStrategy(final IRoleCheckingStrategy roleCheckingStrategy) 

Source Link

Document

Construct.

Usage

From source file:br.com.ieptbto.cra.security.UserRoleAuthorizationStrategy.java

License:Open Source License

public UserRoleAuthorizationStrategy(final IRoleCheckingStrategy roleCheckingStrategy) {
    add(new AnnotationsRoleAuthorizationStrategy(roleCheckingStrategy));
    add(new MetaDataRoleAuthorizationStrategy(roleCheckingStrategy));
}

From source file:de.inren.frontend.application.InRenApplication.java

License:Apache License

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

    /* Spring injection. */
    this.getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    /* Performance measurement */
    if (false) {/*from   w  w  w  .j a v  a  2 s . c  o m*/
        getComponentInstantiationListeners().add(new RenderPerformanceListener());
    }

    configureBootstrap();

    initializeServices();

    getSecuritySettings().setAuthorizationStrategy(new MetaDataRoleAuthorizationStrategy(this));

    initializeFailSafeLocalize();
    new AnnotatedMountScanner().scanPackage("de.inren").mount(this);

    mountResource("/" + PictureResource.PICTURE_RESOURCE + "/${" + PictureResource.ID + "}/${"
            + PictureResource.SIZE + "}", PictureResource.asReference());

    // Access to Images by url
    // mount(createImageURIRequestTargetUrlCodingStrategy());
    // mount(createLayoutURIRequestTargetUrlCodingStrategy());
    // mount(createThumbnailURIRequestTargetUrlCodingStrategy());

    // Render hints in html to navigate from firebug to eclipse
    // WicketSource.configure(this);

    // TODO gehrt ins codeflower package. => Init fr Wicket
    // module/packages machen.
    final IPackageResourceGuard packageResourceGuard = getResourceSettings().getPackageResourceGuard();
    if (packageResourceGuard instanceof SecurePackageResourceGuard) {
        ((SecurePackageResourceGuard) packageResourceGuard).addPattern("+*.json");
        ((SecurePackageResourceGuard) packageResourceGuard).addPattern("+**.ttf");
    }

    /** for ajax progressbar on upload */
    getApplicationSettings().setUploadProgressUpdatesEnabled(true);

    // I don't like messy html code.
    this.getMarkupSettings().setStripWicketTags(true);
    this.getMarkupSettings().setStripComments(true);

    // This application can be reached from internet, but you must know the
    // right port.
    // So I like to know who else besides me tries to connect.

    getRequestCycleListeners().add(new AbstractRequestCycleListener() {
        @Override
        public void onBeginRequest(RequestCycle cycle) {
            WebClientInfo ci = new WebClientInfo(cycle);
            log.debug("Request info: " + ci.getProperties().getRemoteAddress() + ", "
                    + ("".equals(DnsUtil.lookup(ci.getProperties().getRemoteAddress())) ? ""
                            : DnsUtil.lookup(ci.getProperties().getRemoteAddress()) + ", ")
                    + (cycle.getRequest().getUrl().getPath() == null
                            || "".equals(cycle.getRequest().getUrl().getPath()) ? ""
                                    : cycle.getRequest().getUrl().getPath() + ", ")
                    + ci.getUserAgent());
        }
    });

    getSecuritySettings().setAuthorizationStrategy(new InRenAuthorizationStrategy());

    // MetaDataRoleAuthorizationStrategy.authorize(AdminOnlyPage.class,
    // Roles.ADMIN);
    // mountPage("admin", AdminOnlyPage.class);

    // TODO das funzzt nur auf Class

    // LIST<COMPONENTACCESS> COMPONENTACCESS =
    // COMPONENTACCESSSERVICE.GETCOMPONENTACCESSLIST();
    // FOR (COMPONENTACCESS CA : COMPONENTACCESS) {
    // COLLECTION<ROLE> ROLES = CA.GETGRANTEDROLES();
    // STRINGBUFFER ROLESTRING = NEW STRINGBUFFER();
    // FOR (ROLE ROLE : ROLES) {
    // ROLESTRING.APPEND(ROLE);
    // }
    // METADATAROLEAUTHORIZATIONSTRATEGY.AUTHORIZE(CA.GETNAME(),
    // ROLESTRING.TOSTRING());
    // }
}

From source file:de.tudarmstadt.ukp.csniper.webapp.WicketApplication.java

License:Apache License

@Override
public void init() {
    addResourceReplacement(WiQueryCoreThemeResourceReference.get(), theme);

    if (!isInitialized) {
        super.init();

        getRequestCycleSettings().setTimeout(Duration.minutes(10));

        getComponentInstantiationListeners().add(new SpringComponentInjector(this));

        CompoundAuthorizationStrategy autr = new CompoundAuthorizationStrategy();
        autr.add(new AnnotationsRoleAuthorizationStrategy(this));
        autr.add(new MetaDataRoleAuthorizationStrategy(this));
        getSecuritySettings().setAuthorizationStrategy(autr);

        mountPage("/login.html", getSignInPageClass());
        mountPage("/analysis.html", AnalysisPage.class);
        mountPage("/evaluation.html", EvaluationPage.class);
        mountPage("/project.html", ProjectPage.class);
        mountPage("/type.html", AnnotationTypePage.class);
        mountPage("/statistics.html", StatisticsPage.class);
        mountPage("/statistics2.html", StatisticsPage2.class);
        //         mountPage("/export.html", ExportPage.class);
        mountPage("/search.html", SearchPage.class);
        mountPage("/welcome.html", getHomePage());
        //         mountPage("/exportHtml.html", ExportHtmlPage.class);
        mountPage("/users.html", ManageUsersPage.class);

        isInitialized = true;//from w  ww  .  ja v a  2s .com
    }
}

From source file:org.apache.syncope.client.console.SyncopeConsoleApplication.java

License:Apache License

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

    // read console.properties
    Properties props = new Properties();
    try (InputStream is = getClass().getResourceAsStream("/" + CONSOLE_PROPERTIES)) {
        props.load(is);//from  w w w . j  a v a2s. c o  m
        File consoleDir = new File(props.getProperty("console.directory"));
        if (consoleDir.exists() && consoleDir.canRead() && consoleDir.isDirectory()) {
            File consoleDirProps = FileUtils.getFile(consoleDir, CONSOLE_PROPERTIES);
            if (consoleDirProps.exists() && consoleDirProps.canRead() && consoleDirProps.isFile()) {
                props.clear();
                props.load(FileUtils.openInputStream(consoleDirProps));
            }
        }
    } catch (Exception e) {
        throw new WicketRuntimeException("Could not read " + CONSOLE_PROPERTIES, e);
    }
    version = props.getProperty("version");
    Args.notNull(version, "<version> not set");
    site = props.getProperty("site");
    Args.notNull(site, "<site> not set");
    anonymousUser = props.getProperty("anonymousUser");
    Args.notNull(anonymousUser, "<anonymousUser> not set");
    anonymousKey = props.getProperty("anonymousKey");
    Args.notNull(anonymousKey, "<anonymousKey> not set");

    String scheme = props.getProperty("scheme");
    Args.notNull(scheme, "<scheme> not set");
    String host = props.getProperty("host");
    Args.notNull(host, "<host> not set");
    String port = props.getProperty("port");
    Args.notNull(port, "<port> not set");
    String rootPath = props.getProperty("rootPath");
    Args.notNull(rootPath, "<rootPath> not set");
    String useGZIPCompression = props.getProperty("useGZIPCompression");
    Args.notNull(rootPath, "<useGZIPCompression> not set");

    clientFactory = new SyncopeClientFactoryBean()
            .setAddress(scheme + "://" + host + ":" + port + "/" + rootPath)
            .setUseCompression(BooleanUtils.toBoolean(useGZIPCompression));

    // process page properties
    pageClasses = new HashMap<>();
    populatePageClasses(props);
    pageClasses = Collections.unmodifiableMap(pageClasses);

    // Application settings
    IBootstrapSettings settings = new BootstrapSettings();

    // set theme provider
    settings.setThemeProvider(new SingleThemeProvider(new AdminLTE()));

    // install application settings
    Bootstrap.install(this, settings);

    getResourceSettings().setUseMinifiedResources(true);

    getResourceSettings().setThrowExceptionOnMissingResource(true);

    getJavaScriptLibrarySettings().setJQueryReference(new DynamicJQueryResourceReference());

    getSecuritySettings().setAuthorizationStrategy(new MetaDataRoleAuthorizationStrategy(this));

    ClassPathScanImplementationLookup lookup = (ClassPathScanImplementationLookup) getServletContext()
            .getAttribute(ConsoleInitializer.CLASSPATH_LOOKUP);
    for (Class<? extends BasePage> clazz : lookup.getPageClasses()) {
        MetaDataRoleAuthorizationStrategy.authorize(clazz, SyncopeConsoleSession.AUTHENTICATED);
    }

    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setCompressWhitespace(true);

    getRequestCycleListeners().add(new SyncopeConsoleRequestCycleListener());

    mountPage("/login", getSignInPageClass());

    activitiModelerDirectory = props.getProperty("activitiModelerDirectory");
    Args.notNull(activitiModelerDirectory, "<activitiModelerDirectory> not set");

    try {
        reconciliationReportKey = props.getProperty("reconciliationReportKey");
    } catch (NumberFormatException e) {
        LOG.error("While parsing reconciliationReportKey", e);
    }
    Args.notNull(reconciliationReportKey, "<reconciliationReportKey> not set");

    mountResource("/" + ACTIVITI_MODELER_CONTEXT, new ResourceReference(ACTIVITI_MODELER_CONTEXT) {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new FilesystemResource(ACTIVITI_MODELER_CONTEXT, activitiModelerDirectory);
        }

    });
    mountResource("/workflowDefGET", new ResourceReference("workflowDefGET") {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new WorkflowDefGETResource();
        }
    });
    mountResource("/workflowDefPUT", new ResourceReference("workflowDefPUT") {

        private static final long serialVersionUID = -128426276529456602L;

        @Override
        public IResource getResource() {
            return new WorkflowDefPUTResource();
        }
    });

    // enable component path
    if (getDebugSettings().isAjaxDebugModeEnabled()) {
        getDebugSettings().setComponentPathAttributeName("syncope-path");
    }
}

From source file:org.wicketTutorial.metadataroles.WicketApplication.java

License:Apache License

@Override
public void init() {
    getSecuritySettings().setAuthorizationStrategy(new MetaDataRoleAuthorizationStrategy(this));
    MetaDataRoleAuthorizationStrategy.authorize(AdminOnlyPage.class, Roles.ADMIN);
}