ShiroAuthenticationService implements AuthenticationService { @Override public String getPrincipal() { Subject subject = org.apache.shiro.SecurityUtils.getSubject(); String principal; if (subject.isAuthenticated()) { principal = extractPrincipal(subject); if (conf.isUsernameForceLowerCase()) { LOGGER.debug("Converting principal name " + principal + " to lower case:" + principal.toLowerCase()); principal = principal.toLowerCase(); } } else { principal = "anonymous"; } return principal; } @Inject  ShiroAuthenticationService(ZeppelinConfiguration conf); @Override String getPrincipal(); @Override Collection<Realm> getRealmsList(); @Override boolean isAuthenticated(); @Override List<String> getMatchedUsers(String searchText, int numUsersToFetch); @Override List<String> getMatchedRoles(); @Override Set<String> getAssociatedRoles();  }
@Test public void canGetPrincipalName() { String expectedName = "java.security.Principal.getName()"; setupPrincipalName(expectedName); assertEquals(expectedName, shiroSecurityService.getPrincipal()); }
@Test public void testUsernameForceLowerCase() throws IOException, InterruptedException { String expectedName = "java.security.Principal.getName()"; System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_USERNAME_FORCE_LOWERCASE .getVarName(), String.valueOf(true)); setupPrincipalName(expectedName); assertEquals(expectedName.toLowerCase(), shiroSecurityService.getPrincipal()); System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_USERNAME_FORCE_LOWERCASE .getVarName(), String.valueOf(false)); }