本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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() );
}
示例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
}