本文整理汇总了Java中org.opensaml.saml2.metadata.EntityDescriptor.getRoleDescriptors方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDescriptor.getRoleDescriptors方法的具体用法?Java EntityDescriptor.getRoleDescriptors怎么用?Java EntityDescriptor.getRoleDescriptors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.metadata.EntityDescriptor
的用法示例。
在下文中一共展示了EntityDescriptor.getRoleDescriptors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateRelyingPartyMetadata
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Populates the peer's entity metadata if a metadata provide is present in the message context. Populates the
* peer's role descriptor if the entity metadata was available and the role name is present in the message context.
*
* @param messageContext current message context
*
* @throws MessageDecodingException thrown if there is a problem populating the message context
*/
protected void populateRelyingPartyMetadata(SAMLMessageContext messageContext) throws MessageDecodingException {
MetadataProvider metadataProvider = messageContext.getMetadataProvider();
try {
if (metadataProvider != null) {
EntityDescriptor relyingPartyMD = metadataProvider.getEntityDescriptor(messageContext
.getInboundMessageIssuer());
messageContext.setPeerEntityMetadata(relyingPartyMD);
QName relyingPartyRole = messageContext.getPeerEntityRole();
if (relyingPartyMD != null && relyingPartyRole != null) {
List<RoleDescriptor> roles = relyingPartyMD.getRoleDescriptors(relyingPartyRole,
SAMLConstants.SAML11P_NS);
if (roles != null && roles.size() > 0) {
messageContext.setPeerEntityRoleMetadata(roles.get(0));
}
}
}
} catch (MetadataProviderException e) {
log.error("Error retrieving metadata for relying party " + messageContext.getInboundMessageIssuer(), e);
throw new MessageDecodingException("Error retrieving metadata for relying party "
+ messageContext.getInboundMessageIssuer(), e);
}
}
示例2: filterEntityDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Filters entity descriptor roles.
*
* @param descriptor entity descriptor to filter
*
* @throws FilterException thrown if an effective role name can not be determined
*/
protected void filterEntityDescriptor(EntityDescriptor descriptor) throws FilterException {
List<RoleDescriptor> roles = descriptor.getRoleDescriptors();
if (roles != null && !roles.isEmpty()) {
Iterator<RoleDescriptor> rolesItr = roles.iterator();
QName roleName;
while (rolesItr.hasNext()) {
roleName = getRoleName(rolesItr.next());
if (!roleWhiteList.contains(roleName)) {
log.trace("Filtering out role {} from entity {}", roleName, descriptor.getEntityID());
rolesItr.remove();
}
}
}
}
示例3: getMetadata
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Get a string representation of the signed metadata.
*
* This method replaces the KeyInfo elements in the SPMetadata.xml file with
* the actual certificate passed in the credentials parameter.
*
* @param signingCredential
* Credential to use for signing. If <code>null</code>, the
* metadata is not signed.
* @return The signed metadata as a string.
*/
public String getMetadata(Credential signingCredential, boolean sign) {
X509Credential c = (X509Credential) signingCredential;
EntityDescriptor e = SAMLUtil.clone(entityDescriptor);
for (RoleDescriptor rd : e.getRoleDescriptors()) {
for (KeyDescriptor k : rd.getKeyDescriptors()) {
for (X509Data data : k.getKeyInfo().getX509Datas()) {
for (X509Certificate cert : data.getX509Certificates()) {
try {
cert.setValue(Base64.encodeBytes(c.getEntityCertificate().getEncoded()));
} catch (CertificateEncodingException e1) {
throw new RuntimeException(e1);
}
}
}
}
}
OIOSamlObject obj = new OIOSamlObject(e);
if (sign) {
obj.sign(signingCredential);
}
return obj.toXML();
}
示例4: validateDescriptors
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Checks that an AffiliationDescriptor OR one or more RoleDescriptors are present.
*
* @param entityDescriptor
* @throws ValidationException
*/
protected void validateDescriptors(EntityDescriptor entityDescriptor) throws ValidationException {
if ((entityDescriptor.getRoleDescriptors() == null || entityDescriptor.getRoleDescriptors().size() < 1)
&& entityDescriptor.getAffiliationDescriptor() == null) {
throw new ValidationException("Must have an AffiliationDescriptor or one or more RoleDescriptors.");
}
if (entityDescriptor.getAffiliationDescriptor() != null && entityDescriptor.getRoleDescriptors() != null
&& entityDescriptor.getRoleDescriptors().size() > 0) {
throw new ValidationException("Cannot have an AffiliationDescriptor AND RoleDescriptors");
}
}
示例5: doGetRole
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Gets the identified roles from an EntityDescriptor. This method should not check if the provider is initialized,
* if arguments are null, if the roles are valid, etc. All of this is done by the invoker of this method.
*
* @param entityID ID of the entity from which to retrieve the roles, never null
* @param roleName name of the roles to search for, never null
*
* @return the modifiable list of identified roles or an empty list if no roles exists
*
* @throws MetadataProviderException thrown if there is a problem searching for the roles
*/
protected List<RoleDescriptor> doGetRole(String entityID, QName roleName) throws MetadataProviderException {
EntityDescriptor entity = doGetEntityDescriptor(entityID);
if (entity == null) {
log.debug("Metadata document did not contain a descriptor for entity {}", entityID);
return Collections.emptyList();
}
List<RoleDescriptor> descriptors = entity.getRoleDescriptors(roleName);
if (descriptors != null && !descriptors.isEmpty()) {
return new ArrayList<RoleDescriptor>(descriptors);
}
return Collections.emptyList();
}
示例6: getRole
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<RoleDescriptor> getRole(String entityID, QName roleName) throws MetadataProviderException {
EntityDescriptor entityMetadata = getEntityDescriptor(entityID);
if (entityMetadata == null) {
return null;
}
return entityMetadata.getRoleDescriptors(roleName);
}
示例7: getRole
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<RoleDescriptor> getRole(String entityID, QName roleName) throws MetadataProviderException {
EntityDescriptor entity = getEntityDescriptor(entityID);
if (entity != null) {
return entity.getRoleDescriptors(roleName);
} else {
return null;
}
}
示例8: filterEntitiesDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Filters entities descriptor.
*
* @param descriptor entities descriptor to filter
*
* @throws FilterException thrown if an effective role name can not be determined
*/
protected void filterEntitiesDescriptor(EntitiesDescriptor descriptor) throws FilterException {
// First we filter out any contained EntityDescriptors
List<EntityDescriptor> entityDescriptors = descriptor.getEntityDescriptors();
if (entityDescriptors != null && !entityDescriptors.isEmpty()) {
List<EntityDescriptor> emptyEntityDescriptors = new ArrayList<EntityDescriptor>();
Iterator<EntityDescriptor> entityDescriptorsItr = entityDescriptors.iterator();
EntityDescriptor entityDescriptor;
List<RoleDescriptor> entityRoles;
while (entityDescriptorsItr.hasNext()) {
entityDescriptor = entityDescriptorsItr.next();
filterEntityDescriptor(entityDescriptor);
if (getRemoveRolelessEntityDescriptors()) {
entityRoles = entityDescriptor.getRoleDescriptors();
if (entityRoles == null || entityRoles.isEmpty()) {
log.trace("Filtering out entity descriptor {} from entity group {}", entityDescriptor
.getEntityID(), descriptor.getName());
emptyEntityDescriptors.add(entityDescriptor);
}
}
}
entityDescriptors.removeAll(emptyEntityDescriptors);
}
// Next, contained EntityDescriptors
List<EntitiesDescriptor> entitiesDescriptors = descriptor.getEntitiesDescriptors();
if (entitiesDescriptors != null && !entitiesDescriptors.isEmpty()) {
List<EntitiesDescriptor> emptyEntitiesDescriptors = new ArrayList<EntitiesDescriptor>();
Iterator<EntitiesDescriptor> entitiesDescriptorsItr = entitiesDescriptors.iterator();
EntitiesDescriptor entitiesDescriptor;
while (entitiesDescriptorsItr.hasNext()) {
entitiesDescriptor = entitiesDescriptorsItr.next();
filterEntitiesDescriptor(entitiesDescriptor);
if (getRemoveEmptyEntitiesDescriptors()) {
// Remove the EntitiesDescriptor if does not contain any EntitiesDescriptors or EntityDescriptors
if ((entitiesDescriptor.getEntityDescriptors() == null || entitiesDescriptor.getEntityDescriptors()
.isEmpty())
&& (entitiesDescriptor.getEntitiesDescriptors() == null || entitiesDescriptor
.getEntitiesDescriptors().isEmpty())) {
log.trace("Filtering out entity descriptor {} from entity group {}", entitiesDescriptor
.getName(), descriptor.getName());
emptyEntitiesDescriptors.add(entitiesDescriptor);
}
}
}
entitiesDescriptors.removeAll(emptyEntitiesDescriptors);
}
}
示例9: filterEntitiesDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Filters entities descriptor.
*
* @param descriptor entities descriptor to filter
*
* @throws FilterException thrown if an effective role name can not be determined
*/
protected void filterEntitiesDescriptor(EntitiesDescriptor descriptor) throws FilterException {
// First we filter out any contained EntityDescriptors
List<EntityDescriptor> entityDescriptors = descriptor.getEntityDescriptors();
if (entityDescriptors != null && !entityDescriptors.isEmpty()) {
Iterator<EntityDescriptor> entityDescriptorsItr = entityDescriptors.iterator();
EntityDescriptor entityDescriptor;
List<RoleDescriptor> entityRoles;
while (entityDescriptorsItr.hasNext()) {
entityDescriptor = entityDescriptorsItr.next();
filterEntityDescriptor(entityDescriptor);
if (getRemoveRolelessEntityDescriptors()) {
entityRoles = entityDescriptor.getRoleDescriptors();
if (entityRoles == null || entityRoles.isEmpty()) {
log.trace("Filtering out entity descriptor {} from entity group {}", entityDescriptor
.getEntityID(), descriptor.getName());
entityDescriptorsItr.remove();
}
}
}
}
// Next, contained EntityDescriptors
List<EntitiesDescriptor> entitiesDescriptors = descriptor.getEntitiesDescriptors();
if (entitiesDescriptors != null && !entitiesDescriptors.isEmpty()) {
Iterator<EntitiesDescriptor> entitiesDescriptorsItr = entitiesDescriptors.iterator();
EntitiesDescriptor entitiesDescriptor;
while (entitiesDescriptorsItr.hasNext()) {
entitiesDescriptor = entitiesDescriptorsItr.next();
filterEntitiesDescriptor(entitiesDescriptor);
if (getRemoveEmptyEntitiesDescriptors()) {
// Remove the EntitiesDescriptor if does not contain any EntitiesDescriptors or EntityDescriptors
if ((entitiesDescriptor.getEntityDescriptors() == null || entitiesDescriptor.getEntityDescriptors()
.isEmpty())
&& (entitiesDescriptor.getEntitiesDescriptors() == null || entitiesDescriptor
.getEntitiesDescriptors().isEmpty())) {
log.trace("Filtering out entity descriptor {} from entity group {}", entitiesDescriptor
.getName(), descriptor.getName());
entitiesDescriptorsItr.remove();
}
}
}
}
}