/// <summary> /// Returns true if OrgApacheJackrabbitOakSecurityAuthenticationTokenTokenConfiguraProperties instances are equal /// </summary> /// <param name="other">Instance of OrgApacheJackrabbitOakSecurityAuthenticationTokenTokenConfiguraProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(OrgApacheJackrabbitOakSecurityAuthenticationTokenTokenConfiguraProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( TokenExpiration == other.TokenExpiration || TokenExpiration != null && TokenExpiration.Equals(other.TokenExpiration) ) && ( TokenLength == other.TokenLength || TokenLength != null && TokenLength.Equals(other.TokenLength) ) && ( TokenRefresh == other.TokenRefresh || TokenRefresh != null && TokenRefresh.Equals(other.TokenRefresh) ) && ( TokenCleanupThreshold == other.TokenCleanupThreshold || TokenCleanupThreshold != null && TokenCleanupThreshold.Equals(other.TokenCleanupThreshold) ) && ( PasswordHashAlgorithm == other.PasswordHashAlgorithm || PasswordHashAlgorithm != null && PasswordHashAlgorithm.Equals(other.PasswordHashAlgorithm) ) && ( PasswordHashIterations == other.PasswordHashIterations || PasswordHashIterations != null && PasswordHashIterations.Equals(other.PasswordHashIterations) ) && ( PasswordSaltSize == other.PasswordSaltSize || PasswordSaltSize != null && PasswordSaltSize.Equals(other.PasswordSaltSize) )); }
public async Task <IServiceUserToken> AuthenticateUser(Credentials credentials) { var user = await AuthenticateUserInternal(credentials); user.AddClaim(new Claim(ServiceClaimConstants.Expiration, TokenExpiration.ToString())); var now = DateTime.Now; var secret = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ServiceConfiguration.Key)); var issuer = ServiceConfiguration.Name; var handler = new JwtSecurityTokenHandler(); var signingCreds = new SigningCredentials(secret, SecurityAlgorithms.HmacSha256); var token = handler.CreateJwtSecurityToken(issuer, null, user as ClaimsIdentity, now, DateTime.Now.AddDays(1), now, signingCreds); var encoded = handler.WriteToken(token); user.AddClaim(new Claim(ServiceClaimConstants.Digest, encoded)); return(user); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (TokenExpiration != null) { hashCode = hashCode * 59 + TokenExpiration.GetHashCode(); } if (TokenLength != null) { hashCode = hashCode * 59 + TokenLength.GetHashCode(); } if (TokenRefresh != null) { hashCode = hashCode * 59 + TokenRefresh.GetHashCode(); } if (TokenCleanupThreshold != null) { hashCode = hashCode * 59 + TokenCleanupThreshold.GetHashCode(); } if (PasswordHashAlgorithm != null) { hashCode = hashCode * 59 + PasswordHashAlgorithm.GetHashCode(); } if (PasswordHashIterations != null) { hashCode = hashCode * 59 + PasswordHashIterations.GetHashCode(); } if (PasswordSaltSize != null) { hashCode = hashCode * 59 + PasswordSaltSize.GetHashCode(); } return(hashCode); } }