Examples of UnauthorizedException


Examples of br.com.caelum.restfulie.http.error.UnauthorizedException

      throw new BadRequestException("Http error " + code
          + " when executing request");
    }

    if (code == 401) {
      throw new UnauthorizedException("Http error " + code
          + " when executing request");
    }

    if (code == 403) {
      throw new ForbiddenException("Http error " + code
View Full Code Here

Examples of com.Yasna.forum.UnauthorizedException

     */
    public Authorization createAuthorization(String username, String password)
            throws UnauthorizedException
    {
        if (username == null || password == null) {
            throw new UnauthorizedException();
        }
        //Yazd stores all passwords in hashed form. So, hash the plain text
        //password for comparison.
        password = StringUtils.hash(password);
        int userID = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(AUTHORIZE);
            pstmt.setString(1, username);
            pstmt.setString(2, password);

            ResultSet rs = pstmt.executeQuery();
            //If the query had no results, the username and password
            //did not match a user record. Therefore, throw an exception.
            if (!rs.next()) {
                throw new UnauthorizedException();
            }
            userID = rs.getInt(1);

      pstmt = con.prepareStatement(CHECKLOGIN);
        pstmt.setInt(1,userID);
        pstmt.setString(2,"notactive");
        rs = pstmt.executeQuery();
        if(rs.next()){
            //This account is not activated yet and can not be authorized to login.
             throw new UserNotActivatedException("User not yet activated");
        }
      //pstmt.setInt(1,userID);
      pstmt.setString(2,"lastlogin");
            rs = pstmt.executeQuery();
            //If the query had no results, insert the lastlogin into properties
            if (!rs.next()) {
               pstmt = con.prepareStatement(INSERTLOGIN);
               pstmt.setInt(1,userID);
               pstmt.setString(2,"lastlogin");
               pstmt.setString(3,Long.toString(Calendar.getInstance().getTimeInMillis()));
               pstmt.executeUpdate();
            }else{
               pstmt = con.prepareStatement(UPDATELOGIN);
               pstmt.setString(1,Long.toString(Calendar.getInstance().getTimeInMillis()));
               pstmt.setInt(2,userID);
               pstmt.setString(3,"lastlogin");
               pstmt.executeUpdate();
      }

        }
        catch( SQLException sqle ) {
            System.err.println("Exception in DbAuthorizationFactory:" + sqle);
            sqle.printStackTrace();
            throw new UnauthorizedException();
        }
        finally {
            try pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try con.close();   }
View Full Code Here

Examples of com.coinbase.api.exception.UnauthorizedException

            String errorMessage = null;
            if (es != null) {
                errorMessage = IOUtils.toString(es, "UTF-8");
            }
            if (HttpsURLConnection.HTTP_UNAUTHORIZED == conn.getResponseCode()) {
              throw new UnauthorizedException(errorMessage);
            }
            if (conn.getContentType().toLowerCase().contains("json")) {
                CoinbaseException cbEx = new CoinbaseException(errorMessage);
                cbEx.addSuppressed(e);
                throw cbEx;
View Full Code Here

Examples of com.gitblit.GitBlitException.UnauthorizedException

      is.close();
      return json.toString();
    } catch (IOException e) {
      if (e.getMessage().indexOf("401") > -1) {
        // unauthorized
        throw new UnauthorizedException(url);
      } else if (e.getMessage().indexOf("403") > -1) {
        // requested url is forbidden by the requesting user
        throw new ForbiddenException(url);
      } else if (e.getMessage().indexOf("405") > -1) {
        // requested url is not allowed by the server
View Full Code Here

Examples of com.google.api.server.spi.response.UnauthorizedException

        }catch(UserMaxLimitException ex) {
            return forward("/responsive/account/user_max_limit.jsp");

        }catch(Exception e) {
            e.printStackTrace();
            throw new UnauthorizedException("No Login:login");
        }

//        return null; (ポップアップ用)
        return forward("/account/loggedIn");
    }
View Full Code Here

Examples of com.openshift.internal.client.httpclient.UnauthorizedException

 
  @Test(expected = InvalidCredentialsOpenShiftException.class)
  public void shouldNotLoadListOfApplicationsWithInvalidCredentials()
      throws OpenShiftException, HttpClientException, SocketTimeoutException {
    // pre-conditions
    mockDirector.mockGetApplications("foobarz", new UnauthorizedException("invalid credentials (mock)", null));
    // operation
    domain.getApplications();
    // verifications
    mockDirector.verifyGetAPI()
      .verifyGetUser()
View Full Code Here

Examples of edu.wpi.cs.wpisuitetng.exceptions.UnauthorizedException

          s = sessions.getSession(c.getValue())
      }
     
      if(s == null)
      {
        throw new UnauthorizedException();
      }
    }
    else
    {
      throw new AuthenticationException("Could not find WPISuite cookie. Please Login to recieve one.");
View Full Code Here

Examples of net.fortytwo.twitlogic.services.twitter.errors.UnauthorizedException

        String msg = json.optString(TwitterAPI.ErrorField.ERROR.toString());

        if (null != msg && 0 < msg.length()) {
            System.out.println(json);
            if (msg.equals("Not authorized")) {
                throw new UnauthorizedException();
            } else {
                throw new TwitterAPIException(msg);
            }
        }
    }
View Full Code Here

Examples of net.sf.chellow.monad.UnauthorizedException

          return;
        }
      } catch (UnknownHostException e) {
        throw new InternalException(e);
      }
      throw new UnauthorizedException();
    }
    UserRole role = user.getRole();
    String roleCode = role.getCode();
    if (roleCode.equals(UserRole.VIEWER)) {
      if (pathInfo.startsWith("/reports/")
          && pathInfo.endsWith("/output/")
          && (method.equals(HttpMethod.GET) || method
              .equals(HttpMethod.HEAD))) {
        return;
      }
    } else if (roleCode.equals(UserRole.EDITOR)) {
      return;
    } else if (roleCode.equals(UserRole.PARTY_VIEWER)) {
      if (method.equals(HttpMethod.GET) || method.equals(HttpMethod.HEAD)) {
        Party party = user.getParty();
        char marketRoleCode = party.getRole().getCode();
        if (marketRoleCode == MarketRole.HHDC) {
          Long hhdcContractId = inv.getLong("hhdc-contract-id");
          if (!inv.isValid()) {
            throw new ForbiddenException(
                "Need the parameter hhdc-contract-id.");
          }
          HhdcContract hhdcContract = HhdcContract
              .getHhdcContract(hhdcContractId);
          if (!hhdcContract.getParty().equals(party)) {
            throw new ForbiddenException(
                "The party associated with the contract you're trying to view doesn't match your party.");
          }
          if ((pathInfo + "?" + inv.getRequest().getQueryString())
              .startsWith("/reports/37/output/?hhdc-contract-id="
                  + hhdcContract.getId())) {
            return;
          }
        } else if (marketRoleCode == MarketRole.SUPPLIER) {
          if (pathInfo.startsWith("/supplier-contracts/"
              + party.getId())) {
            return;
          }
        }
      }
    }
    if (inv.getUser() == null) {
      throw new UnauthorizedException();
    }
    throw new ForbiddenException();
  }
View Full Code Here

Examples of org.apache.archiva.redback.authorization.UnauthorizedException

            if ( authzResult.getException() != null )
            {
                log.info( "Authorization Denied [ip={},permission={},repo={}] : {}", request.getRemoteAddr(),
                          permission, repositoryId, authzResult.getException().getMessage() );

                throw new UnauthorizedException( "Access denied for repository " + repositoryId );
            }
            throw new UnauthorizedException( "User account is locked" );
        }

        return true;
    }
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.