本文整理匯總了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;
}
示例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);
}
}
}
}
示例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();
}
示例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;
}
}
示例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));
}
示例6: GitBlitWebSession
import com.gitblit.Constants.AuthenticationType; //導入依賴的package包/類
public GitBlitWebSession(Request request) {
super(request);
isForking = new AtomicBoolean();
authenticationType = AuthenticationType.CREDENTIALS;
}