public KeyListEntry unmarshall(JsonUnmarshallerContext context) throws Exception { KeyListEntry keyListEntry = new KeyListEntry(); if (context.testExpression("KeyId", targetDepth)) { context.nextToken(); keyListEntry.setKeyId(context.getUnmarshaller(String.class).unmarshall(context)); keyListEntry.setKeyArn(context.getUnmarshaller(String.class).unmarshall(context));
@Override public Set<Algorithm> call() throws BackgroundException { final AWSKMS client = client(container); try { final Map<String, String> aliases = new HashMap<String, String>(); for(AliasListEntry entry : client.listAliases().getAliases()) { aliases.put(entry.getTargetKeyId(), entry.getAliasName()); } final Set<Algorithm> keys = new HashSet<Algorithm>(); for(KeyListEntry entry : client.listKeys().getKeys()) { keys.add(new AliasedAlgorithm(entry, aliases.get(entry.getKeyId()))); } return keys; } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot read AWS KMS configuration", e); } finally { client.shutdown(); } } }, prompt));
/** * <p> * Unique identifier of the key. * </p> * * @param keyId * Unique identifier of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyId(String keyId) { setKeyId(keyId); return this; }
/** * <p> * ARN of the key. * </p> * * @param keyArn * ARN of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyArn(String keyArn) { setKeyArn(keyArn); return this; }
public AliasedAlgorithm(final KeyListEntry entry, final String alias) { super(KMSEncryptionFeature.SSE_KMS_DEFAULT.algorithm, entry.getKeyArn()); this.entry = entry; this.alias = alias; }
KMSKeyVH kmsKey = new KMSKeyVH(); try { DescribeKeyResult result = awskms.describeKey(new DescribeKeyRequest().withKeyId(key.getKeyId())); kmsKey.setKey(result.getKeyMetadata()); kmsKey.setTags(awskms.listResourceTags(new ListResourceTagsRequest().withKeyId(key.getKeyId())).getTags()); } catch (Exception e) { log.debug(e.getMessage()); kmsKey.setRotationStatus(awskms.getKeyRotationStatus(new GetKeyRotationStatusRequest().withKeyId(key.getKeyId())).getKeyRotationEnabled()); } catch (Exception e) { log.debug(e.getMessage()); if(key.getKeyId().equals(alias.getTargetKeyId())) { kmsKey.setAlias(alias); break;
/** * <p> * Unique identifier of the key. * </p> * * @param keyId * Unique identifier of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyId(String keyId) { setKeyId(keyId); return this; }
/** * <p> * ARN of the key. * </p> * * @param keyArn * ARN of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyArn(String keyArn) { setKeyArn(keyArn); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof KeyListEntry == false) return false; KeyListEntry other = (KeyListEntry) obj; if (other.getKeyId() == null ^ this.getKeyId() == null) return false; if (other.getKeyId() != null && other.getKeyId().equals(this.getKeyId()) == false) return false; if (other.getKeyArn() == null ^ this.getKeyArn() == null) return false; if (other.getKeyArn() != null && other.getKeyArn().equals(this.getKeyArn()) == false) return false; return true; }
public KeyListEntry unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } KeyListEntry keyListEntry = new KeyListEntry(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("KeyId")) { keyListEntry.setKeyId(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("KeyArn")) { keyListEntry.setKeyArn(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return keyListEntry; }
/** * <p> * Unique identifier of the key. * </p> * * @param keyId * Unique identifier of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyId(String keyId) { setKeyId(keyId); return this; }
/** * <p> * ARN of the key. * </p> * * @param keyArn * ARN of the key. * @return Returns a reference to this object so that method calls can be chained together. */ public KeyListEntry withKeyArn(String keyArn) { setKeyArn(keyArn); return this; }
/** * 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 (getKeyId() != null) sb.append("KeyId: ").append(getKeyId()).append(","); if (getKeyArn() != null) sb.append("KeyArn: ").append(getKeyArn()); sb.append("}"); return sb.toString(); }
public KeyListEntry unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } KeyListEntry keyListEntry = new KeyListEntry(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("KeyId")) { keyListEntry.setKeyId(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("KeyArn")) { keyListEntry.setKeyArn(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return keyListEntry; }
/** * Marshall the given parameter object. */ public void marshall(KeyListEntry keyListEntry, ProtocolMarshaller protocolMarshaller) { if (keyListEntry == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(keyListEntry.getKeyId(), KEYID_BINDING); protocolMarshaller.marshall(keyListEntry.getKeyArn(), KEYARN_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
public KeyListEntry unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } KeyListEntry keyListEntry = new KeyListEntry(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("KeyId")) { keyListEntry.setKeyId(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("KeyArn")) { keyListEntry.setKeyArn(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return keyListEntry; }
public KeyListEntry unmarshall(JsonUnmarshallerContext context) throws Exception { KeyListEntry keyListEntry = new KeyListEntry(); if (context.testExpression("KeyId", targetDepth)) { context.nextToken(); keyListEntry.setKeyId(context.getUnmarshaller(String.class).unmarshall(context)); keyListEntry.setKeyArn(context.getUnmarshaller(String.class).unmarshall(context));