Package org.zanata.security

Examples of org.zanata.security.ZanataIdentity


        if (httpRequest.getRequestURI().equals(getMonitoringUrl(httpRequest))) {
            new ContextualHttpServletRequest((HttpServletRequest) request) {
                @Override
                public void process() throws Exception {
                    ZanataIdentity identity =
                            ServiceLocator.instance().getInstance(
                                    ZanataIdentity.class);
                    if (identity == null || !identity.isLoggedIn()) {
                        String signInUrl =
                                httpRequest.getContextPath()
                                        + "/account/sign_in";
                        httpResponse.sendRedirect(signInUrl);
                    } else if (!identity.hasRole("admin")) {
                        httpResponse.sendError(
                                HttpServletResponse.SC_UNAUTHORIZED,
                                "Only admin can access monitoring!");
                    }
                }
View Full Code Here


    public <V> ListenableFuture<V> startTask(
            final @Nonnull AsyncTask<Future<V>> task) {
        HAccount taskOwner = ServiceLocator.instance()
                .getInstance(ZanataJpaIdentityStore.AUTHENTICATED_USER,
                        HAccount.class);
        ZanataIdentity ownerIdentity = ZanataIdentity.instance();

        // Extract security context from current thread
        final String taskOwnerUsername =
                taskOwner != null ? taskOwner.getUsername() : null;
        final Principal runAsPpal = ownerIdentity.getPrincipal();
        final Subject runAsSubject = ownerIdentity.getSubject();

        // final result
        final AsyncTaskResult<V> taskFuture = new AsyncTaskResult<V>();

        final RunnableOperation runnableOp = new RunnableOperation() {
View Full Code Here

TOP

Related Classes of org.zanata.security.ZanataIdentity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.