Examples of a custom SAML token parser
The following code snippet gives an example of a SAML token parser.
import com.workbrain.server.signoninterface.saml.Saml;
public class MySamlTokenParser implements Saml.TokenParser{
@Override
public Saml.Token parse(String encodedValue) {
String userName = getUserName(encodedValue);
return new SamlToken().setUserName(userName);
}
private class SamlToken implements Saml.Token {
private String userName;
private SamlTokensetUserName(userName){
this.userName = userName;
return this;
}
@Override
public String getUserName() {
return userName;
}
}
}
….or with lambda expression usage:
import com.workbrain.server.signoninterface.saml.Saml;
public class MySamlTokenParser implements Saml.TokenParser{
@Override
public Saml.Token parse(String encodedValue){
String userName = getUserName(encodedValue);
return () -> userName;
}