本文整理汇总了Java中org.openid4java.server.ServerManager类的典型用法代码示例。如果您正苦于以下问题:Java ServerManager类的具体用法?Java ServerManager怎么用?Java ServerManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerManager类属于org.openid4java.server包,在下文中一共展示了ServerManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssociation
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(this.parameterList,
serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException me) {
LOGGER.error("Message exception : {}", me.getMessage(), me);
}
return null;
}
示例2: setUp
import org.openid4java.server.ServerManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
request.addParameter("openid.identity", "http://openid.ja-sig.org/battags");
request.addParameter("openid.return_to", "http://www.ja-sig.org/?service=fa");
request.addParameter("openid.mode", "checkid_setup");
sharedAssociations = mock(ServerAssociationStore.class);
manager = new ServerManager();
manager.setOPEndpointUrl("https://localshot:8443/cas/login");
manager.setEnforceRpId(false);
manager.setSharedAssociations(sharedAssociations);
context = mock(ApplicationContext.class);
cas = mock(CentralAuthenticationService.class);
when(context.getBean("serverManager")).thenReturn(manager);
when(context.getBean("centralAuthenticationService", CentralAuthenticationService.class)).thenReturn(cas);
final ApplicationContextProvider contextProvider = new ApplicationContextProvider();
contextProvider.setApplicationContext(context);
}
示例3: getAssociation
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @param parameterList the parameter list
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager, final ParameterList parameterList) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(parameterList, serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException e) {
LOGGER.error("Message exception : [{}]", e.getMessage(), e);
}
return null;
}
示例4: getAssociation
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(this.parameterList,
serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException me) {
logger.error("Message exception : {}", me.getMessage(), me);
}
return null;
}
示例5: ApprovingRequestProcessor
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Construct a new {@link ApprovingRequestProcessor}.
*
* @param httpReq
* the http request
* @param httpResp
* the http response
* @param josService
* the jos service
* @param serverManager
* the serverManager
* @param checkIdRequest
* the approving request
*/
public ApprovingRequestProcessor(final HttpServletRequest httpReq,
final HttpServletResponse httpResp, final JosService josService,
final ServerManager serverManager,
final ApprovingRequest checkIdRequest) {
this.httpReq = httpReq;
this.httpResp = httpResp;
this.josService = josService;
this.serverManager = serverManager;
this.userSession = WebUtils.getOrCreateUserSession(this.httpReq
.getSession());
this.user = userSession.getUser();
this.checkIdRequest = checkIdRequest;
this.authRequest = checkIdRequest.getAuthRequest();
this.realm = this.authRequest.getRealm();
}
示例6: buildAuthenticationResponse
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* We sign directly (final 'true') because we don't add extensions
* response message can be either a DirectError or an AuthSuccess here.
*
* @param serverManager the server manager
* @param ticketId the ticket id
* @param service the service
* @param parameters the parameters
* @param associated the associated
* @param successFullAuthentication the success full authentication
* @param id the id
* @return response response
*/
protected Response buildAuthenticationResponse(final ServerManager serverManager,
final String ticketId, final OpenIdService service,
final Map<String, String> parameters,
final boolean associated, final boolean successFullAuthentication,
final String id) {
final Message response = serverManager.authResponse(this.parameterList, id, id,
successFullAuthentication, true);
parameters.putAll(response.getParameterMap());
if (!associated) {
parameters.put(OpenIdProtocolConstants.OPENID_ASSOCHANDLE, ticketId);
}
return buildRedirect(service, parameters);
}
示例7: setUp
import org.openid4java.server.ServerManager; //导入依赖的package包/类
@Before
public void setUp() {
manager = new ServerManager();
manager.setOPEndpointUrl("https://localshot:8443/cas/login");
manager.setEnforceRpId(false);
smartOpenIdController.setServerManager(manager);
}
示例8: OpenIdServiceResponseBuilder
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Instantiates a new Open id service response builder.
*
* @param openIdPrefixUrl the open id prefix url
* @param serverManager the server manager
* @param centralAuthenticationService the central authentication service
*/
public OpenIdServiceResponseBuilder(final String openIdPrefixUrl,
final ServerManager serverManager,
final CentralAuthenticationService centralAuthenticationService) {
this.openIdPrefixUrl = openIdPrefixUrl;
this.serverManager = serverManager;
this.centralAuthenticationService = centralAuthenticationService;
}
示例9: serverManager
import org.openid4java.server.ServerManager; //导入依赖的package包/类
@RefreshScope
@Bean
public ServerManager serverManager() {
final ServerManager manager = new ServerManager();
manager.setOPEndpointUrl(casProperties.getServer().getLoginUrl());
manager.setEnforceRpId(casProperties.getAuthn().getOpenid().isEnforceRpId());
manager.setSharedAssociations(new InMemoryServerAssociationStore());
LOGGER.info("Creating openid server manager with OP endpoint [{}]", casProperties.getServer().getLoginUrl());
return manager;
}
示例10: setUp
import org.openid4java.server.ServerManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
request.addParameter("openid.identity", "http://openid.ja-sig.org/battags");
request.addParameter("openid.return_to", "http://www.ja-sig.org/?service=fa");
request.addParameter("openid.mode", "checkid_setup");
sharedAssociations = mock(ServerAssociationStore.class);
manager = new ServerManager();
manager.setOPEndpointUrl("https://localshot:8443/cas/login");
manager.setEnforceRpId(false);
manager.setSharedAssociations(sharedAssociations);
context = mock(ApplicationContext.class);
ApplicationContextProvider contextProvider = new ApplicationContextProvider();
contextProvider.setApplicationContext(context);
cas = mock(CentralAuthenticationService.class);
}
示例11: init
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
context = config.getServletContext();
this.manager = new ServerManager();
manager.setOPEndpointUrl(OP_ENDPOINT_URL);
manager.getRealmVerifier().setEnforceRpId(false);
manager.setSharedAssociations(new InMemoryServerAssociationStore());
manager.setPrivateAssociations(new InMemoryServerAssociationStore());
}
示例12: onSubmit
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected ModelAndView onSubmit(final HttpServletRequest request,
final HttpServletResponse response, final Object command,
final BindException errors) throws Exception {
String token = (String) request.getAttribute("token");
UserSession userSession = getUserSession(request);
ApprovingRequest checkIdRequest = userSession
.getApprovingRequest(token);
if (checkIdRequest != null) {
Domain domain = this.getDomain(request);
ServerManager serverManager = this.getJosService()
.getServerManager(domain);
new ApprovingRequestProcessor(request, response, getJosService(),
serverManager, checkIdRequest).checkId();
}
CaptchaInterceptor.setHuman(request, false);
if (userSession.isLoggedIn()) {
request.setAttribute("topSites", this.getJosService().getTopSites(
this.getUser(request), 10));
request.setAttribute("latestSites", this.getJosService()
.getLatestSites(this.getUser(request), 10));
request.setAttribute("latestRealms", this.getJosService()
.getLatestRealms(10));
}
return super.onSubmit(request, response, command, errors);
}
示例13: getServerManager
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public ServerManager getServerManager(final Domain domain) {
ServerManager serverManager = this.serverManagers.get(domain);
if (serverManager == null) {
serverManager = newServerManager(domain);
}
return serverManager;
}
示例14: setServerManager
import org.openid4java.server.ServerManager; //导入依赖的package包/类
public void setServerManager(@NotNull final ServerManager serverManager) {
this.serverManager = serverManager;
}
示例15: build
import org.openid4java.server.ServerManager; //导入依赖的package包/类
/**
* Generates an Openid response.
* If no ticketId is found, response is negative.
* If we have a ticket id, then we check if we have an association.
* If so, we ask OpenId server manager to generate the answer according with the existing association.
* If not, we send back an answer with the ticket id as association handle.
* This will force the consumer to ask a verification, which will validate the service ticket.
*
* @param ticketId the service ticket to provide to the service.
* @param webApplicationService web application service
* @return the generated authentication answer
*/
@Override
public Response build(final WebApplicationService webApplicationService, final String ticketId) {
final ServerManager serverManager = ApplicationContextProvider.getApplicationContext()
.getBean("serverManager", ServerManager.class);
final CentralAuthenticationService centralAuthenticationService = ApplicationContextProvider
.getApplicationContext().getBean("centralAuthenticationService",
CentralAuthenticationService.class);
final OpenIdService service = (OpenIdService) webApplicationService;
final Map<String, String> parameters = new HashMap<>();
if (StringUtils.isBlank(ticketId)) {
parameters.put(OpenIdProtocolConstants.OPENID_MODE, OpenIdProtocolConstants.CANCEL);
return buildRedirect(service, parameters);
}
final Association association = getAssociation(serverManager);
final boolean associated = association != null;
final boolean associationValid = isAssociationValid(association);
boolean successFullAuthentication = true;
Assertion assertion = null;
try {
if (associated && associationValid) {
assertion = centralAuthenticationService.validateServiceTicket(ticketId, service);
LOGGER.debug("Validated openid ticket {} for {}", ticketId, service);
} else {
LOGGER.warn("Association does not exist or is not valid");
successFullAuthentication = false;
}
} catch (final AbstractTicketException te) {
LOGGER.error("Could not validate ticket : {}", te.getMessage(), te);
successFullAuthentication = false;
}
final String id = determineIdentity(service, assertion);
return buildAuthenticationResponse(serverManager, ticketId, service, parameters, associated,
successFullAuthentication, id);
}