Examples of AuthenticationException


Examples of com.ibm.sbt.security.authentication.AuthenticationException

      }
      List<Cookie> cookies = cookieStore.getCookies();
      setCookieCache(cookies);

    } catch (IOException e) {
      throw new AuthenticationException(e,"FormEndpoint failed to authenticate");
    }
    return validAuthentication;

  }
View Full Code Here

Examples of com.kolich.havalo.exceptions.authentication.AuthenticationException

            // Extract the Authorization header from the incoming HTTP request.
            String header = request.getHeader(AUTHORIZATION);
            // If the header does not exist or does not start with the correct
            // token, give up immediately.
            if(header == null || !header.startsWith(HAVALO_AUTHORIZATION_PREFIX)) {
                throw new AuthenticationException("Request did not contain " +
                    "a valid '" + AUTHORIZATION + "' header.");
            }
            // Extract just the part of the Authorization header that follows
            // the Havalo authorization prefix.
            header = header.substring(HAVALO_AUTHORIZATION_PREFIX.length());
            final String[] tokens = header.split(HAVALO_AUTHORIZATION_SEPARATOR, 2);
            if(tokens == null || tokens.length != 2) {
                throw new AuthenticationException("Failed to extract correct " +
                    "number of tokens from '" + AUTHORIZATION + "' header.");
            }
            // If we get here, then we must have had some valid input
            // Authorization header with a real access key and signature.
            final String accessKey = tokens[0], signature = tokens[1];
            // request.getRequestURI();
            // Extract username from incoming signed request header.
            // Expected format is ...
            //    Authorization: Havalo AccessKey:Signature
            // ... where the AccessKey is the unique UUID used to identify the user.
            // And, the Signature is ...
            //    Base64( HMAC-SHA256( UTF-8-Encoding-Of( AccessSecret, StringToSign ) ) );
            // And, the StringToSign is ....
            //    HTTP-Verb (GET, PUT, POST, or DELETE) + "\n" +
            //    RFC822 Date (from 'Date' request header, must exist) + "\n" +
            //    Content-Type (from 'Content-Type' request header, optional) + "\n" +
            //    CanonicalizedResource (the part of this request's URL from
            //        the protocol name up to the query string in the first line
            //        of the HTTP request)
            // Call the user details service to load the user data for the UUID.
            final KeyPair userKp = userService_.loadKeyPairById(
                UUID.fromString(accessKey));
            if(userKp == null) {
                throw new AuthenticationException("User service returned " +
                    "null, which is an interface contract violation.");
            }
            // Get the string to sign -- will fail gracefully if the incoming
            // request does not have the proper headers attached to it.
            final String stringToSign = getStringToSign(request);
            // Compute the resulting signed signature.
            final String computed = HMACSHA256Signer.sign(userKp, stringToSign);
            // Does the signature match what was passed to us in the
            // Authorization request header?
            if(!computed.equals(signature)) {
                throw new BadCredentialsException("Signatures did not " +
                    "match (request=" + signature + ", computed=" + computed +
                    ")");
            }
            // Success!
            request.setAttribute(HAVALO_AUTHENTICATION_ATTRIBUTE, userKp);
        } catch (Exception e) {
            logger__.debug("Authentication failure; service failed " +
                "to authenticate request.", e);
            throw new AuthenticationException("Authentication " +
                "failed; either the provided signature did not match, " +
                "or you do not have permission to access the requested " +
                "resource.", e);
        }
    }
View Full Code Here

Examples of com.maxmind.geoip2.exception.AuthenticationException

                || code.equals("IP_ADDRESS_RESERVED")) {
            throw new AddressNotFoundException(error);
        } else if (code.equals("AUTHORIZATION_INVALID")
                || code.equals("LICENSE_KEY_REQUIRED")
                || code.equals("USER_ID_REQUIRED")) {
            throw new AuthenticationException(error);
        } else if (code.equals("OUT_OF_QUERIES")) {
            throw new OutOfQueriesException(error);
        }

        // These should be fairly rare
View Full Code Here

Examples of com.porterhead.rest.user.exception.AuthenticationException

    public AuthenticatedUserToken login(LoginRequest request) {
        validate(request);
        User user = null;
        user = userRepository.findByEmailAddress(request.getUsername());
        if (user == null) {
            throw new AuthenticationException();
        }
        String hashedPassword = null;
        try {
            hashedPassword = user.hashPassword(request.getPassword());
        } catch (Exception e) {
            throw new AuthenticationException();
        }
        if (hashedPassword.equals(user.getHashedPassword())) {
            return new AuthenticatedUserToken(user.getUuid().toString(), createAuthorizationToken(user).getToken());
        } else {
            throw new AuthenticationException();
        }
    }
View Full Code Here

Examples of com.porterhead.rest.user.exception.AuthenticationException

        assertThat(response.getStatus(), is(400));
    }

    @Test
    public void authenticationErrorOnLogin() {
        when(userService.login(any(LoginRequest.class))).thenThrow(new AuthenticationException());
        ClientResponse response = super.resource().path("user/login").entity(createLoginRequest(), APPLICATION_JSON).accept(APPLICATION_JSON).post(ClientResponse.class);
        assertThat(response.getStatus(), is(401));
    }
View Full Code Here

Examples of com.psddev.dari.util.AuthenticationException

                    hashedPassword = Password.validateAndCreateCustom(userPasswordPolicy, user, null, null, password);
                } else {
                    hashedPassword = Password.validateAndCreateCustom(passwordPolicy, null, null, password);
                }
            } catch (PasswordException error) {
                throw new AuthenticationException(error);
            }

            user.setName(name);

            if (atAt >= 0) {
                user.setEmail(username);

            } else {
                user.setUsername(username);
            }

            user.setPassword(hashedPassword);
            user.save();

            return user;
        }

        throw new AuthenticationException(
                "Oops! No user with that username and password.");
    }
View Full Code Here

Examples of com.sk89q.skmcl.session.AuthenticationException

            if (identities.size() > 0) {
                account.setIdentities(identities);
                Persistence.commitAndForget(getAccounts());
                return identities.get(0);
            } else {
                throw new AuthenticationException(
                        "Account doesn't own Minecraft",
                        _("loginDialog.minecraftNotOwned"));
            }
        }
View Full Code Here

Examples of com.stripe.exception.AuthenticationException

      String apiKey) throws AuthenticationException,
      InvalidRequestException, APIConnectionException, CardException,
      APIException {
    if ((Stripe.apiKey == null || Stripe.apiKey.length() == 0)
        && (apiKey == null || apiKey.length() == 0)) {
      throw new AuthenticationException(
          "No API key provided. (HINT: set your API key using 'Stripe.apiKey = <API-KEY>'. "
              + "You can generate API keys from the Stripe web interface. "
              + "See https://stripe.com/api for details or email support@stripe.com if you have questions.");
    }
View Full Code Here

Examples of com.tap5.hotelbooking.security.AuthenticationException

        User user = crudService.findUniqueWithNamedQuery(User.BY_CREDENTIALS, QueryParameters.with(
                "username",
                username).and("password", password).parameters());

        if (user == null) { throw new AuthenticationException("The user doesn't exist"); }

        request.getSession(true).setAttribute(AUTH_TOKEN, user);
    }
View Full Code Here

Examples of com.yammer.dropwizard.auth.AuthenticationException

        .get(String.class);
    final VerifyTokenResponse response;
    try {
      response = mapper.readValue(json, VerifyTokenResponse.class);
    } catch (IOException e) {
      throw new AuthenticationException("Could not parse JSON: "+ json, e);
    }
    return Optional.fromNullable(response.getPrincipal());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.