public boolean checkCredential (Object suppliedCredential) { return this.user.checkCredential(suppliedCredential); } }
public void unsetJAASInfo (Subject subject) { subject.getPrincipals().remove(this.principal); subject.getPrivateCredentials().remove(this.user.getCredential()); subject.getPrincipals().removeAll(this.roles); }
public void setUserInfo (UserInfo u) { this.user = u; this.principal = new JAASPrincipal(u.getUserName()); this.roles = new ArrayList<JAASRole>(); if (u.getRoleNames() != null) { Iterator<String> itor = u.getRoleNames().iterator(); while (itor.hasNext()) this.roles.add(new JAASRole((String)itor.next())); } }
statement.close(); return dbCredential==null ? null : new UserInfo (userName, Credential.getCredential(dbCredential), roles);
public String getUserName () { return this.user.getUserName(); }
/** * Don't implement this as we want to pre-fetch all of the users. * * @param userName * @throws Exception */ public UserInfo getUserInfo(String userName) throws Exception { PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename); if (propertyUserStore == null) throw new IllegalStateException("PropertyUserStore should never be null here!"); LOG.debug("Checking PropertyUserStore "+_filename+" for "+userName); UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName); if (userIdentity==null) return null; Set<Principal> principals = userIdentity.getSubject().getPrincipals(); List<String> roles = new ArrayList<String>(); for ( Principal principal : principals ) { roles.add( principal.getName() ); } Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next(); LOG.debug("Found: " + userName + " in PropertyUserStore "+_filename); return new UserInfo(userName, credential, roles); }
public String getUserName () { return this.user.getUserName(); }
public void setUserInfo (UserInfo u) { this.user = u; this.principal = new JAASPrincipal(u.getUserName()); this.roles = new ArrayList<JAASRole>(); if (u.getRoleNames() != null) { Iterator<String> itor = u.getRoleNames().iterator(); while (itor.hasNext()) this.roles.add(new JAASRole((String)itor.next())); } }
statement.close(); return dbCredential==null ? null : new UserInfo (userName, Credential.getCredential(dbCredential), roles);
public void setJAASInfo (Subject subject) { subject.getPrincipals().add(this.principal); subject.getPrivateCredentials().add(this.user.getCredential()); subject.getPrincipals().addAll(roles); }
public boolean checkCredential (Object suppliedCredential) { return this.user.checkCredential(suppliedCredential); } }
/** * Don't implement this as we want to pre-fetch all of the users. * * @param userName * @throws Exception */ public UserInfo getUserInfo(String userName) throws Exception { PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename); if (propertyUserStore == null) throw new IllegalStateException("PropertyUserStore should never be null here!"); LOG.debug("Checking PropertyUserStore "+_filename+" for "+userName); UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName); if (userIdentity==null) return null; Set<Principal> principals = userIdentity.getSubject().getPrincipals(); List<String> roles = new ArrayList<String>(); for ( Principal principal : principals ) { roles.add( principal.getName() ); } Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next(); LOG.debug("Found: " + userName + " in PropertyUserStore "+_filename); return new UserInfo(userName, credential, roles); }
public void setJAASInfo (Subject subject) { subject.getPrincipals().add(this.principal); subject.getPrivateCredentials().add(this.user.getCredential()); subject.getPrincipals().addAll(roles); }
/** * binding authentication check * This method of authentication works only if the user branch of the DIT (ldap tree) * has an ACI (access control instruction) that allow the access to any user or at least * for the user that logs in. * * @param username * @param password * @return true always * @throws LoginException */ public boolean bindingLogin(String username, Object password) throws LoginException, NamingException { SearchResult searchResult = findUser(username); String userDn = searchResult.getNameInNamespace(); LOG.info("Attempting authentication: " + userDn); Hashtable<Object,Object> environment = getEnvironment(); environment.put(Context.SECURITY_PRINCIPAL, userDn); environment.put(Context.SECURITY_CREDENTIALS, password); DirContext dirContext = new InitialDirContext(environment); List<String> roles = getUserRolesByDn(dirContext, userDn); UserInfo userInfo = new UserInfo(username, null, roles); setCurrentUser(new JAASUserInfo(userInfo)); setAuthenticated(true); return true; }
public void unsetJAASInfo (Subject subject) { subject.getPrincipals().remove(this.principal); subject.getPrivateCredentials().remove(this.user.getCredential()); subject.getPrincipals().removeAll(this.roles); }
/** * get the available information about the user * <p/> * for this LoginModule, the credential can be null which will result in a * binding ldap authentication scenario * <p/> * roles are also an optional concept if required * * @param username * @return the userinfo for the username * @throws Exception */ public UserInfo getUserInfo(String username) throws Exception { String pwdCredential = getUserCredentials(username); if (pwdCredential == null) { return null; } pwdCredential = convertCredentialLdapToJetty(pwdCredential); Credential credential = Credential.getCredential(pwdCredential); List<String> roles = getUserRoles(_rootContext, username); return new UserInfo(username, credential, roles); }
/** * binding authentication check * This method of authentication works only if the user branch of the DIT (ldap tree) * has an ACI (access control instruction) that allow the access to any user or at least * for the user that logs in. * * @param username * @param password * @return true always * @throws LoginException */ public boolean bindingLogin(String username, Object password) throws LoginException, NamingException { SearchResult searchResult = findUser(username); String userDn = searchResult.getNameInNamespace(); LOG.info("Attempting authentication: " + userDn); Hashtable<Object,Object> environment = getEnvironment(); environment.put(Context.SECURITY_PRINCIPAL, userDn); environment.put(Context.SECURITY_CREDENTIALS, password); DirContext dirContext = new InitialDirContext(environment); List<String> roles = getUserRolesByDn(dirContext, userDn); UserInfo userInfo = new UserInfo(username, null, roles); setCurrentUser(new JAASUserInfo(userInfo)); setAuthenticated(true); return true; }
/** * get the available information about the user * <p/> * for this LoginModule, the credential can be null which will result in a * binding ldap authentication scenario * <p/> * roles are also an optional concept if required * * @param username * @return the userinfo for the username * @throws Exception */ public UserInfo getUserInfo(String username) throws Exception { String pwdCredential = getUserCredentials(username); if (pwdCredential == null) { return null; } pwdCredential = convertCredentialLdapToJetty(pwdCredential); Credential credential = Credential.getCredential(pwdCredential); List<String> roles = getUserRoles(_rootContext, username); return new UserInfo(username, credential, roles); }