1 24 package org.riotfamily.riot.security.auth; 25 26 import org.springframework.util.Assert; 27 28 32 public class StaticAuthenticationService implements AuthenticationService { 33 34 public static final String DEFAULT_USERNAME = "root"; 35 36 private static final RiotUser ROOT = new RootUser(); 37 38 private String username = DEFAULT_USERNAME; 39 40 private String password; 41 42 43 public void setPassword(String password) { 44 this.password = password; 45 } 46 47 public void setUsername(String username) { 48 this.username = username; 49 } 50 51 public RiotUser authenticate(String username, String password) { 52 Assert.notNull("No password set."); 53 if (this.username.equals(username) && this.password.equals(password)) { 54 return ROOT; 55 } 56 return null; 57 } 58 59 private static class RootUser implements RiotUser { 60 61 public String getUserId() { 62 return "root"; 63 } 64 } 65 } 66 | Popular Tags |