@Test public void testResolveLoginAliasToUserName() throws Exception { reset(servletRequestAttributes); RequestContextHolder.setRequestAttributes(servletRequestAttributes); expect(servletRequestAttributes.getAttribute(eq("loginAlias1"), eq(RequestAttributes.SCOPE_SESSION))) .andReturn("user1").atLeastOnce(); replay(servletRequestAttributes); String user = AuthorizationHelper.resolveLoginAliasToUserName("loginAlias1"); verify(servletRequestAttributes); assertEquals("user1", user); }
public static String resolveLoginAliasToUserName(String loginAlias) { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attr != null && attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION) != null) { return (String)attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION); } return loginAlias; }
AuthorizationHelper { public static String resolveLoginAliasToUserName(String loginAlias) { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attr != null && attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION) != null) { return (String)attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION); } return loginAlias; } }
AuthorizationHelper { public static String resolveLoginAliasToUserName(String loginAlias) { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attr != null && attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION) != null) { return (String)attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION); } return loginAlias; }  }
AuthorizationHelper { public static String resolveLoginAliasToUserName(String loginAlias) { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attr != null && attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION) != null) { return (String)attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION); } return loginAlias; }  Collection<GrantedAuthority> convertPrivilegesToAuthorities(Collection<PrivilegeEntity> privilegeEntities); static String getAuthenticatedName(); static String getAuthenticatedName(String defaultUsername); static int getAuthenticatedId(); static boolean isAuthorized(ResourceType resourceType, Long resourceId, 
                                     RoleAuthorization requiredAuthorization); static boolean isAuthorized(ResourceType resourceType, Long resourceId, 
                                     Set<RoleAuthorization> requiredAuthorizations); static boolean isAuthorized(Authentication authentication, ResourceType resourceType,
                                     Long resourceId, RoleAuthorization requiredAuthorization); static boolean isAuthorized(Authentication authentication, ResourceType resourceType,
                                     Long resourceId, Set<RoleAuthorization> requiredAuthorizations); static void verifyAuthorization(ResourceType resourceType,
                                         Long resourceId,
                                         Set<RoleAuthorization> requiredAuthorizations); static void verifyAuthorization(Authentication authentication,
                                         ResourceType resourceType,
                                         Long resourceId,
                                         Set<RoleAuthorization> requiredAuthorizations); static Authentication getAuthentication(); static void addLoginNameAlias(String ambariUserName, String loginAlias); static String resolveLoginAliasToUserName(String loginAlias); static List<String> getAuthorizationNames(Authentication authentication); }
AuthorizationHelper { public static String resolveLoginAliasToUserName(String loginAlias) { ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (attr != null && attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION) != null) { return (String)attr.getAttribute(loginAlias, RequestAttributes.SCOPE_SESSION); } return loginAlias; }  Collection<GrantedAuthority> convertPrivilegesToAuthorities(Collection<PrivilegeEntity> privilegeEntities); static String getAuthenticatedName(); static String getAuthenticatedName(String defaultUsername); static int getAuthenticatedId(); static boolean isAuthorized(ResourceType resourceType, Long resourceId, 
                                     RoleAuthorization requiredAuthorization); static boolean isAuthorized(ResourceType resourceType, Long resourceId, 
                                     Set<RoleAuthorization> requiredAuthorizations); static boolean isAuthorized(Authentication authentication, ResourceType resourceType,
                                     Long resourceId, RoleAuthorization requiredAuthorization); static boolean isAuthorized(Authentication authentication, ResourceType resourceType,
                                     Long resourceId, Set<RoleAuthorization> requiredAuthorizations); static void verifyAuthorization(ResourceType resourceType,
                                         Long resourceId,
                                         Set<RoleAuthorization> requiredAuthorizations); static void verifyAuthorization(Authentication authentication,
                                         ResourceType resourceType,
                                         Long resourceId,
                                         Set<RoleAuthorization> requiredAuthorizations); static Authentication getAuthentication(); static void addLoginNameAlias(String ambariUserName, String loginAlias); static String resolveLoginAliasToUserName(String loginAlias); static List<String> getAuthorizationNames(Authentication authentication);  }