当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionClass.AUTHENTICATION属性代码示例

本文整理汇总了Java中com.vangav.backend.exceptions.VangavException.ExceptionClass.AUTHENTICATION属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionClass.AUTHENTICATION属性的具体用法?Java ExceptionClass.AUTHENTICATION怎么用?Java ExceptionClass.AUTHENTICATION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.vangav.backend.exceptions.VangavException.ExceptionClass的用法示例。


在下文中一共展示了ExceptionClass.AUTHENTICATION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticateRequest

@Override
protected void authenticateRequest (
  final Request request) throws Exception {
  
  // TODO: implement
  
  // get request's body
  RequestSignupEmail requestSignupEmail =
    (RequestSignupEmail)request.getRequestJsonBody();
  
  ResultSet resultSet =
    EmailCreds.i().executeSyncSelect(requestSignupEmail.email);
  
  // email already signed up?
  if (resultSet.isExhausted() == false) {
    
    throw new BadRequestException(
      427,
      1,
      "Email ["
        + requestSignupEmail.email
        + "] is already signed up, request issued from device_token ["
        + requestSignupEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:27,代码来源:HandlerSignupEmail.java

示例2: authenticateRequest

@Override
protected void authenticateRequest (
  final Request request) throws Exception {
  
  // do normal access_token authentication first
  super.authenticateRequest(request);
  
  // get request's body
  RequestLogout requestLogout =
    (RequestLogout)request.getRequestJsonBody();
  
  // get user's refresh token
  ResultSet resultSet =
    RefreshTokens.i().executeSyncSelect(
      requestLogout.getUserId(),
      requestLogout.device_token);
  
  // no refresh token for this user/device_token
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      423,
      1,
      "No refresh token for user_id ["
        + requestLogout.user_id
        + "] and device_token ["
        + requestLogout.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // extract refresh token
  String refreshToken =
    resultSet.one().getString(RefreshTokens.kRefreshTokenColumnName);
  
  // wrong refresh token
  if (requestLogout.refresh_token.compareTo(refreshToken) != 0) {
    
    throw new BadRequestException(
      423,
      2,
      "Wrong refresh token for user_id ["
        + requestLogout.user_id
        + "] and device_token ["
        + requestLogout.device_token
        + "], expected refresh_token ["
        + refreshToken
        + "] but got ["
        + requestLogout.refresh_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:53,代码来源:HandlerLogout.java

示例3: authenticateRequest

@Override
protected void authenticateRequest (
  final Request request) throws Exception {
  
  // get request's body
  RequestLoginEmail requestLoginEmail =
    (RequestLoginEmail)request.getRequestJsonBody();
  
  // select user's password
  ResultSet resultSet =
    EmailCreds.i().executeSyncSelect(requestLoginEmail.email);
  
  // email isn't registered?
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      421,
      1,
      "Email ["
        + requestLoginEmail.email
        + "] isn't registered, request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // extract password
  Row row = resultSet.one();
  
  String password = row.getString(EmailCreds.kPasswordColumnName);
  
  // wrong password?
  if (requestLoginEmail.password.compareTo(password) != 0) {
    
    throw new BadRequestException(
      421,
      2,
      "Wrong password ["
        + requestLoginEmail.password
        + "], expected password ["
        + password
        + "] for email ["
        + requestLoginEmail.email
        + "], request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:49,代码来源:HandlerLoginEmail.java

示例4: processRequest

@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestLoginEmail requestLoginEmail =
    (RequestLoginEmail)request.getRequestJsonBody();

  // select user's password and user_id
  ResultSet resultSet =
    EmailCreds.i().executeSyncSelect(requestLoginEmail.email);
  
  // email isn't registered? -- in case authentication is disabled
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      421,
      3,
      "Email ["
        + requestLoginEmail.email
        + "] isn't registered, request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // extract user_id
  Row row = resultSet.one();
  
  UUID userId = row.getUUID(EmailCreds.kUserIdColumnName);
  
  // set user's id
  request.setUserId(userId);

  // generate new authentication tokens
  OAuth2Tokens oAuth2Tokens = new OAuth2Tokens();
  
  // insert into ig_auth.auth_codes
  AuthCodes.i().executeSyncInsert(
    userId,
    requestLoginEmail.device_token,
    oAuth2Tokens.getAuthorizationCode(),
    oAuth2Tokens.getAccessToken(),
    oAuth2Tokens.getRefreshToken(),
    ((int)Constants.kAuthCodeLifeTime.getAs(
      TimeUnitType.SECOND).getValue() ) );
  
  // set response
  ((ResponseLoginEmail)request.getResponseBody() ).set(
    requestLoginEmail.request_tracking_id,
    userId.toString(),
    oAuth2Tokens.getAuthorizationCode() );
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:53,代码来源:HandlerLoginEmail.java

示例5: authenticateRequest

@Override
protected void authenticateRequest (
  final Request request) throws Exception {

  // get request's authenticator Object
  Authenticator authenticator =
    this.getRequestAuthenticator(request.getRequestJsonBody() );
  
  // no authentication for this controller's request?
  if (authenticator == null) {
    
    return;
  }
  
  // select user's password
  ResultSet resultSet =
    AuthCreds.i().executeSyncSelect(authenticator.getUserId() );
  
  // user isn't signed up?
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      300,
      1,
      "No password for user's id ["
        + authenticator.getUserId().toString()
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // get user's password
  String password = resultSet.one().getString(AuthCreds.kPasswordColumnName);
  
  // wrong password?
  if (password.compareTo(authenticator.getPassword() ) != 0) {
    
    throw new BadRequestException(
      300,
      2,
      "Wrong password for user's id ["
        + authenticator.getUserId().toString()
        + "], expected password ["
        + password
        + "] but got password ["
        + authenticator.getPassword()
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // authentication went through successfully
}
 
开发者ID:vangav,项目名称:vos_whatsapp,代码行数:51,代码来源:CommonPlayHandler.java


注:本文中的com.vangav.backend.exceptions.VangavException.ExceptionClass.AUTHENTICATION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。