private static KeyDescriptor buildKeyDescriptorElement(UsageType type, KeyInfo key) { final KeyDescriptor descriptor = build(KeyDescriptor.DEFAULT_ELEMENT_NAME); descriptor.setUse(type); descriptor.setKeyInfo(key); return descriptor; } }
private static KeyDescriptor buildKeyDescriptorElement(UsageType type, KeyInfo key) { final KeyDescriptor descriptor = build(KeyDescriptor.DEFAULT_ELEMENT_NAME); descriptor.setUse(type); descriptor.setKeyInfo(key); return descriptor; } }
/** {@inheritDoc} */ protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { KeyDescriptor keyDescriptor = (KeyDescriptor) samlObject; if (attribute.getName().equals(KeyDescriptor.USE_ATTRIB_NAME)) { try { UsageType usageType = UsageType.valueOf(UsageType.class, attribute.getValue().toUpperCase()); // Only allow the enum values specified in the schema. if (usageType != UsageType.SIGNING && usageType != UsageType.ENCRYPTION) { throw new UnmarshallingException("Invalid key usage type: " + attribute.getValue()); } keyDescriptor.setUse(usageType); } catch (IllegalArgumentException e) { throw new UnmarshallingException("Invalid key usage type: " + attribute.getValue()); } } else { super.processAttribute(samlObject, attribute); } }
protected final KeyDescriptor getKeyDescriptor(final UsageType type, final KeyInfo key) { final SAMLObjectBuilder<KeyDescriptor> builder = (SAMLObjectBuilder<KeyDescriptor>) Configuration.getBuilderFactory() .getBuilder(KeyDescriptor.DEFAULT_ELEMENT_NAME); final KeyDescriptor descriptor = builder.buildObject(); descriptor.setUse(type); descriptor.setKeyInfo(key); return descriptor; }
public KeyDescriptor getKeyDescriptor(SimpleKey key) { SAMLObjectBuilder<KeyDescriptor> builder = (SAMLObjectBuilder<KeyDescriptor>) getBuilderFactory() .getBuilder(KeyDescriptor.DEFAULT_ELEMENT_NAME); KeyDescriptor descriptor = builder.buildObject(); KeyStoreCredentialResolver resolver = getCredentialsResolver(key); Credential credential = getCredential(key, resolver); try { KeyInfo info = getKeyInfoGenerator(credential).generate(credential); descriptor.setKeyInfo(info); if (key.getType() != null) { descriptor.setUse(UsageType.valueOf(key.getType().toString())); } else { descriptor.setUse(UsageType.SIGNING); } return descriptor; } catch (SecurityException e) { throw new SamlKeyException(e); } }
signingKeyDescriptor.setUse(UsageType.SIGNING); KeyInfo signingKeyInfo = keyInfoBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME); X509Data signingX509Data = x509DataBuilder.buildObject(X509Data.DEFAULT_ELEMENT_NAME); encKeyDescriptor.setUse(UsageType.ENCRYPTION); KeyInfo encKeyInfo = keyInfoBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME); X509Data encX509Data = x509DataBuilder.buildObject(X509Data.DEFAULT_ELEMENT_NAME);
signingKeyDescriptor.setUse(UsageType.SIGNING); KeyInfo signingKeyInfo = keyInfoBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME); X509Data signingX509Data = x509DataBuilder.buildObject(X509Data.DEFAULT_ELEMENT_NAME); encKeyDescriptor.setUse(UsageType.ENCRYPTION); KeyInfo encKeyInfo = keyInfoBuilder.buildObject(KeyInfo.DEFAULT_ELEMENT_NAME); X509Data encX509Data = x509DataBuilder.buildObject(X509Data.DEFAULT_ELEMENT_NAME);