List of usage examples for org.springframework.security.openid OpenIDAttribute setRequired
public void setRequired(boolean required)
From source file:com.erudika.para.security.SimpleAxFetchListFactory.java
/** * A list of OpenID attributes to send in a request. * @param identifier a user identifier/*from w ww . ja va 2 s . com*/ * @return a list of attributes */ public List<OpenIDAttribute> createAttributeList(String identifier) { List<OpenIDAttribute> list = new ArrayList<OpenIDAttribute>(); if (identifier != null && identifier.matches("https://www.google.com/.*")) { OpenIDAttribute email = new OpenIDAttribute("email", "http://axschema.org/contact/email"); OpenIDAttribute first = new OpenIDAttribute("firstname", "http://axschema.org/namePerson/first"); OpenIDAttribute last = new OpenIDAttribute("lastname", "http://axschema.org/namePerson/last"); email.setCount(1); email.setRequired(true); first.setRequired(true); last.setRequired(true); list.add(email); list.add(first); list.add(last); } return list; }
From source file:org.mitre.provenance.openid.OpenId4JavaProxyConsumer.java
List<OpenIDAttribute> fetchAxAttributes(Message authSuccess, List<OpenIDAttribute> attributesToFetch)
throws OpenIDConsumerException {
if (attributesToFetch == null || !authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
return Collections.emptyList();
}//from www. ja va 2s .co m
logger.debug("Extracting attributes retrieved by attribute exchange");
List<OpenIDAttribute> attributes = Collections.emptyList();
try {
MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
if (ext instanceof FetchResponse) {
FetchResponse fetchResp = (FetchResponse) ext;
attributes = new ArrayList<OpenIDAttribute>(attributesToFetch.size());
for (OpenIDAttribute attr : attributesToFetch) {
List<String> values = fetchResp.getAttributeValues(attr.getName());
if (!values.isEmpty()) {
OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(), attr.getType(), values);
fetched.setRequired(attr.isRequired());
attributes.add(fetched);
}
}
}
} catch (MessageException e) {
throw new OpenIDConsumerException("Attribute retrieval failed", e);
}
if (logger.isDebugEnabled()) {
logger.debug("Retrieved attributes" + attributes);
}
return attributes;
}
From source file:org.springframework.security.openid.OpenID4JavaConsumer.java
List<OpenIDAttribute> fetchAxAttributes(Message authSuccess, List<OpenIDAttribute> attributesToFetch)
throws OpenIDConsumerException {
if (attributesToFetch == null || !authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
return Collections.emptyList();
}//from ww w . j a v a 2 s. c o m
logger.debug("Extracting attributes retrieved by attribute exchange");
List<OpenIDAttribute> attributes = Collections.emptyList();
try {
MessageExtension ext = authSuccess.getExtension(AxMessage.OPENID_NS_AX);
if (ext instanceof FetchResponse) {
FetchResponse fetchResp = (FetchResponse) ext;
attributes = new ArrayList<>(attributesToFetch.size());
for (OpenIDAttribute attr : attributesToFetch) {
List<String> values = fetchResp.getAttributeValues(attr.getName());
if (!values.isEmpty()) {
OpenIDAttribute fetched = new OpenIDAttribute(attr.getName(), attr.getType(), values);
fetched.setRequired(attr.isRequired());
attributes.add(fetched);
}
}
}
} catch (MessageException e) {
throw new OpenIDConsumerException("Attribute retrieval failed", e);
}
if (logger.isDebugEnabled()) {
logger.debug("Retrieved attributes" + attributes);
}
return attributes;
}