shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dikybird <m_chipping...@hotmail.com>
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 {
@Override
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>

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

        AuthenticationToken numberToken = (AuthenticationToken) new
NumberAuthToken(number);

        Subject subject = SecurityUtils.getSubject();

        subject.login(numberToken);



--
View this message in context: http://shiro-developer.582600.n2.nabble.com/Apache-Shiro-custom-AuthenticationToken-tp7578964.html
Sent from the Shiro Developer mailing list archive at Nabble.com.

Mime
View raw message