1 17 package org.alfresco.repo.security.authentication.ntlm; 18 19 import net.sf.acegisecurity.GrantedAuthority; 20 import net.sf.acegisecurity.providers.*; 21 22 28 public class NTLMLocalToken extends UsernamePasswordAuthenticationToken 29 { 30 private static final long serialVersionUID = -7946514578455279387L; 31 32 35 protected NTLMLocalToken() 36 { 37 super(null, null); 38 } 39 40 46 public NTLMLocalToken(String username, String plainPwd) { 47 super(username.toLowerCase(), plainPwd); 48 } 49 50 55 public final boolean isGuestLogon() 56 { 57 return hasAuthority(NTLMAuthenticationProvider.NTLMAuthorityGuest); 58 } 59 60 65 public final boolean isAdministrator() 66 { 67 return hasAuthority(NTLMAuthenticationProvider.NTLMAuthorityAdministrator); 68 } 69 70 76 public final boolean hasAuthority(String authority) 77 { 78 boolean found = false; 79 GrantedAuthority[] authorities = getAuthorities(); 80 81 if ( authorities != null && authorities.length > 0) 82 { 83 85 int i = 0; 86 87 while ( found == false && i < authorities.length) 88 { 89 if ( authorities[i++].getAuthority().equals(authority)) 90 found = true; 91 } 92 } 93 94 96 return found; 97 } 98 } 99 | Popular Tags |