SEC-153: Improve toString() method.

This commit is contained in:
Ben Alex 2006-01-28 01:30:46 +00:00
parent 484b0e3a51
commit ce907f2ddc
1 changed files with 41 additions and 36 deletions

View File

@ -1,4 +1,4 @@
/* Copyright 2004, 2005 Acegi Technology Pty Limited /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,9 @@
package org.acegisecurity.providers.cas; package org.acegisecurity.providers.cas;
import org.acegisecurity.GrantedAuthority; import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.providers.AbstractAuthenticationToken; import org.acegisecurity.providers.AbstractAuthenticationToken;
import org.acegisecurity.userdetails.UserDetails; import org.acegisecurity.userdetails.UserDetails;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -101,12 +103,33 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken
//~ Methods ================================================================ //~ Methods ================================================================
public void setAuthenticated(boolean isAuthenticated) { public boolean equals(Object obj) {
this.authenticated = isAuthenticated; if (!super.equals(obj)) {
} return false;
}
public boolean isAuthenticated() { if (obj instanceof CasAuthenticationToken) {
return this.authenticated; CasAuthenticationToken test = (CasAuthenticationToken) obj;
// proxyGrantingTicketIou is never null due to constructor
if (!this.getProxyGrantingTicketIou()
.equals(test.getProxyGrantingTicketIou())) {
return false;
}
// proxyList is never null due to constructor
if (!this.getProxyList().equals(test.getProxyList())) {
return false;
}
if (this.getKeyHash() != test.getKeyHash()) {
return false;
}
return true;
}
return false;
} }
public GrantedAuthority[] getAuthorities() { public GrantedAuthority[] getAuthorities() {
@ -143,42 +166,24 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken
return userDetails; return userDetails;
} }
public boolean equals(Object obj) { public boolean isAuthenticated() {
if (!super.equals(obj)) { return this.authenticated;
return false; }
}
if (obj instanceof CasAuthenticationToken) { public void setAuthenticated(boolean isAuthenticated) {
CasAuthenticationToken test = (CasAuthenticationToken) obj; this.authenticated = isAuthenticated;
// proxyGrantingTicketIou is never null due to constructor
if (!this.getProxyGrantingTicketIou().equals(test
.getProxyGrantingTicketIou())) {
return false;
}
// proxyList is never null due to constructor
if (!this.getProxyList().equals(test.getProxyList())) {
return false;
}
if (this.getKeyHash() != test.getKeyHash()) {
return false;
}
return true;
}
return false;
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append(super.toString()); sb.append(super.toString());
sb.append("; Credentials (Service/Proxy Ticket): " + this.credentials); sb.append("; Credentials (Service/Proxy Ticket): ");
sb.append("; Proxy-Granting Ticket IOU: " + this.proxyGrantingTicketIou); sb.append(this.credentials);
sb.append("; Proxy List: " + this.proxyList.toString()); sb.append("; Proxy-Granting Ticket IOU: ");
sb.append(this.proxyGrantingTicketIou);
sb.append("; Proxy List: ");
sb.append(this.proxyList.toString());
return sb.toString(); return (sb.toString());
} }
} }