Integrate Spring-based java module into a standalone java application -


i have spring-based module need integrate existing/legacy java "standalone" app. spring-based module simple implementation of authenticationprovider (spring-security).

what hook spring based module in java application in way can call authenticate method on provider java code.

is possible? required?

is possible wrap spring module in plain java library , use api interface standalone java app?

i searched specific tutorials seems there isn't 1 fit requirement.

ok, have use applicationcontext directly can manage spring framework in application.

public class myapplication {  private static final logger logger = loggerfactory.getlogger(myapplication.class);  public static void main(string[] args) {      myauthenticationprovider authprovider;      try (configurableapplicationcontext springapplicationcontext = new annotationconfigapplicationcontext(             myspringconfiguration.class)) {         springapplicationcontext.registershutdownhook();         authprovider = springapplicationcontext.getbean(myauthenticationprovider.class);     }      authentication request = new usernamepasswordauthenticationtoken("foo", "foo");     authentication result = authprovider.authenticate(request);      if (result.isauthenticated()) {         logger.debug("user authenticated");     } else {         logger.debug("cannot authenticate user.");     }  } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -