Package org.apache.commons.httpclient.auth

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


                    + OAUTH_KEYS.OAUTH_VERSION.toLowerCase()
                    + "="
                    + credentials.getVersion();
            return sign(credentials.getSignatureMethod(), URLEncoder.encode(baseString, "UTF-8"), credentials.getCert());
        } catch (URIException e) {
            throw new AuthenticationException(e.getMessage(), e);
        } catch (UnsupportedEncodingException e) {
            throw new AuthenticationException(e.getMessage(), e);
        }
    }
View Full Code Here


            byte[] temp = new byte[NONCE_LENGTH];
            sr.nextBytes(temp);
            String n = new String(Hex.encodeHex(temp));
            return n;
        } catch (Exception e) {
            throw new AuthenticationException(e.getMessage(), e);
        }
    }
View Full Code Here

                mac.init(kg.generateKey());
                byte[] result = mac.doFinal(baseString.getBytes());

                return new String(Base64.encodeBase64(result));
            } catch (Exception e) {
                throw new AuthenticationException(e.getMessage(), e);
            }
        } else if (method.equalsIgnoreCase("md5")) {
            return new String(Base64.encodeBase64(DigestUtils.md5(baseString)));
        } else if (method.equalsIgnoreCase("sha1")) {
            return new String(Base64.encodeBase64(DigestUtils.sha(baseString)));
        } else if (method.equalsIgnoreCase("RSA-SHA1")) {
            if (cert == null) {
                throw new AuthenticationException("a cert is mandatory to use SHA1 with RSA");
            }
            try {
                Cipher cipher = Cipher.getInstance("SHA1withRSA");
                cipher.init(Cipher.ENCRYPT_MODE, cert);
                byte[] result = cipher.doFinal(baseString.getBytes());
                return new String(Base64.encodeBase64(result));
            } catch (Exception e) {
                throw new AuthenticationException(e.getMessage(), e);
            }
        } else {
            throw new AuthenticationException("unsupported algorithm method: " + method);
        }
    }
View Full Code Here

        // for now we are only expecting Strings         
        //return method.getResponseBodyAsString();
        return readFully(new InputStreamReader(method.getResponseBodyAsStream(), "UTF-8"));
      }
      else if (statusCode == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED || statusCode == HttpStatus.SC_UNAUTHORIZED)
        throw new AuthenticationException("Authentication failed:"+ method.getStatusLine() + ' ' + method.getURI() + ' ' + method.getStatusText());                                     
      else {
        throw new Exception("Method failed: " + method.getStatusLine() + ' ' + method.getURI() + ' ' + method.getStatusText()); //$NON-NLS-1$
      }
    }
    catch (IOException e) {
View Full Code Here

     *
     * @deprecated Use {@link #authenticate(Credentials, HttpMethod)}
     */
    public String authenticate(Credentials credentials, String method, String uri)
      throws AuthenticationException {
        throw new AuthenticationException("method not supported by Negotiate scheme");
    }
View Full Code Here

                    init( method.getURI().getHost() );
                }
            } catch (org.apache.commons.httpclient.URIException urie) {
                LOG.error(urie.getMessage());
                state = FAILED;
                throw new AuthenticationException(urie.getMessage());
            }
       
            // HTTP 1.1 issue:
            // Mutual auth will never complete do to 200 insted of 401 in
            // return from server. "state" will never reach ESTABLISHED
            // but it works anyway
            token = context.initSecContext(token, 0, token.length);
            LOG.info("got token, sending " + token.length + " to server");
        } catch (GSSException gsse) {
            LOG.fatal(gsse.getMessage());
            state = FAILED;
            if( gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED )
                throw new InvalidCredentialsException(gsse.getMessage(),gsse);
            if( gsse.getMajor() == GSSException.NO_CRED )
                throw new CredentialsNotAvailableException(gsse.getMessage(),gsse);
            if( gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN )
                throw new AuthChallengeException(gsse.getMessage(),gsse);
            // other error
            throw new AuthenticationException(gsse.getMessage());
        }
        return "Negotiate " + new String(new Base64().encode(token));
    }
View Full Code Here

    String temp = nonce + date.getValue() + password;
    try {
      MessageDigest md = MessageDigest.getInstance("SHA1");
      return new String(Base64.encodeBase64(md.digest(temp.getBytes())));
    } catch (Exception e) {
      throw new AuthenticationException(e.getMessage(), e);
    }
  }
View Full Code Here

        byte[] temp = new byte[NONCE_LENGTH];
        sr.nextBytes(temp);
        String n = new String(Hex.encodeHex(temp));
        return n;
      } catch (Exception e) {
        throw new AuthenticationException(e.getMessage(),e);
      }
  }
View Full Code Here

      return sign(
        credentials.getSignatureMethod(),
        URLEncoder.encode(baseString, "UTF-8"),
        credentials.getCert() );
    } catch (URIException e) {
      throw new AuthenticationException(e.getMessage(), e);
    } catch (UnsupportedEncodingException e) {
      throw new AuthenticationException(e.getMessage(), e);
    }
  }
View Full Code Here

      byte[] temp = new byte[NONCE_LENGTH];
      sr.nextBytes(temp);
      String n = new String(Hex.encodeHex(temp));
      return n;
    } catch (Exception e) {
      throw new AuthenticationException(e.getMessage(),e);
    }
  }
View Full Code Here

TOP

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

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.