@Override public String getAuthorization() { final String v = this.value("Authorization"); if(StringUtils.isBlank(v)) { return parent.getAuthorization(); } return v; }
public static AuthenticationHeaderSignatureVersion getDefault(final Protocol protocol) { try { return S3Protocol.AuthenticationHeaderSignatureVersion.valueOf(protocol.getAuthorization()); } catch(IllegalArgumentException e) { log.warn(String.format("Unsupported authentication context %s", protocol.getAuthorization())); return S3Protocol.AuthenticationHeaderSignatureVersion.valueOf( PreferencesFactory.get().getProperty("s3.signature.version")); } }
@Override public void setUserName(final String input) { final String user; final AuthScheme scheme; if(StringUtils.contains(input, ':')) { // Support non default auth scheme (PAM) user = StringUtils.splitPreserveAllTokens(input, ':')[1]; // Defaults to standard if not found scheme = AuthScheme.findTypeByString(StringUtils.splitPreserveAllTokens(input, ':')[0]); } else { user = input; if(StringUtils.isNotBlank(host.getProtocol().getAuthorization())) { scheme = AuthScheme.findTypeByString(host.getProtocol().getAuthorization()); } else { // We can default to Standard if not specified scheme = AuthScheme.STANDARD; } } super.setUserName(user); this.setAuthenticationScheme(scheme); } }
.authType(LoginRequest.AuthTypeEnum.fromValue(session.getHost().getProtocol().getAuthorization())) .login(user) .password(password)).getToken();
@Override public boolean equals(Object o) { if(this == o) { return true; } if(!(o instanceof Protocol)) { return false; } Protocol protocol = (Protocol) o; if(this.getIdentifier() != null ? !this.getIdentifier().equals(protocol.getIdentifier()) : protocol.getIdentifier() != null) { return false; } if(this.getScheme() != null ? !this.getScheme().equals(protocol.getScheme()) : protocol.getScheme() != null) { return false; } if(this.getContext() != null ? !this.getContext().equals(protocol.getContext()) : protocol.getContext() != null) { return false; } if(this.getAuthorization() != null ? !this.getAuthorization().equals(protocol.getAuthorization()) : protocol.getAuthorization() != null) { return false; } if(this.getProvider() != null ? !this.getProvider().equals(protocol.getProvider()) : protocol.getProvider() != null) { return false; } if(this.getDefaultHostname() != null ? !this.getDefaultHostname().equals(protocol.getDefaultHostname()) : protocol.getDefaultHostname() != null) { return false; } return true; }
final String password = host.getCredentials().getPassword(); switch(SDSProtocol.Authorization.valueOf(host.getProtocol().getAuthorization())) { case oauth: authorizationService.setTokens(authorizationService.authorize(host, controller, cancel)); .authType(LoginRequest.AuthTypeEnum.fromValue(host.getProtocol().getAuthorization())) .login(login) .password(additional.getPassword()) .authType(LoginRequest.AuthTypeEnum.fromValue(host.getProtocol().getAuthorization())) .login(login) .password(password)
private String login(final LoginCallback controller, final LoginRequest request) throws BackgroundException { try { try { return new AuthApi(client).login(request).getToken(); } catch(ApiException e) { throw new SDSExceptionMappingService().map(e); } } catch(PartialLoginFailureException e) { final Credentials additional = controller.prompt(host, host.getCredentials().getUsername(), LocaleFactory.localizedString("Provide additional login credentials", "Credentials"), e.getDetail(), new LoginOptions() .icon(host.getProtocol().disk()) .user(false) .keychain(false) ); return this.login(controller, new LoginRequest() .authType(LoginRequest.AuthTypeEnum.fromValue(host.getProtocol().getAuthorization())) .password(additional.getPassword()) ); } }
@Override protected SDSApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); switch(SDSProtocol.Authorization.valueOf(host.getProtocol().getAuthorization())) { case oauth: authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() {