Java Code Examples for org.opensaml.xml.util.DatatypeHelper#isEmpty()
The following examples show how to use
org.opensaml.xml.util.DatatypeHelper#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseSAMLXMLSignatureSecurityPolicyRule.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected CriteriaSet buildCriteriaSet(String entityID, MessageContext messageContext) throws SecurityPolicyException { if (!(messageContext instanceof SAMLMessageContext)) { log.error("Supplied message context was not an instance of SAMLMessageContext, can not build criteria set from SAML metadata parameters"); throw new SecurityPolicyException("Supplied message context was not an instance of SAMLMessageContext"); } SAMLMessageContext samlContext = (SAMLMessageContext) messageContext; CriteriaSet criteriaSet = new CriteriaSet(); if (! DatatypeHelper.isEmpty(entityID)) { criteriaSet.add(new EntityIDCriteria(entityID) ); } MetadataCriteria mdCriteria = new MetadataCriteria(samlContext.getPeerEntityRole(), samlContext.getInboundSAMLProtocol()); criteriaSet.add(mdCriteria); criteriaSet.add( new UsageCriteria(UsageType.SIGNING) ); return criteriaSet; }
Example 2
Source File: InlineX509DataProvider.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Find the certificate from the chain that matches one of the specified digests. * * @param certs list of certificates to evaluate * @param digests X509 digests to use as search criteria * @return the matching certificate, or null */ protected X509Certificate findCertFromDigest(List<X509Certificate> certs, List<XMLObject> digests) { byte[] certValue; byte[] xmlValue; for (XMLObject xo : digests) { if (!(xo instanceof X509Digest)) { continue; } X509Digest digest = (X509Digest) xo; if (!DatatypeHelper.isEmpty(digest.getValue())) { xmlValue = Base64.decode(digest.getValue()); for (X509Certificate cert : certs) { try { certValue = X509Util.getX509Digest(cert, digest.getAlgorithm()); if (certValue != null && Arrays.equals(xmlValue, certValue)) { return cert; } } catch (SecurityException e) { // Ignore as no match. } } } } return null; }
Example 3
Source File: PolicyTypeMarshaller.java From lams with GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { PolicyType policy = (PolicyType) xmlObject; if (!DatatypeHelper.isEmpty(policy.getPolicyId())) { domElement.setAttribute(PolicyType.POLICY_ID_ATTRIB_NAME, policy.getPolicyId()); } if (!DatatypeHelper.isEmpty(policy.getVersion())) { domElement.setAttribute(PolicyType.VERSION_ATTRIB_NAME, policy.getVersion()); } if (!DatatypeHelper.isEmpty(policy.getRuleCombiningAlgoId())) { domElement.setAttribute(PolicyType.RULE_COMBINING_ALG_ID_ATTRIB_NAME, policy.getRuleCombiningAlgoId()); } }
Example 4
Source File: KeyInfoHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Check whether the specified {@link DSAKeyValue} element has the all optional DSA * values which can be shared amongst many keys in a DSA "key family", and * are presumed to be known from context. * * @param keyDescriptor the {@link DSAKeyValue} element to check * @return true if all parameters are present and non-empty, false otherwise */ public static boolean hasCompleteDSAParams(DSAKeyValue keyDescriptor) { if ( keyDescriptor.getG() == null || DatatypeHelper.isEmpty(keyDescriptor.getG().getValue()) || keyDescriptor.getP() == null || DatatypeHelper.isEmpty(keyDescriptor.getP().getValue()) || keyDescriptor.getQ() == null || DatatypeHelper.isEmpty(keyDescriptor.getQ().getValue()) ) { return false; } return true; }
Example 5
Source File: PolicyCombinerParametersTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { PolicyCombinerParametersType policyCombinerParametersType = (PolicyCombinerParametersType)xmlObject; if(!DatatypeHelper.isEmpty(policyCombinerParametersType.getPolicyIdRef())){ domElement.setAttribute(PolicyCombinerParametersType.POLICY_ID_REF_ATTRIB_NAME, policyCombinerParametersType.getPolicyIdRef()); } super.marshallAttributes(xmlObject, domElement); }
Example 6
Source File: ClasspathResource.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor. * * @param path the path to the file for this resource * * @throws ResourceException thrown if the resource path is null or empty or if the resource does not exist */ public ClasspathResource(String path) throws ResourceException { super(); if (DatatypeHelper.isEmpty(path)) { throw new ResourceException("Resource path may not be null or empty"); } resource = getClass().getResource(path); if (resource == null) { throw new ResourceException("Classpath resource does not exist: " + path); } lastModTime = new DateTime(); }
Example 7
Source File: ReplayCache.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor. * * @param storageService the StorageService which serves as the backing store for the cache * @param storageParition name of storage service partition to use * @param duration default length of time that message state is valid */ public ReplayCache(StorageService<String, ReplayCacheEntry> storageService, String storageParition, long duration) { storage = storageService; entryDuration = duration; if (!DatatypeHelper.isEmpty(storageParition)) { partition = DatatypeHelper.safeTrim(storageParition); } else { partition = "replay"; } cacheLock = new ReentrantLock(true); }
Example 8
Source File: ApplyTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { ApplyType applyType = (ApplyType)xmlObject; if(!DatatypeHelper.isEmpty(applyType.getFunctionId())){ domElement.setAttribute(ApplyType.FUNCTION_ID_ATTRIB_NAME, applyType.getFunctionId()); } }
Example 9
Source File: X509KeyInfoGeneratorFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Process the options related to generation of KeyName elements based on the certificate's * subject DN value. * * @param keyInfo the KeyInfo element being processed. * @param cert the certificate being processed */ protected void processSubjectDNKeyName(KeyInfo keyInfo, java.security.cert.X509Certificate cert) { if (options.emitSubjectDNAsKeyName) { String subjectNameValue = getSubjectName(cert); if (! DatatypeHelper.isEmpty(subjectNameValue)) { KeyInfoHelper.addKeyName(keyInfo, subjectNameValue); } } }
Example 10
Source File: PolicySetTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { PolicySetType policySet = (PolicySetType) xmlObject; if (!DatatypeHelper.isEmpty(policySet.getPolicySetId())) { domElement.setAttribute(PolicySetType.POLICY_SET_ID_ATTRIB_NAME, policySet.getPolicySetId()); } if (!DatatypeHelper.isEmpty(policySet.getVersion())) { domElement.setAttribute(PolicySetType.VERSION_ATTRIB_NAME, policySet.getVersion()); } if (!DatatypeHelper.isEmpty(policySet.getPolicyCombiningAlgoId())) { domElement.setAttribute(PolicySetType.POLICY_COMBINING_ALG_ID_ATTRIB_NAME, policySet .getPolicyCombiningAlgoId()); } }
Example 11
Source File: BaseSAML2MessageEncoder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Checks that the relay state is 80 bytes or less if it is not null. * * @param relayState relay state to check * * @return true if the relay state is not empty and is less than 80 bytes */ protected boolean checkRelayState(String relayState) { if (!DatatypeHelper.isEmpty(relayState)) { if (relayState.getBytes().length > 80) { log.warn("Relay state exceeds 80 bytes, some application may not support this."); } return true; } return false; }
Example 12
Source File: FileBackedHttpResource.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor. * * @param resource HTTP(S) URL of the resource * @param backingFile filesystem location to store the resource */ public FileBackedHttpResource(String resource, String backingFile) { super(resource); if (DatatypeHelper.isEmpty(backingFile)) { throw new IllegalArgumentException("Backing file path may not be null or empty"); } resourceFile = new File(backingFile); }
Example 13
Source File: Decrypter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Dynamically construct key algorithm credential criteria based on the specified algorithm URI. * * @param encAlgorithmURI the algorithm URI * @return a new key algorithm credential criteria instance, or null if criteria could not be determined */ private KeyAlgorithmCriteria buildKeyAlgorithmCriteria(String encAlgorithmURI) { if (DatatypeHelper.isEmpty(encAlgorithmURI)) { return null; } String jcaKeyAlgorithm = SecurityHelper.getKeyAlgorithmFromURI(encAlgorithmURI); if (!DatatypeHelper.isEmpty(jcaKeyAlgorithm)) { return new KeyAlgorithmCriteria(jcaKeyAlgorithm); } return null; }
Example 14
Source File: VariableDefinitionTypeMarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException { VariableDefinitionType variableDefinitionType = (VariableDefinitionType) xmlObject; if(!DatatypeHelper.isEmpty(variableDefinitionType.getVariableId())){ domElement.setAttribute(VariableDefinitionType.VARIABLE_ID_ATTRIB_NAME, variableDefinitionType.getVariableId()); } }
Example 15
Source File: AttributeDesignatorSchemaValidator.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Checks that the AttributeNameSpace attribute is present and valid * @param designator * @throws ValidationException */ protected void validateNameSpace(AttributeDesignator designator) throws ValidationException { if (DatatypeHelper.isEmpty(designator.getAttributeNamespace())) { throw new ValidationException("AttributeNameSpace attribute not present or invalid"); } }
Example 16
Source File: KeywordsImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public void setXMLLang(String newLang) { boolean hasValue = newLang != null && !DatatypeHelper.isEmpty(newLang); lang = prepareForAssignment(lang, newLang); manageQualifiedAttributeNamespace(LangBearing.XML_LANG_ATTR_NAME, hasValue); }
Example 17
Source File: RequestAbstractTypeSchemaValidator.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Validates the ID attribute. * * @param request request to validate * @throws ValidationException if invalid */ protected void validateID(RequestAbstractType request) throws ValidationException { if (DatatypeHelper.isEmpty(request.getID())) { throw new ValidationException("ID attribute must not be empty"); } }
Example 18
Source File: AdditionalMetadataLocationSchemaValidator.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Checks that Namespace is present. * * @param aml * @throws ValidationException */ protected void validateNamespace(AdditionalMetadataLocation aml) throws ValidationException { if (DatatypeHelper.isEmpty(aml.getNamespaceURI())) { throw new ValidationException("Namespace required"); } }
Example 19
Source File: AssertionSchemaValidator.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Checks that the ID attribute is present. * * @param assertion * @throws ValidationException */ protected void validateID(Assertion assertion) throws ValidationException { if (DatatypeHelper.isEmpty(assertion.getID())) { throw new ValidationException("ID is required attribute"); } }
Example 20
Source File: NamespaceManager.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Check whether the supplied QName contains non-empty namespace info and should * be managed by the namespace manager. * * @param name the QName to check * @return true if the QName contains non-empty namespace info and should be managed, false otherwise */ private boolean checkQName(QName name) { return !DatatypeHelper.isEmpty(name.getNamespaceURI()); }