/** * Gets all requested attributes (required and optional). * * @return List of attribute names. */ public List getAttributes() { List attributes = getAttributes(true); attributes.addAll(getAttributes(false)); return attributes; }
/** * Constructs a SRegRequest from a parameter list. * <p> * The parameter list can be extracted from a received message with the * getExtensionParams method of the Message class, and MUST NOT contain * the "openid.<extension_alias>." prefix. */ public static SRegRequest createSRegRequest(ParameterList params) throws MessageException { SRegRequest req = new SRegRequest(params); if (! req.isValid()) throw new MessageException("Invalid parameters for a SReg request"); if (DEBUG) _log.debug("Created SReg request from parameter list:\n" + params); return req; }
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("email", true);
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("nickname", false); sregReq.addAttribute("email", false); sregReq.addAttribute("fullname", false); sregReq.addAttribute("dob", false); sregReq.addAttribute("gender", false); sregReq.addAttribute("postcode", false); sregReq.addAttribute("country", false); sregReq.addAttribute("language", false); sregReq.addAttribute("timezone", false); if (!sregReq.getAttributes().isEmpty()) { authReq.addExtension(sregReq);
/** * Instantiates the apropriate Simple Registration object * (request / response) for the supplied parameter list. * * @param parameterList The Simple Registration specific parameters * (without the openid.<ext_alias> prefix) * extracted from the openid message. * @param isRequest Indicates whether the parameters were * extracted from an OpenID request (true), * or from an OpenID response. * @return MessageExtension implementation for * the supplied extension parameters. * @throws MessageException If a Simple Registration object could not be * instantiated from the supplied parameter list. */ public MessageExtension getExtension( ParameterList parameterList, boolean isRequest) throws MessageException { if ( parameterList.hasParameter("required") || parameterList.hasParameter("optional")) return SRegRequest.createSRegRequest(parameterList); else return SRegResponse.createSRegResponse(parameterList); } }
/** * Constructs a SReg Request with an empty parameter list. */ public static SRegRequest createFetchRequest() { return new SRegRequest(); }
/** * Returns a map with the requested attributes. * * @param required If set to true the list of 'required' attributes * is returned, otherwise the list of 'optional' * attributes. * @return List of attribute names. */ public List getAttributes(boolean required) { List attributes = new ArrayList(); String level = required ? "required" : "optional"; Parameter param = _parameters.getParameter(level); if (param != null) { String[] values = param.getValue().split(","); for (int i = 0; i < values.length; i++) { String attr = multivalDecode(values[i]); attributes.add(attr); } } return attributes; }
/** * Adds an attribute to the SReg request. * * @param attr A requested attribute name. * @param required If true, marks the attribute as 'required'; * 'if_available' otherwise. */ public void addAttribute(String attr, boolean required) { String level = required ? "required" : "optional"; Parameter levelParam = _parameters.getParameter(level); Parameter newParam; if (levelParam == null) { newParam = new Parameter(level, multivalEncode(attr)); } else { newParam = new Parameter(level, levelParam.getValue() + "," + multivalEncode(attr)); _parameters.removeParameters(level); } _parameters.set(newParam); if (DEBUG) _log.debug("Added new attribute to SReg request: " + attr + " required: " + required); }
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("email", true); authReq.addExtension(sregReq);
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("nickname", false); sregReq.addAttribute("email", false); sregReq.addAttribute("fullname", false); sregReq.addAttribute("dob", false); sregReq.addAttribute("gender", false); sregReq.addAttribute("postcode", false); sregReq.addAttribute("country", false); sregReq.addAttribute("language", false); sregReq.addAttribute("timezone", false); if (!sregReq.getAttributes().isEmpty()) { authReq.addExtension(sregReq);
/** * Instantiates the apropriate Simple Registration object * (request / response) for the supplied parameter list. * * @param parameterList The Simple Registration specific parameters * (without the openid.<ext_alias> prefix) * extracted from the openid message. * @param isRequest Indicates whether the parameters were * extracted from an OpenID request (true), * or from an OpenID response. * @return MessageExtension implementation for * the supplied extension parameters. * @throws MessageException If a Simple Registration object could not be * instantiated from the supplied parameter list. */ public MessageExtension getExtension( ParameterList parameterList, boolean isRequest) throws MessageException { if ( parameterList.hasParameter("required") || parameterList.hasParameter("optional")) return SRegRequest.createSRegRequest(parameterList); else return SRegResponse.createSRegResponse(parameterList); } }
/** * Constructs a SReg Request with an empty parameter list. */ public static SRegRequest createFetchRequest() { return new SRegRequest(); }
/** * Returns a map with the requested attributes. * * @param required If set to true the list of 'required' attributes * is returned, otherwise the list of 'optional' * attributes. * @return List of attribute names. */ public List getAttributes(boolean required) { List attributes = new ArrayList(); String level = required ? "required" : "optional"; Parameter param = _parameters.getParameter(level); if (param != null) { String[] values = param.getValue().split(","); for (int i = 0; i < values.length; i++) { String attr = multivalDecode(values[i]); attributes.add(attr); } } return attributes; }
/** * Adds an attribute to the SReg request. * * @param attr A requested attribute name. * @param required If true, marks the attribute as 'required'; * 'if_available' otherwise. */ public void addAttribute(String attr, boolean required) { String level = required ? "required" : "optional"; Parameter levelParam = _parameters.getParameter(level); Parameter newParam; if (levelParam == null) { newParam = new Parameter(level, multivalEncode(attr)); } else { newParam = new Parameter(level, levelParam.getValue() + "," + multivalEncode(attr)); _parameters.removeParameters(level); } _parameters.set(newParam); if (DEBUG) _log.debug("Added new attribute to SReg request: " + attr + " required: " + required); }
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("email", true); authReq.addExtension(sregReq);
SRegRequest sregReq = SRegRequest.createFetchRequest(); sregReq.addAttribute("nickname", false); sregReq.addAttribute("email", false); sregReq.addAttribute("fullname", false); sregReq.addAttribute("dob", false); sregReq.addAttribute("gender", false); sregReq.addAttribute("postcode", false); sregReq.addAttribute("country", false); sregReq.addAttribute("language", false); sregReq.addAttribute("timezone", false); if (!sregReq.getAttributes().isEmpty()) { authReq.addExtension(sregReq);
/** * Gets all requested attributes (required and optional). * * @return List of attribute names. */ public List getAttributes() { List attributes = getAttributes(true); attributes.addAll(getAttributes(false)); return attributes; }
/** * Constructs a SRegRequest from a parameter list. * <p> * The parameter list can be extracted from a received message with the * getExtensionParams method of the Message class, and MUST NOT contain * the "openid.<extension_alias>." prefix. */ public static SRegRequest createSRegRequest(ParameterList params) throws MessageException { SRegRequest req = new SRegRequest(params); if (! req.isValid()) throw new MessageException("Invalid parameters for a SReg request"); if (DEBUG) _log.debug("Created SReg request from parameter list:\n" + params); return req; }
/** * Instantiates the apropriate Simple Registration object * (request / response) for the supplied parameter list. * * @param parameterList The Simple Registration specific parameters * (without the openid.<ext_alias> prefix) * extracted from the openid message. * @param isRequest Indicates whether the parameters were * extracted from an OpenID request (true), * or from an OpenID response. * @return MessageExtension implementation for * the supplied extension parameters. * @throws MessageException If a Simple Registration object could not be * instantiated from the supplied parameter list. */ public MessageExtension getExtension( ParameterList parameterList, boolean isRequest) throws MessageException { if ( parameterList.hasParameter("required") || parameterList.hasParameter("optional")) return SRegRequest.createSRegRequest(parameterList); else return SRegResponse.createSRegResponse(parameterList); } }
/** * Constructs a SReg Request with an empty parameter list. */ public static SRegRequest createFetchRequest() { return new SRegRequest(); }