当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationType类代码示例

本文整理汇总了Java中com.gitblit.Constants.AuthenticationType的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationType类的具体用法?Java AuthenticationType怎么用?Java AuthenticationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationType类属于com.gitblit.Constants包,在下文中一共展示了AuthenticationType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loggedIn

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
private UserModel loggedIn(HttpServletRequest request, UserModel user, String credentials, AuthResult authentication) {
	if (authentication != null && !gerritSession.get().getUser().isIdentifiedUser()) {
		log.warn("Setting account after log-in for " + user.getName());
		// We just logged in via Gerrit. However, if somehow somewhere some code called getCurrentUser() on that WebSession object before,
		// the "current user object" remains stuck on the previous value. Happens for instance in WrappedSyndicationFilter after the 401
		// challenge. Frankly said, I don't know if that is a bug in Gerrit, or what's up. Methinks CacheBasedWebSession.login() should
		// (re-)set its private field "user" to null, so that the next call to getCurrentUser() re-computes the user object. We can get
		// around this by forcing the account id to the account we just authenticated. In this request, this user won't be able to do
		// Gerrit administration, but we're inside GitBlit anyway, so there's no need for this anyway.
		gerritSession.get().setUserAccountId(authentication.getAccountId());
	}
	if (request != null) {
		request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS);
	}
	user.cookie = StringUtils.getSHA1(user.getName() + credentials); // Code from GitBlit
	return user;
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:18,代码来源:GerritGitBlitAuthenticationManager.java

示例2: loginUser

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
private void loginUser(UserModel user) {
	if (user != null) {
		HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
		HttpServletResponse response = ((WebResponse) getResponse()).getHttpServletResponse();

		// Set the user into the session
		GitBlitWebSession session = GitBlitWebSession.get();

		// issue 62: fix session fixation vulnerability
		session.replaceSession();
		session.setUser(user);

		request = ((WebRequest) getRequest()).getHttpServletRequest();
		response = ((WebResponse) getResponse()).getHttpServletResponse();
		request.getSession().setAttribute(Constants.ATTRIB_AUTHTYPE, AuthenticationType.CREDENTIALS);

		// Set Cookie
		app().authentication().setCookie(request, response, user);

		if (!session.continueRequest()) {
			PageParameters params = getPageParameters();
			if (params == null) {
				// redirect to this page
				redirectTo(getClass());
			} else {
				// Strip username and password and redirect to this page
				params.remove("username");
				params.remove("password");
				redirectTo(getClass(), params);
			}
		}
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:34,代码来源:RootPage.java

示例3: isStandardLogin

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
private boolean isStandardLogin(HttpServletRequest request) {
	if (request == null) {
		log.warn("(Internal) Deprecated cookie method called.");
		return false;
	}
	HttpSession session = request.getSession();
	AuthenticationType authenticationType = (AuthenticationType) session.getAttribute(Constants.ATTRIB_AUTHTYPE);
	return authenticationType != null && authenticationType.isStandard();
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:10,代码来源:GerritGitBlitAuthenticationManager.java

示例4: flagWicketSession

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
protected void flagWicketSession(AuthenticationType authenticationType) {
	RequestCycle requestCycle = RequestCycle.get();
	if (requestCycle != null) {
		// flag the Wicket session, if this is a Wicket request
		GitBlitWebSession session = GitBlitWebSession.get();
		session.authenticationType = authenticationType;
	}
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:9,代码来源:GitBlit.java

示例5: onInitialize

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
@Override
protected void onInitialize() {
	super.onInitialize();

	GitBlitWebSession session = GitBlitWebSession.get();
	UserModel user = session.getUser();
	boolean editCredentials = app().authentication().supportsCredentialChanges(user);
	HttpServletRequest request = ((WebRequest) getRequest()).getHttpServletRequest();
	AuthenticationType authenticationType = (AuthenticationType) request.getSession().getAttribute(Constants.ATTRIB_AUTHTYPE);
	boolean standardLogin = (null != authenticationType) ? authenticationType.isStandard() : true;

	if (app().settings().getBoolean(Keys.web.allowGravatar, true)) {
		add(new AvatarImage("username", user, "navbarGravatar", 20, false));
	} else {
		add(new Label("username", user.getDisplayName()));
	}

	List<MenuItem> standardItems = new ArrayList<MenuItem>();
	standardItems.add(new MenuDivider());
	if (user.canAdmin() || user.canCreate()) {
		standardItems.add(new PageLinkMenuItem("gb.newRepository", app().getNewRepositoryPage()));
	}
	standardItems.add(new PageLinkMenuItem("gb.myProfile", UserPage.class, WicketUtils.newUsernameParameter(user.username)));
	if (editCredentials) {
		standardItems.add(new PageLinkMenuItem("gb.changePassword", ChangePasswordPage.class));
	}
	standardItems.add(new MenuDivider());
	add(newSubmenu("standardMenu", user.getDisplayName(), standardItems));

	if (showAdmin) {
		// admin menu
		List<MenuItem> adminItems = new ArrayList<MenuItem>();
		adminItems.add(new MenuDivider());
		adminItems.add(new PageLinkMenuItem("gb.users", UsersPage.class));
		adminItems.add(new PageLinkMenuItem("gb.teams", TeamsPage.class));

		boolean showRegistrations = app().federation().canFederate()
				&& app().settings().getBoolean(Keys.web.showFederationRegistrations, false);
		if (showRegistrations) {
			adminItems.add(new PageLinkMenuItem("gb.federation", FederationPage.class));
		}
		adminItems.add(new MenuDivider());

		add(newSubmenu("adminMenu", getString("gb.administration"), adminItems));
	} else {
		add(new Label("adminMenu").setVisible(false));
	}

	// plugin extension items
	List<MenuItem> extensionItems = new ArrayList<MenuItem>();
	List<UserMenuExtension> extensions = app().plugins().getExtensions(UserMenuExtension.class);
	for (UserMenuExtension ext : extensions) {
		List<MenuItem> items = ext.getMenuItems(user);
		extensionItems.addAll(items);
	}

	if (extensionItems.isEmpty()) {
		// no extension items
		add(new Label("extensionsMenu").setVisible(false));
	} else {
		// found extension items
		extensionItems.add(0, new MenuDivider());
		add(newSubmenu("extensionsMenu", getString("gb.extensions"), extensionItems));
		extensionItems.add(new MenuDivider());
	}

	add(new BookmarkablePageLink<Void>("logout", LogoutPage.class).setVisible(standardLogin));
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:69,代码来源:RootPage.java

示例6: GitBlitWebSession

import com.gitblit.Constants.AuthenticationType; //导入依赖的package包/类
public GitBlitWebSession(Request request) {
	super(request);
	isForking = new AtomicBoolean();
	authenticationType = AuthenticationType.CREDENTIALS;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:6,代码来源:GitBlitWebSession.java


注:本文中的com.gitblit.Constants.AuthenticationType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。