本文整理汇总了Java中org.openid4java.message.sreg.SRegRequest类的典型用法代码示例。如果您正苦于以下问题:Java SRegRequest类的具体用法?Java SRegRequest怎么用?Java SRegRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SRegRequest类属于org.openid4java.message.sreg包,在下文中一共展示了SRegRequest类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addSReg
import org.openid4java.message.sreg.SRegRequest; //导入依赖的package包/类
/**
* Add Simple Register extension message to the response message.
*
* @param response
* the response message to add to
* @param persona
* the persona
* @throws MessageException
* if add extension failed
*/
private void addSReg(final Message response, final Persona persona)
throws MessageException {
if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG)) {
MessageExtension ext = authRequest
.getExtension(SRegMessage.OPENID_NS_SREG);
if (ext instanceof SRegRequest) {
SRegRequest sregReq = (SRegRequest) ext;
// data released by the user
if (persona != null) {
Map<String, String> userDataSReg = persona.toAliasValueMap();
SRegResponse sregResp = SRegResponse.createSRegResponse(
sregReq, userDataSReg);
// (alternatively) manually add attribute values
// sregResp.addAttribute("email", email);
response.addExtension(sregResp);
}
} else {
throw new UnsupportedOperationException(ext.getClass()
+ " is unsupported.");
}
}
}
开发者ID:sutra,项目名称:openid-server,代码行数:34,代码来源:ApprovingRequestProcessor.java
示例2: addSimpleRegistrationToAuthRequest
import org.openid4java.message.sreg.SRegRequest; //导入依赖的package包/类
/**
* Simple Registration Extension example.
*
* @param httpReq
* @param authReq
* @throws MessageException
* @see <a href="http://code.google.com/p/openid4java/wiki/SRegHowTo">Simple Registration HowTo</a>
* @see <a href="http://openid.net/specs/openid-simple-registration-extension-1_0.html">OpenID Simple Registration Extension 1.0</a>
*/
private void addSimpleRegistrationToAuthRequest(HttpServletRequest httpReq,
AuthRequest authReq) throws MessageException {
// Attribute Exchange example: fetching the 'email' attribute
// FetchRequest fetch = FetchRequest.createFetchRequest();
SRegRequest sregReq = SRegRequest.createFetchRequest();
String[] attributes = { "nickname", "email", "fullname", "dob",
"gender", "postcode", "country", "language", "timezone" };
for (int i = 0, l = attributes.length; i < l; i++) {
String attribute = attributes[i];
String value = httpReq.getParameter(attribute);
if (OPTIONAL_VALUE.equals(value)) {
sregReq.addAttribute(attribute, false);
} else if (REQUIRED_VALUE.equals(value)) {
sregReq.addAttribute(attribute, true);
}
}
// attach the extension to the authentication request
if (!sregReq.getAttributes().isEmpty()) {
authReq.addExtension(sregReq);
}
}
开发者ID:jbufu,项目名称:openid4java,代码行数:33,代码来源:ConsumerServlet.java
示例3: processSRegExtension
import org.openid4java.message.sreg.SRegRequest; //导入依赖的package包/类
private Message processSRegExtension(Message token, final AuthRequest authRequest) throws MessageException {
String sregNamespace = detectSRegVersion(authRequest);
if (sregNamespace != null) {
MessageExtension ext = authRequest.getExtension(sregNamespace);
if (ext instanceof SRegRequest) {
SRegRequest sregReq = (SRegRequest) ext;
SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, getValidUser().getUserDataMap());
token.addExtension(sregResp, "sreg");
} else if (ext instanceof SRegResponse) {
// what to do here?
} else {
final String message = String.format("TODO - Support of '%s'", ext.getClass().getCanonicalName());
throw new UnsupportedOperationException(message);
}
}
return token;
}
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:18,代码来源:CustomOpenIdProcessor.java
示例4: authorizationRequest
import org.openid4java.message.sreg.SRegRequest; //导入依赖的package包/类
/**
* Send authorization request to OpenID server
* @param userSuppliedString - OpenID username/login
* @param req - current request object
* @param res - current response object
* @return - true if sent, false if error
* @throws IOException - other problem
*/
public boolean authorizationRequest(String userSuppliedString, HttpServletRequest req, HttpServletResponse res) throws IOException {
try {
List discoveries = manager.discover(userSuppliedString);
DiscoveryInformation discovered = manager.associate(discoveries);
req.getSession().setAttribute("openid-disc", discovered);
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
SRegRequest sregReq = SRegRequest.createFetchRequest();
sregReq.addAttribute("email", true);
sregReq.addAttribute("fullname", true);
authReq.addExtension(sregReq);
res.sendRedirect(authReq.getDestinationUrl(true));
return true;
} catch (OpenIDException ex) {
// logger.error("Exception in authRequest with '" + userSuppliedString + "'", ex);
}
return false;
}
开发者ID:faramir,项目名称:ZawodyWeb,代码行数:33,代码来源:OpenIdConsumer.java
示例5: authRequest
import org.openid4java.message.sreg.SRegRequest; //导入依赖的package包/类
public String authRequest(String userSuppliedString,
HttpServletRequest httpReq,
HttpServletResponse httpResp)
throws IOException
{
try
{
// --- Forward proxy setup (only if needed) ---
// ProxyProperties proxyProps = new ProxyProperties();
// proxyProps.setProxyName("proxy.example.com");
// proxyProps.setProxyPort(8080);
// HttpClientFactory.setProxyProperties(proxyProps);
// perform discovery on the user-supplied identifier
List discoveries = manager.discover(userSuppliedString);
// attempt to associate with the OpenID provider
// and retrieve one service endpoint for authentication
DiscoveryInformation discovered = manager.associate(discoveries);
// store the discovery information in the user's session
httpReq.getSession().setAttribute("openid-disc", discovered);
// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
// Attribute Exchange example: fetching the 'email' attribute
FetchRequest fetch = FetchRequest.createFetchRequest();
fetch.addAttribute("email", // attribute alias
"http://schema.openid.net/contact/email", // type URI
true); // required
// attach the extension to the authentication request
authReq.addExtension(fetch);
// example using Simple Registration to fetching the 'email' attribute
SRegRequest sregReq = SRegRequest.createFetchRequest();
sregReq.addAttribute("email", true);
authReq.addExtension(sregReq);
if (! discovered.isVersion2() )
{
// Option 1: GET HTTP-redirect to the OpenID Provider endpoint
// The only method supported in OpenID 1.x
// redirect-URL usually limited ~2048 bytes
httpResp.sendRedirect(authReq.getDestinationUrl(true));
return null;
}
else
{
// Option 2: HTML FORM Redirection (Allows payloads >2048 bytes)
//RequestDispatcher dispatcher =
// getServletContext().getRequestDispatcher("formredirection.jsp");
//httpReq.setAttribute("prameterMap", response.getParameterMap());
//httpReq.setAttribute("destinationUrl", response.getDestinationUrl(false));
//dispatcher.forward(request, response);
}
}
catch (OpenIDException e)
{
// present error to the user
throw new RuntimeException("wrap:" + e.getMessage(), e);
}
return null;
}
开发者ID:jbufu,项目名称:openid4java,代码行数:68,代码来源:SampleConsumer.java
注:本文中的org.openid4java.message.sreg.SRegRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论