shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dikybird <>
Subject Apache Shiro custom AuthenticationToken
Date Tue, 10 May 2016 17:50:08 GMT
I am trying to use Shiro to login with a number rather than standard
usernamePasswordToken. I am getting the error
org.apache.shiro.authc.pam.UnsupportedTokenException: Realm .... does not
support authentication token. Please ensure that the appropriate Realm
implementation is configured correctly or that the realm accepts
AuthenticationTokens of this type.". How can I configure the realm to
support the token?

public class NumberAuthToken implements AuthenticationToken{
String  number;

public NumberAuthToken (String number) {
  this.number = number;

public String getPrincipal() {
  return number;
public String getCredentials() {
  return number;

and credentials matcher

public class NumberTokenMatcher implements CredentialsMatcher {
public boolean doCredentialsMatch(AuthenticationToken authToken,
AuthenticationInfo authenticationInfo) {

    return true;

in spring configuration

 <beans:bean id="UserDetails" class="com.UserDetailsService">
   <beans:property name="credentialsMatcher" ref="NumberTokenMatcher"/>

  <beans:bean id="NumberTokenMatcher" class="com.NumberTokenMatcher">

        AuthenticationToken numberToken = (AuthenticationToken) new

        Subject subject = SecurityUtils.getSubject();


View this message in context:
Sent from the Shiro Developer mailing list archive at

View raw message