/** * Authenticate a user. * * @param username a username * @param password a plain text password, as entered by the user * * @return a Principal object representing the user if successful, false otherwise */ public Principal authenticate(String username, String password) { if (booleanAuthenticate(username, password)) { return new SimplePrincipal(username); } else { return null; } }
/** * Compares this principal to the specified object. * * @param obj object to compare with. * * @return true if the object passed in is a SimplePrincipal with the same name. */ public boolean equals(Object obj) { if (obj instanceof SimplePrincipal) { return name.equals(((SimplePrincipal)obj).getName()); } return false; }
if ((superadminpassword != null) && (superadminpassword.equals(password))) { if (context.isMainWiki()) { principal = new SimplePrincipal(XWikiRightService.SUPERADMIN_USER_FULLNAME); } else { principal = new SimplePrincipal(context.getMainXWiki() + ":" + XWikiRightService.SUPERADMIN_USER_FULLNAME);
public boolean processLogin(String username, String password, String rememberme, SecurityRequestWrapper request, HttpServletResponse response, XWikiContext context) throws Exception { Principal principal = authenticate(username, password, context); if (principal != null) { // login successful request.getSession().removeAttribute(LOGIN_ATTEMPTS); // make sure the Principal contains wiki name information if (!StringUtils.contains(principal.getName(), ':')) { principal = new SimplePrincipal(context.getDatabase() + ":" + principal.getName()); } request.setUserPrincipal(principal); return false; } else { // login failed // show the basic authentication window again. showLogin(request.getCurrentRequest(), response); return true; } }
principal = new SimplePrincipal(context.getDatabase() + ":" + principal.getName());
public static Principal checkLogin(SecurityRequestWrapper request, HttpServletResponse response, XWikiContext context) throws Exception { // Always verify authentication String authorizationHeader = request.getHeader("Authorization"); if (authorizationHeader != null) { String decoded = decodeBasicAuthorizationString(authorizationHeader); String username = convertUsername(parseUsername(decoded), context); String password = parsePassword(decoded); Principal principal = authenticate(username, password, context); if (principal != null) { // login successful request.getSession().removeAttribute(LOGIN_ATTEMPTS); // make sure the Principal contains wiki name information if (!StringUtils.contains(principal.getName(), ':')) { principal = new SimplePrincipal(context.getDatabase() + ":" + principal.getName()); } request.setUserPrincipal(principal); return principal; } } return null; }
if (user != null) { if (checkPassword(user, password, context)) { return new SimplePrincipal(virtualXwikiName != null ? context.getDatabase() + ":" + user : user); } else { if (user != null) { if (checkPassword(user, password, context)) { return new SimplePrincipal(context.getDatabase() + ":" + user); } else { context.put("message", "invalidcredentials");
principal = new SimplePrincipal(context.getDatabase() + ":" + principal.getName());
principal = new SimplePrincipal(userProfile.getFullName()); } else { principal = new SimplePrincipal(context.getDatabase() + ":" + userProfile.getFullName());
principal = new SimplePrincipal(userProfile.getFullName()); } else { principal = new SimplePrincipal(userProfile.getPrefixedFullName());