@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode()); hashCode = prime * hashCode + ((getLogins() == null) ? 0 : getLogins().hashCode()); hashCode = prime * hashCode + ((getCustomRoleArn() == null) ? 0 : getCustomRoleArn().hashCode()); return hashCode; }
/** * To be used to help the calling of the 2hop flow in event of the identity * id being either missing or deleted. Once that is caught as having * happened, this call is made, which will clear the old id, get a new * one/token, and get the flow going back to where it was with a new request * * @return the result of the new request */ private GetCredentialsForIdentityResult retryGetCredentialsForIdentity() { token = retryRefresh(); Map<String, String> logins; if (token != null && !token.isEmpty()) { logins = new HashMap<String, String>(); logins.put(getLoginsKey(), token); } else { logins = getLogins(); } GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn); return cib.getCredentialsForIdentity(request); }
String cognitoIdentityId = "your user's identity id"; String openIdToken = "open id token for the user created on backend"; Map<String,String> logins = new HashMap<>(); logins.put("cognito-identity.amazonaws.com", openIdToken); GetCredentialsForIdentityRequest getCredentialsRequest = new GetCredentialsForIdentityRequest() .withIdentityId(cognitoIdentityId) .withLogins(logins); AmazonCognitoIdentityClient cognitoIdentityClient = new AmazonCognitoIdentityClient(); GetCredentialsForIdentityResult getCredentialsResult = cognitoIdentityClient.getCredentialsForIdentity(getCredentialsRequest); Credentials credentials = getCredentialsResult.getCredentials(); AWSSessionCredentials sessionCredentials = new BasicSessionCredentials( credentials.getAccessKeyId(), credentials.getSecretKey(), credentials.getSessionToken() ); AmazonS3Client s3Client = new AmazonS3Client(sessionCredentials); ...
GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetCredentialsForIdentityRequest == false) return false; GetCredentialsForIdentityRequest other = (GetCredentialsForIdentityRequest) obj; if (other.getIdentityId() == null ^ this.getIdentityId() == null) return false; if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false) return false; if (other.getLogins() == null ^ this.getLogins() == null) return false; if (other.getLogins() != null && other.getLogins().equals(this.getLogins()) == false) return false; if (other.getCustomRoleArn() == null ^ this.getCustomRoleArn() == null) return false; if (other.getCustomRoleArn() != null && other.getCustomRoleArn().equals(this.getCustomRoleArn()) == false) return false; return true; }
/** * To be used to help the calling of the 2hop flow in event of the identity * id being either missing or deleted. Once that is caught as having * happened, this call is made, which will clear the old id, get a new * one/token, and get the flow going back to where it was with a new request * * @return the result of the new request */ private GetCredentialsForIdentityResult retryGetCredentialsForIdentity() { token = retryRefresh(); Map<String, String> logins; if (token != null && !token.isEmpty()) { logins = new HashMap<String, String>(); logins.put("cognito-identity.amazonaws.com", token); } else { logins = getLogins(); } GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn); return cib.getCredentialsForIdentity(request); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getIdentityId() != null) sb.append("IdentityId: ").append(getIdentityId()).append(","); if (getLogins() != null) sb.append("Logins: ").append(getLogins()).append(","); if (getCustomRoleArn() != null) sb.append("CustomRoleArn: ").append(getCustomRoleArn()); sb.append("}"); return sb.toString(); }
/** * To be used to help the calling of the 2hop flow in event of the identity * id being either missing or deleted. Once that is caught as having * happened, this call is made, which will clear the old id, get a new * one/token, and get the flow going back to where it was with a new request * * @return the result of the new request */ private GetCredentialsForIdentityResult retryGetCredentialsForIdentity() { token = retryRefresh(); Map<String, String> logins; if (token != null && !token.isEmpty()) { logins = new HashMap<String, String>(); logins.put(getLoginsKey(), token); } else { logins = getLogins(); } GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn); return cib.getCredentialsForIdentity(request); }
/** * Marshall the given parameter object. */ public void marshall(GetCredentialsForIdentityRequest getCredentialsForIdentityRequest, ProtocolMarshaller protocolMarshaller) { if (getCredentialsForIdentityRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(getCredentialsForIdentityRequest.getIdentityId(), IDENTITYID_BINDING); protocolMarshaller.marshall(getCredentialsForIdentityRequest.getLogins(), LOGINS_BINDING); protocolMarshaller.marshall(getCredentialsForIdentityRequest.getCustomRoleArn(), CUSTOMROLEARN_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn);
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode()); hashCode = prime * hashCode + ((getLogins() == null) ? 0 : getLogins().hashCode()); hashCode = prime * hashCode + ((getCustomRoleArn() == null) ? 0 : getCustomRoleArn().hashCode()); return hashCode; }
GetCredentialsForIdentityRequest request = new GetCredentialsForIdentityRequest() .withIdentityId(getIdentityId()) .withLogins(logins).withCustomRoleArn(customRoleArn);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetCredentialsForIdentityRequest == false) return false; GetCredentialsForIdentityRequest other = (GetCredentialsForIdentityRequest) obj; if (other.getIdentityId() == null ^ this.getIdentityId() == null) return false; if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false) return false; if (other.getLogins() == null ^ this.getLogins() == null) return false; if (other.getLogins() != null && other.getLogins().equals(this.getLogins()) == false) return false; if (other.getCustomRoleArn() == null ^ this.getCustomRoleArn() == null) return false; if (other.getCustomRoleArn() != null && other.getCustomRoleArn().equals(this.getCustomRoleArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getIdentityId() != null) sb.append("IdentityId: " + getIdentityId() + ","); if (getLogins() != null) sb.append("Logins: " + getLogins() + ","); if (getCustomRoleArn() != null) sb.append("CustomRoleArn: " + getCustomRoleArn()); sb.append("}"); return sb.toString(); }
jsonWriter.beginObject(); if (getCredentialsForIdentityRequest.getIdentityId() != null) { String identityId = getCredentialsForIdentityRequest.getIdentityId(); jsonWriter.name("IdentityId"); jsonWriter.value(identityId); if (getCredentialsForIdentityRequest.getLogins() != null) { java.util.Map<String, String> logins = getCredentialsForIdentityRequest.getLogins(); jsonWriter.name("Logins"); jsonWriter.beginObject(); if (getCredentialsForIdentityRequest.getCustomRoleArn() != null) { String customRoleArn = getCredentialsForIdentityRequest.getCustomRoleArn(); jsonWriter.name("CustomRoleArn"); jsonWriter.value(customRoleArn);
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode()); hashCode = prime * hashCode + ((getLogins() == null) ? 0 : getLogins().hashCode()); hashCode = prime * hashCode + ((getCustomRoleArn() == null) ? 0 : getCustomRoleArn().hashCode()); return hashCode; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getIdentityId() == null) ? 0 : getIdentityId().hashCode()); hashCode = prime * hashCode + ((getLogins() == null) ? 0 : getLogins().hashCode()); hashCode = prime * hashCode + ((getCustomRoleArn() == null) ? 0 : getCustomRoleArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetCredentialsForIdentityRequest == false) return false; GetCredentialsForIdentityRequest other = (GetCredentialsForIdentityRequest) obj; if (other.getIdentityId() == null ^ this.getIdentityId() == null) return false; if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false) return false; if (other.getLogins() == null ^ this.getLogins() == null) return false; if (other.getLogins() != null && other.getLogins().equals(this.getLogins()) == false) return false; if (other.getCustomRoleArn() == null ^ this.getCustomRoleArn() == null) return false; if (other.getCustomRoleArn() != null && other.getCustomRoleArn().equals(this.getCustomRoleArn()) == false) return false; return true; } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetCredentialsForIdentityRequest == false) return false; GetCredentialsForIdentityRequest other = (GetCredentialsForIdentityRequest) obj; if (other.getIdentityId() == null ^ this.getIdentityId() == null) return false; if (other.getIdentityId() != null && other.getIdentityId().equals(this.getIdentityId()) == false) return false; if (other.getLogins() == null ^ this.getLogins() == null) return false; if (other.getLogins() != null && other.getLogins().equals(this.getLogins()) == false) return false; if (other.getCustomRoleArn() == null ^ this.getCustomRoleArn() == null) return false; if (other.getCustomRoleArn() != null && other.getCustomRoleArn().equals(this.getCustomRoleArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getIdentityId() != null) sb.append("IdentityId: " + getIdentityId() + ","); if (getLogins() != null) sb.append("Logins: " + getLogins() + ","); if (getCustomRoleArn() != null) sb.append("CustomRoleArn: " + getCustomRoleArn()); sb.append("}"); return sb.toString(); }