From d169829f2798a56b80a5e859b786e4da07551014 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 29 Apr 2005 22:29:00 +0000 Subject: [PATCH] AbstractAuthenticationToken.getName() now returns username alone if UserDetails present. --- .../providers/AbstractAuthenticationToken.java | 7 ++++++- doc/xdocs/changes.xml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java b/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java index 962773adfc..1e4c30870e 100644 --- a/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java +++ b/core/src/main/java/org/acegisecurity/providers/AbstractAuthenticationToken.java @@ -1,4 +1,4 @@ -/* Copyright 2004 Acegi Technology Pty Limited +/* Copyright 2004, 2005 Acegi Technology Pty Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package net.sf.acegisecurity.providers; import net.sf.acegisecurity.Authentication; +import net.sf.acegisecurity.UserDetails; /** @@ -38,6 +39,10 @@ public abstract class AbstractAuthenticationToken implements Authentication { } public String getName() { + if (this.getPrincipal() instanceof UserDetails) { + return ((UserDetails) this.getPrincipal()).getUsername(); + } + return this.getPrincipal().toString(); } diff --git a/doc/xdocs/changes.xml b/doc/xdocs/changes.xml index 646f00f6df..0940b81242 100644 --- a/doc/xdocs/changes.xml +++ b/doc/xdocs/changes.xml @@ -27,6 +27,7 @@ AnonymousProcessingFilter offers protected method to control when it should execute + AbstractAuthenticationToken.getName() now returns username alone if UserDetails present AuthorityGranter.grant now returns a java.util.Set of role names, instead of a single role name