Example usage for org.springframework.security.openid OpenIDAttribute getCount

List of usage examples for org.springframework.security.openid OpenIDAttribute getCount

Introduction

In this page you can find the example usage for org.springframework.security.openid OpenIDAttribute getCount.

Prototype

public int getCount() 

Source Link

Document

The requested count for the attribute when it is used as part of an authentication request.

Usage

From source file:org.mitre.provenance.openid.OpenId4JavaProxyConsumer.java

public String beginConsumption(HttpServletRequest req, String identityUrl, String returnToUrl, String realm)
        throws OpenIDConsumerException {
    List<DiscoveryInformation> discoveries;

    try {//from www  .  j a v  a 2  s.  c o  m
        discoveries = consumerManager.discover(identityUrl);
    } catch (DiscoveryException e) {
        throw new OpenIDConsumerException("Error during discovery", e);
    }

    DiscoveryInformation information = consumerManager.associate(discoveries);
    req.getSession().setAttribute(DISCOVERY_INFO_KEY, information);

    AuthRequest authReq;

    try {
        authReq = consumerManager.authenticate(information, returnToUrl, realm);

        logger.debug("Looking up attribute fetch list for identifier: " + identityUrl);

        List<OpenIDAttribute> attributesToFetch = attributesToFetchFactory.createAttributeList(identityUrl);

        if (!attributesToFetch.isEmpty()) {
            req.getSession().setAttribute(ATTRIBUTE_LIST_KEY, attributesToFetch);
            FetchRequest fetchRequest = FetchRequest.createFetchRequest();
            for (OpenIDAttribute attr : attributesToFetch) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Adding attribute " + attr.getType() + " to fetch request");
                }
                fetchRequest.addAttribute(attr.getName(), attr.getType(), attr.isRequired(), attr.getCount());
            }
            authReq.addExtension(fetchRequest);
        }
    } catch (MessageException e) {
        throw new OpenIDConsumerException("Error processing ConsumerManager authentication", e);
    } catch (ConsumerException e) {
        throw new OpenIDConsumerException("Error processing ConsumerManager authentication", e);
    }

    return authReq.getDestinationUrl(true);
}