JAASLoginService jaasLoginService = new JAASLoginService( "Kettle" ); jaasLoginService.setLoginModuleName( System.getProperty( "loginmodulename" ) ); securityHandler.setLoginService( jaasLoginService ); } else {
JAASUserPrincipal userPrincipal = new JAASUserPrincipal(getUserName(callbackHandler), subject, loginContext); subject.getPrincipals().add(userPrincipal); return _identityService.newUserIdentity(subject,userPrincipal,getGroups(subject));
@SuppressWarnings({ "unchecked", "rawtypes" }) private String[] getGroups (Subject subject) { //get all the roles of the various types String[] roleClassNames = getRoleClassNames(); Collection<String> groups = new LinkedHashSet<String>(); try { for (String roleClassName : roleClassNames) { Class load_class = Thread.currentThread().getContextClassLoader().loadClass(roleClassName); Set<Principal> rolesForType = subject.getPrincipals(load_class); for (Principal principal : rolesForType) { groups.add(principal.getName()); } } return groups.toArray(new String[groups.size()]); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
case KERBEROS: case PAM: loginService = new JAASLoginService(config.loginType.jaasRealm); primaryAuthenticator = new BasicAuthenticator(); break;
/** * @see org.eclipse.jetty.plus.jaas.JAASLoginService#login(java.lang.String, java.lang.Object) */ @Override public UserIdentity login(String username, Object credentials) { String password = credentials.toString(); if (password.startsWith("SAML-BEARER-TOKEN:")) { //$NON-NLS-1$ return doSamlLogin(username, password.substring(18)); } else { return super.login(username, credentials); } }
JAASUserPrincipal userPrincipal = new JAASUserPrincipal(getUserName(callbackHandler), subject, loginContext); subject.getPrincipals().add(userPrincipal); return _identityService.newUserIdentity(subject,userPrincipal,getGroups(subject));
@SuppressWarnings({ "unchecked", "rawtypes" }) private String[] getGroups (Subject subject) { //get all the roles of the various types String[] roleClassNames = getRoleClassNames(); Collection<String> groups = new LinkedHashSet<String>(); try { for (String roleClassName : roleClassNames) { Class load_class = Thread.currentThread().getContextClassLoader().loadClass(roleClassName); Set<Principal> rolesForType = subject.getPrincipals(load_class); for (Principal principal : rolesForType) { groups.add(principal.getName()); } } return groups.toArray(new String[groups.size()]); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }