Package org.apache.commons.httpclient.auth

Examples of org.apache.commons.httpclient.auth.CredentialsNotAvailableException


        AuthScope authscope = new AuthScope(host, port, realm);
        Credentials credentials = proxy
            ? state.getProxyCredentials(authscope)
            : state.getCredentials(authscope);
        if (credentials == null) {
            throw new CredentialsNotAvailableException("No credentials available");
        }
        String auth = authscheme.authenticate(credentials, method);
        if (auth != null) {
            String s = proxy ? "Proxy-Authorization" : "Authorization";
            Header header = new Header(s, auth, true);
View Full Code Here


                    String user = readConsole();  
                    System.out.print("Enter password: ");
                    String password = readConsole();
                    return new UsernamePasswordCredentials(user, password);   
                } else {
                    throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
                        authscheme.getSchemeName());
                }
            } catch (IOException e) {
                throw new CredentialsNotAvailableException(e.getMessage(), e);
            }
        }
View Full Code Here

                    String user = readConsole();  
                    System.out.print("Enter password: ");
                    String password = readConsole();
                    return new UsernamePasswordCredentials(user, password);   
                } else {
                    throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
                        authscheme.getSchemeName());
                }
            } catch (IOException e) {
                throw new CredentialsNotAvailableException(e.getMessage(), e);
            }
        }
View Full Code Here

  public Credentials getCredentials( final AuthScheme authscheme, final String host, int port, boolean proxy )
      throws CredentialsNotAvailableException
  {
    if( checkedCredentials )
      throw new CredentialsNotAvailableException( "Missing valid credentials" );

    if( authscheme == null )
    {
      return null;
    }
    try
    {
      String password = wsdlRequest.getPassword();
      if( password == null )
        password = "";

      if( authscheme instanceof NTLMScheme )
      {
        logger.info( host + ":" + port + " requires Windows authentication" );
        return new NTCredentials( wsdlRequest.getUsername(), password, host, wsdlRequest.getDomain() );
      }
      else if( authscheme instanceof RFC2617Scheme )
      {
        logger.info( host + ":" + port + " requires authentication with the realm '" + authscheme.getRealm() + "'" );
        return new UsernamePasswordCredentials( wsdlRequest.getUsername(), password );
      }
      else
      {
        throw new CredentialsNotAvailableException( "Unsupported authentication scheme: "
            + authscheme.getSchemeName() );
      }
    }
    catch( IOException e )
    {
      throw new CredentialsNotAvailableException( e.getMessage(), e );
    }
    finally
    {
      checkedCredentials = true;
    }
View Full Code Here

            cache.put( key, credentials );
            return credentials;
          }
          else
            throw new CredentialsNotAvailableException( "Operation cancelled" );
        }
        else if( authscheme instanceof RFC2617Scheme )
        {
          if( hasCredentials() )
          {
            log.info( "Returning url credentials" );
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials( getUsername(), pw );
            cache.put( key, credentials );
            return credentials;
          }

          log.info( host + ":" + port + " requires authentication with the realm '" + authscheme.getRealm() + "'" );
          ShowDialog showDialog = new ShowDialog();
          showDialog.values.put( "Info", "Authentication required for [" + host + ":" + port + "]" );

          UISupport.getUIUtils().runInUIThreadIfSWT( showDialog );
          if( showDialog.result )
          {
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials( showDialog.values
                .get( "Username" ), showDialog.values.get( "Password" ) );
            cache.put( key, credentials );
            return credentials;
          }
          else
            throw new CredentialsNotAvailableException( "Operation cancelled" );

        }
        else
        {
          throw new CredentialsNotAvailableException( "Unsupported authentication scheme: "
              + authscheme.getSchemeName() );
        }
      }
      catch( IOException e )
      {
        throw new CredentialsNotAvailableException( e.getMessage(), e );
      }
    }
View Full Code Here

    public Credentials getCredentials( final AuthScheme authscheme, final String host, int port, boolean proxy )
        throws CredentialsNotAvailableException
    {
      if( checkedCredentials )
        throw new CredentialsNotAvailableException( "Missing valid credentials" );

      if( authscheme == null )
      {
        return null;
      }
      try
      {
        if( authscheme instanceof NTLMScheme )
        {
          logger.info( host + ":" + port + " requires Windows authentication" );
          return new NTCredentials( username, password, host, domain );
        }
        else if( authscheme instanceof RFC2617Scheme )
        {
          logger.info( host + ":" + port + " requires authentication with the realm '" + authscheme.getRealm()
              + "'" );
          return new UsernamePasswordCredentials( username, password );
        }
        else
        {
          throw new CredentialsNotAvailableException( "Unsupported authentication scheme: "
              + authscheme.getSchemeName() );
        }
      }
      catch( IOException e )
      {
        throw new CredentialsNotAvailableException( e.getMessage(), e );
      }
      finally
      {
        checkedCredentials = true;
      }
View Full Code Here

                    String user = readConsole();  
                    System.out.print("Enter password: ");
                    String password = readConsole();
                    return new UsernamePasswordCredentials(user, password);   
                } else {
                    throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
                        authscheme.getSchemeName());
                }
            } catch (IOException e) {
                throw new CredentialsNotAvailableException(e.getMessage(), e);
            }
        }
View Full Code Here

        String realm = authscheme.getRealm();
        Credentials credentials = proxy
            ? state.getProxyCredentials(realm, host)
            : state.getCredentials(realm, host);
        if (credentials == null) {
            throw new CredentialsNotAvailableException("No credentials available");
        }
        String auth = authscheme.authenticate(credentials, method);
        if (auth != null) {
            String s = proxy ? "Proxy-Authorization" : "Authorization";
            Header header = new Header(s, auth, true);
View Full Code Here

                    String user = readConsole();  
                    System.out.print("Enter password: ");
                    String password = readConsole();
                    return new UsernamePasswordCredentials(user, password);   
                } else {
                    throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
                        authscheme.getSchemeName());
                }
            } catch (IOException e) {
                throw new CredentialsNotAvailableException(e.getMessage(), e);
            }
        }
View Full Code Here

                    String user = readConsole();  
                    System.out.print("Enter password: ");
                    String password = readConsole();
                    return new UsernamePasswordCredentials(user, password);   
                } else {
                    throw new CredentialsNotAvailableException("Unsupported authentication scheme: " +
                        authscheme.getSchemeName());
                }
            } catch (IOException e) {
                throw new CredentialsNotAvailableException(e.getMessage(), e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.auth.CredentialsNotAvailableException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.