本文整理汇总了Java中com.warrenstrange.googleauth.GoogleAuthenticatorKey类的典型用法代码示例。如果您正苦于以下问题:Java GoogleAuthenticatorKey类的具体用法?Java GoogleAuthenticatorKey怎么用?Java GoogleAuthenticatorKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GoogleAuthenticatorKey类属于com.warrenstrange.googleauth包,在下文中一共展示了GoogleAuthenticatorKey类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
点赞 3
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(getServlet().getServletContext());
UserManagementService userManagementService = (UserManagementService) ctx.getBean("userManagementService");
// check if user needs to get his shared two-factor authorization secret
User loggedInUser = userManagementService.getUserByLogin(request.getRemoteUser());
if (loggedInUser.isTwoFactorAuthenticationEnabled() && loggedInUser.getTwoFactorAuthenticationSecret() == null) {
GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey key = gAuth.createCredentials();
String sharedSecret = key.getKey();
loggedInUser.setTwoFactorAuthenticationSecret(sharedSecret);
userManagementService.saveUser(loggedInUser);
request.setAttribute("sharedSecret", sharedSecret);
String QRCode = GoogleAuthenticatorQRGenerator.getOtpAuthURL(null, "LAMS account: " + loggedInUser.getLogin(), key);
request.setAttribute("QRCode", QRCode);
}
return mapping.findForward("secret");
}
开发者ID:lamsfoundation,
项目名称:lams,
代码行数:27,
代码来源:TwoFactorAuthenticationAction.java
示例2: createKey
点赞 3
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
public String createKey(UUID uuid) {
GoogleAuthenticator authenticator = new GoogleAuthenticator();
GoogleAuthenticatorKey key = authenticator.createCredentials();
changeState(uuid, AuthState.PENDING_SETUP);
pendingKeys.put(uuid, key.getKey());
return key.getKey();
}
开发者ID:ConnorLinfoot,
项目名称:MC2FA,
代码行数:8,
代码来源:AuthHandler.java
示例3: doTask
点赞 3
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
public boolean doTask(User user, Map<String, Object> request)
throws ProvisioningException {
GoogleAuthenticator ga = new GoogleAuthenticator();
GoogleAuthenticatorKey key = ga.createCredentials();
String attrVal = null;
attrVal = generateEncryptedToken(user.getUserID(), key,this.hostName,this.task.getConfigManager(),this.encryptionKey);
Attribute keyattr = new Attribute(this.attributeName);
keyattr.getValues().add(attrVal);
user.getAttribs().put(this.attributeName, keyattr);
return true;
}
开发者ID:TremoloSecurity,
项目名称:OpenUnison,
代码行数:14,
代码来源:CreateOTPKey.java
示例4: generateEncryptedToken
点赞 2
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
public static String generateEncryptedToken(String userID, GoogleAuthenticatorKey key,
String hostName,ConfigManager cfg,String encryptionKey) throws ProvisioningException {
TOTPKey totpkey = new TOTPKey();
totpkey.setHost(hostName);
totpkey.setScratchCodes(key.getScratchCodes());
totpkey.setSecretKey(key.getKey());
totpkey.setUserName(userID);
totpkey.setValidationCode(key.getVerificationCode());
Gson gson = new Gson();
String json = gson.toJson(totpkey);
SecretKey sc = cfg.getSecretKey(encryptionKey);
String attrVal = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(json.getBytes("UTF-8"));
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE,sc );
byte[] encJson = cipher.doFinal(baos.toByteArray());
String base64d = new String(org.bouncycastle.util.encoders.Base64.encode(encJson));
Token token = new Token();
token.setEncryptedRequest(base64d);
token.setIv(new String(org.bouncycastle.util.encoders.Base64.encode(cipher.getIV())));
json = gson.toJson(token);
attrVal = new String(org.bouncycastle.util.encoders.Base64.encode(json.getBytes("UTF-8")));
} catch (Exception e) {
throw new ProvisioningException("Could not encrypt key",e);
}
return attrVal;
}
开发者ID:TremoloSecurity,
项目名称:OpenUnison,
代码行数:38,
代码来源:CreateOTPKey.java
示例5: processService
点赞 2
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
@Secured({ "ROLE_USER", "ROLE_ADMIN"})
@Override
public SetGoogleAuthenticatorCredentialResponse processService(
final SetGoogleAuthenticatorCredentialRequest serviceRequest) {
LOGGER.info("{}:{}",serviceRequest.getClass().getSimpleName(),serviceRequest.getSessionId());
final CreateApplicationEventRequest eventRequest = new CreateApplicationEventRequest();
eventRequest.setEventGroup(ApplicationEventGroup.USER);
eventRequest.setApplicationOperation(ApplicationOperationType.CREATE);
eventRequest.setActionName(SetGoogleAuthenticatorCredentialRequest.class.getSimpleName());
eventRequest.setSessionId(serviceRequest.getSessionId());
final UserAccount userAccount = getUserAccountFromSecurityContext();
final SetGoogleAuthenticatorCredentialResponse response = new SetGoogleAuthenticatorCredentialResponse(ServiceResult.SUCCESS);
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
final GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey gKey = gAuth.createCredentials();
final UserAccount updateUserAccount = userDAO.load(userAccount.getHjid());
updateUserAccount.setGoogleAuthKey(gKey.getKey());
updateUserAccount.setGoogleAuthVerificationCode(gKey.getVerificationCode());
updateUserAccount.setGoogleAuthScratchCodes(gKey.getScratchCodes());
userDAO.merge(updateUserAccount);
final String otpAuthTotpURL = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL(agencyDAO.getAll().get(0).getAgencyName(), updateUserAccount.getEmail(), gKey);
response.setOtpAuthTotpURL(otpAuthTotpURL);
response.setGoogleAuthKey(gKey.getKey());
response.setGoogleAuthVerificationCode(gKey.getVerificationCode());
response.setGoogleAuthScratchCodes(gKey.getScratchCodes());
}
eventRequest.setApplicationMessage(response.getResult().toString());
createApplicationEventService.processService(eventRequest);
return response;
}
开发者ID:Hack23,
项目名称:cia,
代码行数:45,
代码来源:SetGoogleAuthenticatorCredentialService.java
示例6: create
点赞 2
import com.warrenstrange.googleauth.GoogleAuthenticatorKey; //导入依赖的package包/类
@Override
public OneTimeTokenAccount create(final String username) {
final GoogleAuthenticatorKey key = this.googleAuthenticator.createCredentials();
return new GoogleAuthenticatorAccount(username, key.getKey(), key.getVerificationCode(), key.getScratchCodes());
}
开发者ID:mrluo735,
项目名称:cas-5.1.0,
代码行数:6,
代码来源:RestGoogleAuthenticatorTokenCredentialRepository.java