Skip to content

Instantly share code, notes, and snippets.

View mmaravich's full-sized avatar

Mladen Maravić mmaravich

  • 13:51 (UTC +02:00)
View GitHub Profile
package org.springframework.core.convert.converter;
public interface Converter<S, T> {
T convert(S source);
}
<beans:bean id="userDetailsService" class="x.y.z.UserDetailsService" />
<beans:bean id="yubikeyAuthenticationProvider"
class="com.curlapp.yubikey.YubikeyAuthenticationProvider"
p:userDetailsService-ref="userDetailsService"
p:yubicoClientId="******" />
<authentication-manager alias="authenticationManager">
<authentication-provider ref="yubikeyAuthenticationProvider"/>
</authentication-manager>
import org.springframework.security.core.userdetails.UserDetails;
public interface YubikeyUserDetails extends UserDetails {
String getPublicId();
}
<dependency>
<groupId>com.yubico</groupId>
<artifactId>yubico-validation-client2</artifactId>
<version>2.0.1</version>
</dependency>
@mmaravich
mmaravich / YubikeyAuthenticationProvider.java
Created August 29, 2014 09:22
Spring Security authentication provider that uses YubiKey OTP as password
package com.curlapp.yubikey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
import org.springframework.security.authentication.DisabledException;