当前位置: 首页>>代码示例>>Java>>正文


Java UsageType类代码示例

本文整理汇总了Java中org.opensaml.xml.security.credential.UsageType的典型用法代码示例。如果您正苦于以下问题:Java UsageType类的具体用法?Java UsageType怎么用?Java UsageType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UsageType类属于org.opensaml.xml.security.credential包,在下文中一共展示了UsageType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCriteriaSet

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:BaseSAMLXMLSignatureSecurityPolicyRule.java

示例2: MetadataCacheKey

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param entityID entity ID of the credential owner
 * @param entityRole role in which the entity is operating
 * @param entityProtocol protocol over which the entity is operating (may be null)
 * @param entityUsage usage of the resolved credentials
 */
protected MetadataCacheKey(String entityID, QName entityRole, String entityProtocol, UsageType entityUsage) {
    if (entityID == null) {
        throw new IllegalArgumentException("Entity ID may not be null");
    }
    if (entityRole == null) {
        throw new IllegalArgumentException("Entity role may not be null");
    }
    if (entityUsage == null) {
        throw new IllegalArgumentException("Credential usage may not be null");
    }
    id = entityID;
    role = entityRole;
    protocol = entityProtocol;
    usage = entityUsage;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:MetadataCredentialResolver.java

示例3: buildCriteriaSet

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Build a criteria set suitable for input to the trust engine.
 * 
 * @param entityID the candidate issuer entity ID which is being evaluated
 * @param samlContext the message context which is being evaluated
 * @return a newly constructly set of criteria suitable for the configured trust engine
 * @throws SecurityPolicyException thrown if criteria set can not be constructed
 */
protected CriteriaSet buildCriteriaSet(String entityID, SAMLMessageContext samlContext)
        throws SecurityPolicyException {

    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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:BaseSAMLSimpleSignatureSecurityPolicyRule.java

示例4: processAttribute

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@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());
        }
    }

    super.processAttribute(samlObject, attribute);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:KeyDescriptorUnmarshaller.java

示例5: marshallAttributes

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject;

    if (keyDescriptor.getUse() != null) {
        UsageType use = keyDescriptor.getUse();
        // UsageType enum contains more values than are allowed by SAML 2 schema
        if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) {
            domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase());
        } else if (use.equals(UsageType.UNSPECIFIED)) {
            // emit nothing for unspecified - this is semantically equivalent to non-existent attribute
        } else {
            // Just in case values are unknowingly added to UsageType in the future...
            throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString());
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:KeyDescriptorMarshaller.java

示例6: getCertificates

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
private static List<X509Certificate> getCertificates(IDPSSODescriptor idpSsoDescriptor)
    throws SamlException {

  List<X509Certificate> certificates;

  try {
    certificates =
        idpSsoDescriptor
            .getKeyDescriptors()
            .stream()
            .filter(x -> x.getUse() == UsageType.SIGNING)
            .flatMap(SamlClient::getDatasWithCertificates)
            .map(SamlClient::getFirstCertificate)
            .collect(Collectors.toList());

  } catch (Exception e) {
    throw new SamlException("Exception in getCertificates", e);
  }

  return certificates;
}
 
开发者ID:coveo,项目名称:saml-client,代码行数:22,代码来源:SamlClient.java

示例7: buildCriteriaSet

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Build the criteria set which will be used as input to the configured trust engine.
 * 
 * @param signedMetadata the metadata element whose signature is being verified
 * @param metadataEntryName the EntityDescriptor entityID or EntitiesDescriptor Name 
 *                          of the signature being evaluated
 * @param isEntityGroup flag indicating whether the signed object is a metadata group (EntitiesDescriptor)
 * @return the newly constructed criteria set
 */
protected CriteriaSet buildCriteriaSet(SignableXMLObject signedMetadata,
        String metadataEntryName, boolean isEntityGroup) {
    
    CriteriaSet newCriteriaSet = new CriteriaSet();
    
    if (getDefaultCriteria() != null) {
        newCriteriaSet.addAll( getDefaultCriteria() );
    }
    
    //TODO how to handle adding dynamic entity ID (or other) criteria (if at all?),
    
    if (!newCriteriaSet.contains(UsageCriteria.class)) {
        newCriteriaSet.add( new UsageCriteria(UsageType.SIGNING) );
    }
    
    return newCriteriaSet;
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:27,代码来源:SignatureValidationFilter.java

示例8: processAttribute

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@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());
        }
    }

    super.processAttribute(samlObject, attribute);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:20,代码来源:KeyDescriptorUnmarshaller.java

示例9: marshallAttributes

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject;

    if (keyDescriptor.getUse() != null) {
        UsageType use = keyDescriptor.getUse();
        // UsageType enum contains more values than are allowed by SAML 2 schema 
        if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) {
            domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase());
        } else if (use.equals(UsageType.UNSPECIFIED)) {
            //emit nothing for unspecified - this is semantically equivalent to non-existent attribute
        } else {
            // Just in case values are unknowingly added to UsageType in the future...
           throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString());
        }
    }
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:18,代码来源:KeyDescriptorMarshaller.java

示例10: buildCriteriaSet

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Build a criteria set suitable for input to the trust engine.
 *
 * @param entityID the candidate issuer entity ID which is being evaluated
 * @param samlContext the message context which is being evaluated
 * @return a newly constructly set of criteria suitable for the configured trust engine
 * @throws SecurityPolicyException thrown if criteria set can not be constructed
 */
protected CriteriaSet buildCriteriaSet(String entityID, SAMLMessageContext samlContext)
        throws SecurityPolicyException {

    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;
}
 
开发者ID:brainysmith,项目名称:idp-play-bridge,代码行数:25,代码来源:BaseSAMLSimpleSignatureSecurityPolicyRuleExtended.java

示例11: ServletRequestX509CredentialAdapter

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param request the servlet request
 */
public ServletRequestX509CredentialAdapter(ServletRequest request) {
    X509Certificate[] chain = (X509Certificate[]) request.getAttribute(X509_CERT_REQUEST_ATTRIBUTE);
    if (chain == null || chain.length == 0) {
        throw new IllegalArgumentException("Servlet request does not contain X.509 certificates in attribute "
                + X509_CERT_REQUEST_ATTRIBUTE);
    }

    setEntityCertificate(chain[0]);
    setEntityCertificateChain(Arrays.asList(chain));
    setUsageType(UsageType.SIGNING);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ServletRequestX509CredentialAdapter.java

示例12: buildCriteriaSet

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@inheritDoc} */
protected CriteriaSet buildCriteriaSet(String entityID, MessageContext messageContext)
        throws SecurityPolicyException {

    CriteriaSet criteriaSet = new CriteriaSet();
    if (!DatatypeHelper.isEmpty(entityID)) {
        criteriaSet.add(new EntityIDCriteria(entityID));
    }

    criteriaSet.add(new UsageCriteria(UsageType.SIGNING));

    return criteriaSet;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ClientCertAuthRule.java

示例13: setUsage

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Set the key usage criteria.
 * 
 * @param usage The usage to set.
 */
public void setUsage(UsageType usage) {
    if (usage != null) {
        credUsage = usage;
    } else {
        credUsage = UsageType.UNSPECIFIED;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:UsageCriteria.java

示例14: EvaluableUsageCredentialCriteria

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param newUsage the criteria value which is the basis for evaluation
 */
public EvaluableUsageCredentialCriteria(UsageType newUsage) {
    if (newUsage == null) {
        throw new IllegalArgumentException("Usage may not be null");
    }
    usage = newUsage;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:EvaluableUsageCredentialCriteria.java

示例15: evaluate

import org.opensaml.xml.security.credential.UsageType; //导入依赖的package包/类
/** {@inheritDoc} */
public Boolean evaluate(Credential target) {
    if (target == null) {
        log.error("Credential target was null");
        return null;
    }
    UsageType credUsage = target.getUsageType();
    if (credUsage == null) {
        log.info("Could not evaluate criteria, credential contained no usage specifier");
        return null;
    }

    Boolean result = matchUsage(credUsage, usage);
    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:EvaluableUsageCredentialCriteria.java


注:本文中的org.opensaml.xml.security.credential.UsageType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。