Examples of Authorization


Examples of org.mortbay.jetty.client.security.Authorization

            if (_destination.isProxied() && uri.startsWith("/"))
            {
                // TODO suppress port 80 or 443
                uri = (_destination.isSecure()?HttpSchemes.HTTPS:HttpSchemes.HTTP) + "://" + _destination.getAddress().getHost() + ":"
                        + _destination.getAddress().getPort() + uri;
                Authorization auth = _destination.getProxyAuthentication();
                if (auth != null)
                    auth.setCredentials(_exchange);
            }

            _generator.setRequest(_exchange._method,uri);

            if (_exchange._version >= HttpVersions.HTTP_1_1_ORDINAL)
View Full Code Here

Examples of org.nemesis.forum.Authorization

  public static Authorization getUserAuthorization(HttpServletRequest request, HttpServletResponse response, boolean checkCookie) {
    // we can get the session object from the request object:
    HttpSession session = request.getSession();

    // Check 1: check for the  authentication token in the user's session.
    Authorization authToken = (Authorization) session.getAttribute(AUTH_TOKEN);
    if (authToken != null) {
      return authToken;
    }

    // Check 2: check the  cookie for username and password, if we're allowing that
View Full Code Here

Examples of org.ofbiz.security.authz.Authorization

            GenericValue userLogin = (GenericValue) context.get("userLogin");
            if (userLogin != null) {
                String permission = permissionExdr.expandString(context);
                String action = actionExdr.expandString(context);

                Authorization authz = (Authorization) context.get("authorization");
                Security security = (Security) context.get("security");
                if (UtilValidate.isNotEmpty(action)) {
                    //Debug.logWarning("Deprecated method hasEntityPermission() was called; the action field should no longer be used", module);
                    // run hasEntityPermission
                    if (security.hasEntityPermission(permission, action, userLogin)) {
                        return true;
                    }
                } else {
                    // run hasPermission
                    if (authz.hasPermission(userLogin.getString("userLoginId"), permission, context)) {
                        return true;
                    }
                }
            }
            return false;
View Full Code Here

Examples of org.osforce.connect.entity.oauth.Authorization

  @RequestMapping(value="/authorized", method=RequestMethod.GET)
    public @ResponseBody Map<String, Object> isAuthorized(
        @RequestParam String target, HttpSession session) {
    Long userId = (Long) session.getAttribute(AttributeKeys.USER_ID_KEY);
    Authorization authorization = authorizationService.getAuthorization(target, userId);
    //
    Map<String, Object> model = CollectionUtil.newHashMap();
    model.put("authorized", authorization!=null);
      return model;
    }
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

                             + " logged in, but was logged out since "
                             + " no console service is available.");
                    sessionEnd(null);
                } else {
                    log.info("User " + telnetLogin.getUser() + " logged in");
                    Authorization authorization
                        = telnetLogin.getAuthorization();
                    s = consoleService.runSession("telnet session", reader,
                                                  printWriter);
                    Dictionary props = s.getProperties();
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

                                InputStream is = client.getInputStream();
                                InputStreamReader isr = new InputStreamReader(
                                        is);
                                BufferedReader in = new BufferedReader(isr);

                                Authorization authorization = null;
                                if (login.booleanValue()) {
                                    LoginResult loginResult = doLogin(client);
                                    if (loginResult.loginOK) {
                                        authorization = loginResult.authorization;
                                    } else {
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

            in.read();
            in.read();
            in.read(); // Read answer.
            out.println();

            Authorization authorization = null;
            boolean loginOK = false;
            ServiceReference sr = bc
                    .getServiceReference(PasswdAuthenticator.class.getName());
            if (sr == null) {
                if (requireUM.booleanValue()) {
                    log(LogService.LOG_WARNING,
                            "Failed to get PasswdAuthenticator reference. UM required but not present.");
                } else {
                    loginOK = (DEFAULT_USER_NAME.equals(userName) && DEFAULT_PASSWORD
                            .equals(password));
                }
            } else {
                PasswdAuthenticator pa = (PasswdAuthenticator) bc
                        .getService(sr);
                if (pa != null) {
                    PasswdSession ps = pa.createSession();
                    ps.setUsername(userName);
                    ps.setPassword(password);
                    ContextualAuthorization ca = null;
                    try {
                        ca = ps.getAuthorization();
                    } catch (IllegalStateException ex) {
                        log(LogService.LOG_WARNING,
                                "UserAdmin service not available.");
                    }
                    if (ca != null) {
                        if (requiredGroup != null && !ca.hasRole(requiredGroup)) {
                            loginOK = false;
                            log(
                                    LogService.LOG_INFO,
                                    userName
                                            + " tried to login, but did not have required role "
                                            + requiredGroup);
                        } else if (forbiddenGroup != null
                                && ca.hasRole(forbiddenGroup)) {
                            loginOK = false;
                            log(
                                    LogService.LOG_INFO,
                                    userName
                                            + " tried to login, but had forbidden role "
                                            + forbiddenGroup);
                        } else {
                            authorization = ca;
                            loginOK = true;
                            out.println("Logged in.");
                        }
                    }
                } else {
                    log(LogService.LOG_WARNING,
                            "Failed to get PasswdAuthenticator service.");
                }
                bc.ungetService(sr);
            }

            // Check if login successful:
            if (!loginOK) {
                out.println("Login failed!");
                client.close();
                log(LogService.LOG_INFO, "Login failed for " + userName);
                return new LoginResult();
            }

            // Set context:
            if (authorization instanceof ContextualAuthorization) {
                String authMethod = "passwd"; // TBD
                String inputPath = "tcp"; // TBD
                ((ContextualAuthorization) authorization).setIPAMContext(
                        inputPath, authMethod);
                Dictionary context = ((ContextualAuthorization) authorization)
                        .getContext();
                log(LogService.LOG_INFO, "User " + authorization.getName()
                        + " logged in, authentication context is " + context
                        + ".");
            } else if (authorization == null) {
                log(LogService.LOG_INFO, "Default user " + DEFAULT_USER_NAME
                        + " logged in.");
            } else {
                log(LogService.LOG_INFO, "User " + authorization.getName()
                        + " logged in.");
            }
            return new LoginResult(authorization);
        }
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

        Group group = (Group) m_userAdmin.createRole("group", Role.GROUP);
        group.addRequiredMember(reqGroup);
        group.addMember(user1);
        group.addMember(user2);

        Authorization auth = m_userAdmin.getAuthorization(user1);
        assertTrue(auth.hasRole("group"));
       
        auth = m_userAdmin.getAuthorization(user2);
        assertTrue(auth.hasRole("group"));
       
        auth = m_userAdmin.getAuthorization(user3);
        assertFalse(auth.hasRole("group"));
    }
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

    /**
     * Tests that obtaining the authorization for a non-existing user yields null.
     */
    public void testGetAuthorizationForAnonymousUserOk() {
        Authorization auth = m_userAdmin.getAuthorization(null);
       
        assertNotNull(auth);

        assertNull(auth.getRoles());
        assertNull(auth.getName());
    }
View Full Code Here

Examples of org.osgi.service.useradmin.Authorization

    /**
     * Tests that obtaining the authorization for a non-existing user yields null.
     */
    public void testGetAuthorizationForNonExistingUserOk() {
        User nonExistingUser = RoleFactory.createUser("non-existing-user");
        Authorization auth = m_userAdmin.getAuthorization(nonExistingUser);

        assertNotNull(auth);

        assertNull(auth.getRoles());
        assertNotNull(auth.getName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.