/** * {@inheritDoc} */ @Override public void setIssueTime(Date iat) { innerToken.setIssueTime(iat); }
/** * {@inheritDoc} */ @Override public void setIssueTime(Date iat) { innerToken.setIssueTime(iat); }
@Override protected void doLogin(AuthToken authToken) throws HasLoginException { //Get the user info from env String userName = System.getenv("userName"); if (userName == null || userName.isEmpty()) { throw new HasLoginException("Please set the userName."); } String password = System.getenv("password"); if (password == null || password.isEmpty()) { throw new HasLoginException("Please set the password."); } LOG.debug("Get the user info successfully."); authToken.setIssuer("has"); authToken.setSubject(userName); final Date now = new Date(System.currentTimeMillis() / 1000 * 1000); authToken.setIssueTime(now); // Set expiration in 60 minutes Date exp = new Date(now.getTime() + 1000 * 60 * 60); authToken.setExpirationTime(exp); authToken.addAttribute("user", userName); authToken.addAttribute("secret", password); authToken.addAttribute("passPhrase", userName + password); } }
@Override protected void doLogin(AuthToken authToken) throws HasLoginException { //Get the user info from env String userName = System.getenv("userName"); if (userName == null || userName.isEmpty()) { throw new HasLoginException("Please set the userName."); } String password = System.getenv("password"); if (password == null || password.isEmpty()) { throw new HasLoginException("Please set the password."); } LOG.debug("Get the user info successfully."); authToken.setIssuer("has"); authToken.setSubject(userName); final Date now = new Date(System.currentTimeMillis() / 1000 * 1000); authToken.setIssueTime(now); // Set expiration in 60 minutes Date exp = new Date(now.getTime() + 1000 * 60 * 60); authToken.setExpirationTime(exp); authToken.addAttribute("user", userName); authToken.addAttribute("secret", password); authToken.addAttribute("passPhrase", userName + password); } }
authToken.setIssueTime(now);
authToken.setIssueTime(now);
public static AuthToken issueToken(String principal, String group, String role) { AuthToken authToken = KrbRuntime.getTokenProvider("JWT").createTokenFactory().createToken(); String iss = "token-service"; authToken.setIssuer(iss); String sub = principal; authToken.setSubject(sub); authToken.addAttribute("group", group); if (role != null) { authToken.addAttribute("role", role); } List<String> aud = new ArrayList<>(); aud.add("krb5kdc-with-token-extension"); authToken.setAudiences(aud); // Set expiration in 60 minutes final Date now = new Date(new Date().getTime() / 1000 * 1000); Date exp = new Date(now.getTime() + 1000 * 60 * 60); authToken.setExpirationTime(exp); Date nbf = now; authToken.setNotBeforeTime(nbf); Date iat = now; authToken.setIssueTime(iat); return authToken; }
public static AuthToken issueToken(String principal, String group, String role) { AuthToken authToken = KrbRuntime.getTokenProvider("JWT").createTokenFactory().createToken(); String iss = "token-service"; authToken.setIssuer(iss); String sub = principal; authToken.setSubject(sub); authToken.addAttribute("group", group); if (role != null) { authToken.addAttribute("role", role); } List<String> aud = new ArrayList<>(); aud.add("krb5kdc-with-token-extension"); authToken.setAudiences(aud); // Set expiration in 60 minutes final Date now = new Date(new Date().getTime() / 1000 * 1000); Date exp = new Date(now.getTime() + 1000 * 60 * 60); authToken.setExpirationTime(exp); Date nbf = now; authToken.setNotBeforeTime(nbf); Date iat = now; authToken.setIssueTime(iat); return authToken; }