@@ -399,6 +399,7 @@ private Inner(DeviceType deviceType, String deviceName, AbsConfiguration configu
399399 public static class Builder {
400400 private final Inner inner ;
401401 private Authentication .LoginCredentials loginCredentials = null ;
402+ private AuthConfiguration authConf ;
402403
403404 public Builder (@ NotNull DeviceType deviceType , @ NotNull String deviceName , @ NotNull AbsConfiguration configuration ) {
404405 this .inner = new Inner (deviceType , deviceName , configuration );
@@ -414,6 +415,7 @@ public Builder(@NotNull AbsConfiguration configuration) {
414415 throw new IllegalArgumentException ("Device type required!" );
415416
416417 this .inner = new Inner (deviceType , deviceName , configuration );
418+ this .authConf = configuration ;
417419 }
418420
419421 public Builder facebook () throws IOException {
@@ -450,7 +452,36 @@ public Builder userPass(@NotNull String username, @NotNull String password) {
450452
451453 @ NotNull
452454 public Session create () throws IOException , GeneralSecurityException , SpotifyAuthenticationException , MercuryClient .PubSubException , SpotifyIrc .IrcException {
453- if (loginCredentials == null ) throw new IllegalStateException ("Missing credentials!" );
455+ if (loginCredentials == null ) {
456+ if (authConf != null ) {
457+ String blob = authConf .blob ();
458+ String username = authConf .username ();
459+ String password = authConf .password ();
460+
461+ switch (authConf .strategy ()) {
462+ case FACEBOOK :
463+ facebook ();
464+ break ;
465+ case BLOB :
466+ if (username == null ) throw new IllegalArgumentException ("Missing username!" );
467+ if (blob == null ) throw new IllegalArgumentException ("Missing blob!" );
468+ blob (username , Base64 .getDecoder ().decode (blob ));
469+ break ;
470+ case USER_PASS :
471+ if (username == null ) throw new IllegalArgumentException ("Missing username!" );
472+ if (password == null ) throw new IllegalArgumentException ("Missing password!" );
473+ userPass (username , password );
474+ break ;
475+ case ZEROCONF :
476+ zeroconf ();
477+ break ;
478+ default :
479+ throw new IllegalStateException ("Unknown auth strategy: " + authConf .strategy ());
480+ }
481+ } else {
482+ throw new IllegalStateException ("Missing credentials!" );
483+ }
484+ }
454485
455486 Session session = new Session (inner , ApResolver .getSocketFromRandomAccessPoint ());
456487 session .connect ();
0 commit comments