本文整理匯總了Java中javax.security.auth.login.LoginException類的典型用法代碼示例。如果您正苦於以下問題:Java LoginException類的具體用法?Java LoginException怎麽用?Java LoginException使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。
LoginException類屬於javax.security.auth.login包,在下文中一共展示了LoginException類的38個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: map
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public Optional map(final Optional wrapper) {
try {
LOG.info("logging in user as {}", username);
LoginContext lc = new LoginContext("PropertyFile", callbacks -> {
LOG.info("Callback Handler invoked ");
Stream.of(callbacks).forEach(cb -> {
if (cb instanceof NameCallback) {
((NameCallback) cb).setName(username);
} else if (cb instanceof PasswordCallback) {
((PasswordCallback) cb).setPassword(password.toCharArray());
}
});
});
lc.login();
return Optional.of(lc.getSubject());
} catch (LoginException e) {
LOG.error("Authentication failed", e);
return Optional.empty();
}
}
開發者ID:gmuecke,項目名稱:boutique-de-jus,代碼行數:22,
示例2: login
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Performs a kerberos login, possibly logging out first.
*
* @param prevContext The LoginContext from the previous login, or null
* @param conf JAAS Configuration object
* @param subject The JAAS Subject
* @return The context and subject from the login
* @throws LoginException If the login failed.
*/
Entry login(LoginContext prevContext, Configuration conf,
Subject subject) throws LoginException {
// Is synchronized by the caller
// If a context was provided, perform a logout first
if (null != prevContext) {
prevContext.logout();
}
// Create a LoginContext given the Configuration and Subject
LoginContext loginContext = createLoginContext(conf);
// Invoke the login
loginContext.login();
// Get the Subject from the context and verify it's non-null (null would imply failure)
Subject loggedInSubject = loginContext.getSubject();
if (null == loggedInSubject) {
throw new RuntimeException("Failed to perform Kerberos login");
}
// Send it back to the caller to use with launchRenewalThread
return new AbstractMap.SimpleEntry<>(loginContext, loggedInSubject);
}
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:32,
示例3: SaslQuorumAuthLearner
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public SaslQuorumAuthLearner(boolean quorumRequireSasl,
String quorumServicePrincipal, String loginContext)
throws SaslException {
this.quorumRequireSasl = quorumRequireSasl;
this.quorumServicePrincipal = quorumServicePrincipal;
try {
AppConfigurationEntry entries[] = Configuration
.getConfiguration()
.getAppConfigurationEntry(loginContext);
if (entries == null || entries.length == 0) {
throw new LoginException("SASL-authentication failed because"
+ " the specified JAAS configuration "
+ "section '" + loginContext
+ "' could not be found.");
}
this.learnerLogin = new Login(loginContext,
new SaslClientCallbackHandler(null, "QuorumLearner"));
this.learnerLogin.startThreadIfNeeded();
} catch (LoginException e) {
throw new SaslException("Failed to initialize authentication mechanism using SASL", e);
}
}
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:23,
示例4: commit
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean commit() throws LoginException {
if (!succeeded) {
return false;
} else {
// add a Principal (authenticated identity) to the Subject
// assume the user we authenticated is the SamplePrincipal
userPrincipal = new SamplePrincipal(username);
if (!subject.getPrincipals().contains(userPrincipal)) {
subject.getPrincipals().add(userPrincipal);
}
// in any case, clean out state
username = null;
password = null;
commitSucceeded = true;
return true;
}
}
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,
示例5: getTicket
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Retrieves the ticket corresponding to the client/server principal
* pair from the Subject in the specified AccessControlContext.
* If the ticket can not be found in the Subject, and if
* useSubjectCredsOnly is false, then obtain ticket from
* a LoginContext.
*/
static KerberosTicket getTicket(GSSCaller caller,
String clientPrincipal, String serverPrincipal,
AccessControlContext acc) throws LoginException {
// Try to get ticket from acc's Subject
Subject accSubj = Subject.getSubject(acc);
KerberosTicket ticket =
SubjectComber.find(accSubj, serverPrincipal, clientPrincipal,
KerberosTicket.class);
// Try to get ticket from Subject obtained from GSSUtil
if (ticket == null && !GSSUtil.useSubjectCredsOnly(caller)) {
Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
ticket = SubjectComber.find(subject,
serverPrincipal, clientPrincipal, KerberosTicket.class);
}
return ticket;
}
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,
示例6: initialize_SSOAutoLogin_Exception
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Test
public void initialize_SSOAutoLogin_Exception() throws Exception {
// given
voUser.setStatus(UserAccountStatus.LOCKED_NOT_CONFIRMED);
String encodedString = ParameterEncoder.encodeParameters(new String[] {
userId, orgId, "MPID", String.valueOf(serviceKey) });
confirmationBean.setEncodedParam(encodedString);
doReturn(Boolean.TRUE).when(confirmationBean).isServiceProvider();
doThrow(new LoginException("")).when(confirmationBean).loginUser(
eq(voUser), anyString(), eq(request), eq(session));
// when
confirmationBean.initialize();
// then
assertEquals(serviceKey, sessionBean.getSubscribeToServiceKey());
verify(confirmationBean, times(1)).addMessage(anyString(),
eq(FacesMessage.SEVERITY_ERROR),
eq(BaseBean.ERROR_USER_CONFIRMED_LOGIN_FAIL));
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:21,
示例7: login
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean login() throws LoginException {
final Callback[] callbacks = new Callback[] {new NameCallback("f"), new PasswordCallback("f", false)};
try {
this.callbackHandler.handle(callbacks);
} catch (final Exception e) {
throw new LoginException();
}
final String userName = ((NameCallback) callbacks[0]).getName();
final String password = new String(((PasswordCallback) callbacks[1]).getPassword());
if ("test".equals(userName) && "test".equals(password)) {
return true;
}
throw new LoginException();
}
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:19,
示例8: testLogin
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public static void testLogin(String confName, char[] passwd,
Configuration cf, boolean expectException) {
try {
CallbackHandler ch = new MyCallbackHandler("testUser", passwd);
LoginContext lc = new LoginContext(confName, new Subject(),
ch, cf);
lc.login();
if (expectException) {
throw new RuntimeException("Login Test failed: "
+ "expected LoginException not thrown");
}
} catch (LoginException le) {
if (!expectException) {
System.out.println("Login Test failed: "
+ "received Unexpected exception.");
throw new RuntimeException(le);
}
}
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,
示例9: loginUser_UserLocked_BluePortal
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Test
public void loginUser_UserLocked_BluePortal() throws Exception {
// given
VOUser voUser = createVoUser("userId", UserAccountStatus.LOCKED);
doReturn(voUser).when(identityServiceMock).getUser(any(VOUser.class));
createSessionMock(serviceAccessMock, "/oscm-portal/", false);
doReturn("").when(authReqDataMock).getMarketplaceId();
doThrow(new LoginException()).when(serviceAccessMock).login(
any(VOUser.class), anyString(), any(HttpServletRequest.class),
any(HttpServletResponse.class));
// when
boolean result = authFilter
.loginUser(chainMock, requestMock, responseMock, userDetails,
authReqDataMock, identityServiceMock);
// then
assertFalse("Forward must be performed", result);
verify(requestMock, times(1)).setAttribute(
Constants.REQ_ATTR_ERROR_KEY, BaseBean.ERROR_USER_LOCKED);
verify(authFilter, times(1)).forward(BaseBean.ERROR_PAGE, requestMock,
responseMock);
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:26,
示例10: login_UserLocked_SAMLSP
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Test
public void login_UserLocked_SAMLSP() throws Exception {
VOUser voUser = createVoUser("userId", UserAccountStatus.LOCKED);
doReturn("userId").when(requestMock).getParameter(
eq(UserBean.SAMPSP_FORM + Constants.REQ_PARAM_USER_ID));
doReturn(Boolean.TRUE).when(userBean).isServiceProvider();
doReturn(voUser).when(idServiceMock).getUser(any(VOUser.class));
doThrow(new LoginException()).when(serviceAccessMock).login(eq(voUser),
anyString(), any(HttpServletRequest.class),
any(HttpServletResponse.class));
doReturn(BaseBean.SAML_SP_LOGIN_AUTOSUBMIT_PAGE).when(requestMock)
.getServletPath();
// when
String result = userBean.login();
// then
verify(requestMock, times(1)).setAttribute(
eq(Constants.REQ_ATTR_ERROR_KEY),
eq(BaseBean.ERROR_USER_LOCKED));
assertEquals(BaseBean.OUTCOME_MARKETPLACE_ERROR_PAGE, result);
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:21,
示例11: doPost
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final String username = request.getParameter("username");
final String password = request.getParameter("password");
HttpSession session = request.getSession(false);
if (session != null) {
session.removeAttribute("user");
}
// Do your crazy complex login procedure here
if (username.equalsIgnoreCase("test") && password.equalsIgnoreCase("test")) {
request.getSession().setAttribute("user", new MyCustomPrincipal(username, Arrays.asList("manager", "admin")));
System.out.println("Principal is: " + request.getSession(false).getAttribute("user"));
} else {
// what should happen when login fails
try {
throw new LoginException("You're not test=test user !");
} catch (LoginException e) {
e.printStackTrace();
}
}
response.sendRedirect(request.getContextPath() + "/");
}
開發者ID:nickscha,項目名稱:servlet-auth,代碼行數:26,
示例12: login
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean login() throws LoginException {
LCTest.logAction("login");
if (callbackHandler == null) {
throw new LoginException("No CallbackHandler available");
}
Callback[] callbacks = new Callback[2];
callbacks[0] = new NameCallback("Username: ");
callbacks[1] = new PasswordCallback("Password: ", false);
try {
callbackHandler.handle(callbacks);
username = ((NameCallback) callbacks[0]).getName();
password = new String(((PasswordCallback) callbacks[1])
.getPassword());
if (username.equals(LCTest.USER_NAME) &&
password.equals(LCTest.PASSWORD)) {
succeeded = true;
return true;
}
throw new FailedLoginException("Incorrect username/password!");
} catch (IOException | UnsupportedCallbackException e) {
throw new LoginException("Login failed: " + e.getMessage());
}
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,
示例13: logout
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Logout a user.
*
*
This method removes the Principals, public credentials and the
* private credentials that were added by the commit
method.
*
*
If the loaded KeyStore's provider extends
* java.security.AuthProvider
,
* then the provider's logout
method is invoked.
*
*
*
* @exception LoginException if the logout fails.
*
* @return true in all cases since this LoginModule
* should not be ignored.
*/
public boolean logout() throws LoginException {
if (debug)
debugPrint("Entering logout " + status);
switch (status) {
case UNINITIALIZED:
throw new LoginException
("The login module is not initialized");
case INITIALIZED:
case AUTHENTICATED:
default:
// impossible for LoginModule to be in AUTHENTICATED
// state
// assert status != AUTHENTICATED;
return false;
case LOGGED_IN:
logoutInternal();
return true;
}
}
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:38,
示例14: testConfigName
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public static void testConfigName(String confName,
boolean expectException) {
String expectedMsg = "No LoginModules configured for " + confName;
try {
LoginContext lc = new LoginContext(confName, new Subject(),
new MyCallbackHandler(), new MyConfiguration());
if (expectException) {
throw new RuntimeException("Wrong Config Name Test failed: "
+ "expected LoginException not thrown.");
}
} catch (LoginException le) {
if (!expectException || !le.getMessage().equals(expectedMsg)) {
System.out.println("Wrong Config Name Test failed: "
+ "received Unexpected exception.");
throw new RuntimeException(le);
}
}
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,
示例15: login
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public void login(String token, ShardInfo shardInfo, SessionReconnectQueue reconnectQueue) throws LoginException, RateLimitedException {
setStatus(Status.LOGGING_IN);
if(token == null || token.isEmpty()) throw new LoginException("Provided token was null or empty!");
setToken(token);
verifyToken();
this.shardInfo = shardInfo;
JDAImpl.LOG.info("Login Successful!");
client = new ClientWebSocketClient(this, reconnectQueue, gatewayClient);
client.send(new JSONObject()
.put("d", presence.getFullPresence())
.put("op", WebSocketCode.PRESENCE).toString());
if(shutdownHook != null) {
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
}
開發者ID:natanbc,項目名稱:discord-bot-gateway,代碼行數:20,
示例16: getServiceCreds
點讚 3
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Retrieves the ServiceCreds for the specified server principal from
* the Subject in the specified AccessControlContext. If not found, and if
* useSubjectCredsOnly is false, then obtain from a LoginContext.
*
* NOTE: This method is also used by JSSE Kerberos Cipher Suites
*/
public static ServiceCreds getServiceCreds(GSSCaller caller,
String serverPrincipal, AccessControlContext acc)
throws LoginException {
Subject accSubj = Subject.getSubject(acc);
ServiceCreds sc = null;
if (accSubj != null) {
sc = ServiceCreds.getInstance(accSubj, serverPrincipal);
}
if (sc == null && !GSSUtil.useSubjectCredsOnly(caller)) {
Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
sc = ServiceCreds.getInstance(subject, serverPrincipal);
}
return sc;
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,
示例17: login
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean login() throws LoginException {
if (debug) {
logger.debug(this.getClass().getName() + " login called.");
}
if (Constants.FEDORA_HOME == null || "".equals(Constants.FEDORA_HOME.trim())) {
logger.error("FEDORA_HOME constant is not set");
return false;
}
final NameCallback nc = new NameCallback("username");
final PasswordCallback pc = new PasswordCallback("password", false);
final Callback[] callbacks = new Callback[] {
nc, pc
};
try {
handler.handle(callbacks);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new LoginException("IOException occured: " + ioe.getMessage());
} catch (UnsupportedCallbackException ucbe) {
ucbe.printStackTrace();
throw new LoginException("UnsupportedCallbackException encountered: "
+ ucbe.getMessage());
}
// Grab the username and password from the callbacks.
final String username = nc.getName();
final String password = new String(pc.getPassword());
successLogin = authenticate(username, password);
return successLogin;
}
開發者ID:discoverygarden,項目名稱:fcrepo3-security-jaas,代碼行數:37,
示例18: clusterSetupAtBegining
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@BeforeClass
public static void clusterSetupAtBegining() throws IOException,
LoginException, URISyntaxException {
SupportsBlocks = true;
CONF.setBoolean(
DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true);
cluster = new MiniDFSCluster.Builder(CONF).numDataNodes(2).build();
cluster.waitClusterUp();
fc = FileContext.getFileContext(cluster.getURI(0), CONF);
Path defaultWorkingDirectory = fc.makeQualified( new Path("/user/" +
UserGroupInformation.getCurrentUser().getShortUserName()));
fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true);
}
開發者ID:naver,項目名稱:hadoop,代碼行數:15,
示例19: handleWebServiceCaller_positive
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Test
public void handleWebServiceCaller_positive() throws LoginException {
// given
long wsPasswordAge = System.currentTimeMillis() - 1;
String wsPassword = "WS" + wsPasswordAge;
// then
realm.handleWebServiceCaller(ANY_KEY, wsPassword);
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:11,
示例20: testParseTwo
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public void testParseTwo() throws LoginException {
assertTrue(module.authenticate("fedoraIntCallUser", "test_changeme"));
final Map> attributes = module.attributes;
assertTrue(attributes.containsKey("fedoraRole"));
final Set roles = attributes.get("fedoraRole");
assertTrue(roles.contains("fedoraInternalCall-1"));
assertTrue(roles.contains("fedoraInternalCall-2"));
assertFalse(roles.contains("administrator"));
assertFalse(attributes.containsKey("custom_one"));
}
開發者ID:discoverygarden,項目名稱:fcrepo3-security-jaas,代碼行數:14,
示例21: handleError
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Handle an account state error produced by ldaptive account state machinery.
*
* Override this method to provide custom error handling.
*
* @param error Account state error.
* @param response Ldaptive authentication response.
* @param configuration Password policy configuration.
* @param messages Container for messages produced by account state error handling.
*
* @throws LoginException On errors that should be communicated as login exceptions.
*/
protected void handleError(
final AccountState.Error error,
final AuthenticationResponse response,
final LdapPasswordPolicyConfiguration configuration,
final List messages)
throws LoginException {
logger.debug("Handling error {}", error);
final LoginException ex = this.errorMap.get(error);
if (ex != null) {
throw ex;
}
logger.debug("No LDAP error mapping defined for {}", error);
}
開發者ID:yuweijun,項目名稱:cas-server-4.2.1,代碼行數:27,
示例22: startServerWithJaas
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
static void startServerWithJaas(final SSLEchoServer server,
String config) throws LoginException, PrivilegedActionException {
LoginContext context = new LoginContext(config);
context.login();
System.out.println("Server: successful authentication");
Subject.doAs(context.getSubject(),
(PrivilegedExceptionAction) () -> {
SSLEchoServer.startServer(server);
return null;
});
}
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,
示例23: login
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Perform the authentication of the username and password.
*/
@Override
public boolean login() throws LoginException {
loginOK = false;
String[] info = getUsernameAndPassword();
String userName = info[0];
String password = info[1];
UniversalLoginModule.log.info("Authenticate user: " + userName);
if (identity == null) {
try {
identity = new SimplePrincipal(userName);
} catch (Exception e) {
throw new LoginException("Failed to create principal: " + e.getMessage());
}
if (!validatePassword(password)) {
if (UniversalLoginModule.log.isDebugEnabled()) {
UniversalLoginModule.log.debug("Bad password for user: " + userName);
}
throw new FailedLoginException("Incorrect password");
}
}
loginOK = true;
if (UniversalLoginModule.log.isDebugEnabled()) {
UniversalLoginModule.log.debug("User authenticated: " + identity);
}
return true;
}
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,
示例24: createPrincipal
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Creates a CAS principal with attributes if the LDAP entry contains principal attributes.
*
* @param username Username that was successfully authenticated which is used for principal ID when
* {@link #setPrincipalIdAttribute(String)} is not specified.
* @param ldapEntry LDAP entry that may contain principal attributes.
*
* @return Principal if the LDAP entry contains at least a principal ID attribute value, null otherwise.
*
* @throws LoginException On security policy errors related to principal creation.
*/
protected Principal createPrincipal(final String username, final LdapEntry ldapEntry) throws LoginException {
final String id;
if (this.principalIdAttribute != null) {
final LdapAttribute principalAttr = ldapEntry.getAttribute(this.principalIdAttribute);
if (principalAttr == null || principalAttr.size() == 0) {
throw new LoginException(this.principalIdAttribute + " attribute not found for " + username);
}
if (principalAttr.size() > 1) {
if (this.allowMultiplePrincipalAttributeValues) {
logger.warn(
"Found multiple values for principal ID attribute: {}. Using first value={}.",
principalAttr,
principalAttr.getStringValue());
} else {
throw new LoginException("Multiple principal values not allowed: " + principalAttr);
}
}
id = principalAttr.getStringValue();
} else {
id = username;
}
final Map attributeMap = new LinkedHashMap<>(this.principalAttributeMap.size());
for (final Map.Entry ldapAttr : this.principalAttributeMap.entrySet()) {
final LdapAttribute attr = ldapEntry.getAttribute(ldapAttr.getKey());
if (attr != null) {
logger.debug("Found principal attribute: {}", attr);
final String principalAttrName = ldapAttr.getValue();
if (attr.size() > 1) {
attributeMap.put(principalAttrName, attr.getStringValues());
} else {
attributeMap.put(principalAttrName, attr.getStringValue());
}
}
}
return this.principalFactory.createPrincipal(id, attributeMap);
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:48,
示例25: getLdapPrincipalIdentifier
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Gets ldap principal identifier. If the principal id attribute is defined, it's retrieved.
* If no attribute value is found, a warning is generated and the provided username is used instead.
* If no attribute is defined, username is used instead.
*
* @param username the username
* @param ldapEntry the ldap entry
* @return the ldap principal identifier
* @throws LoginException in case the principal id cannot be determined.
*/
protected String getLdapPrincipalIdentifier(final String username, final LdapEntry ldapEntry) throws LoginException {
if (StringUtils.isNotBlank(this.principalIdAttribute)) {
final LdapAttribute principalAttr = ldapEntry.getAttribute(this.principalIdAttribute);
if (principalAttr == null || principalAttr.size() == 0) {
if (this.allowMissingPrincipalAttributeValue) {
LOGGER.warn("The principal id attribute [{}] is not found. CAS cannot construct the final authenticated principal "
+ "if it's unable to locate the attribute that is designated as the principal id. "
+ "Attributes available on the LDAP entry are [{}]. Since principal id attribute is not available, CAS will "
+ "fall back to construct the principal based on the provided user id: [{}]",
this.principalIdAttribute, ldapEntry.getAttributes(), username);
return username;
}
LOGGER.error("The principal id attribute [{}] is not found. CAS is configured to disallow missing principal attributes",
this.principalIdAttribute);
throw new LoginException("Principal id attribute is not found for " + principalAttr);
}
if (principalAttr.size() > 1) {
if (!this.allowMultiplePrincipalAttributeValues) {
throw new LoginException("Multiple principal values are not allowed: " + principalAttr);
}
LOGGER.warn("Found multiple values for principal id attribute: [{}]. Using first value=[{}].", principalAttr, principalAttr.getStringValue());
}
LOGGER.debug("Retrieved principal id attribute [{}]", principalAttr.getStringValue());
return principalAttr.getStringValue();
}
LOGGER.debug("Principal id attribute is not defined. Using the default provided user id [{}]", username);
return username;
}
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:42,
示例26: abort
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Abort authentication (when overall authentication fails)
*/
public boolean abort() throws LoginException {
if (!isAuthSucceeded()) {
return false;
} else {
if (isAuthSucceeded() && !isCommitSucceeded()) {
reset();
} else {
logout();
}
}
return true;
}
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,
示例27: onEnable
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public void onEnable(Phonon phononPlugin) {
if (phononPlugin.getConfigAdapter(CoreModule.ID, CoreConfigAdapter.class).isPresent()) {
CoreConfig config = phononPlugin.getConfigAdapter(CoreModule.ID, CoreConfigAdapter.class).get().getNodeOrDefault();
String token = config.getToken();
if (config.getPrefix().equals("/")) {
phononPlugin.getLogger().warn("Using '/' as a command prefix is highly discouraged.");
}
codes = new HashMap<>();
try {
if (config.getToken().isEmpty()) {
return;
}
jda = new JDABuilder(AccountType.BOT)
.setToken(token)
.setAudioEnabled(false)
.setAutoReconnect(true)
.setEnableShutdownHook(true)
.buildAsync();
if (!config.getGame().isEmpty()) {
jda.getPresence().setGame(Game.of(config.getGame()));
}
jda.addEventListener(new CommandListener(phononPlugin));
} catch (LoginException | RateLimitedException e) {
e.printStackTrace();
}
}
}
開發者ID:NucleusPowered,項目名稱:Phonon,代碼行數:29,
示例28: clusterSetupAtBegining
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@BeforeClass
public static void clusterSetupAtBegining() throws IOException,
LoginException, URISyntaxException {
SupportsBlocks = true;
CONF.setBoolean(
DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true);
cluster = new MiniDFSCluster.Builder(CONF)
.numDataNodes(2)
.build();
cluster.waitClusterUp();
fHdfs = cluster.getFileSystem();
}
開發者ID:naver,項目名稱:hadoop,代碼行數:15,
示例29: logout
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean logout() throws LoginException {
if (LOG.isDebugEnabled()) {
LOG.debug("hadoop logout");
}
return true;
}
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:8,
示例30: commit
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean commit() throws LoginException {
Set kcRoles = subject.getPrincipals(RolePrincipal.class);
logger.info("commit invoked. Keycloak roles: " + kcRoles);
SimpleGroup wfRoles = new SimpleGroup("Roles");
for (RolePrincipal kcRole : kcRoles) {
wfRoles.addMember(new SimplePrincipal(kcRole.getName()));
}
subject.getPrincipals().add(wfRoles);
return true;
}
開發者ID:mposolda,項目名稱:keycloak-remote-ejb,代碼行數:15,
示例31: abort
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean abort() throws LoginException {
LCTest.logAction("abort");
if (succeeded == false) {
return false;
}
clearState();
return true;
}
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,
示例32: LoginManager
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
private LoginManager(JaasContext jaasContext, boolean hasKerberos, Map configs,
Password jaasConfigValue) throws IOException, LoginException {
this.cacheKey = jaasConfigValue != null ? jaasConfigValue : jaasContext.name();
login = hasKerberos ? new KerberosLogin() : new DefaultLogin();
login.configure(configs, jaasContext);
login.login();
}
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:8,
示例33: getSubject
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Retrieves the caller's Subject, or Subject obtained by logging in
* via the specified caller.
*
* Caller must have permission to:
* - access the Subject
* - create LoginContext
* - read the auth.login.defaultCallbackHandler security property
*
* NOTE: This method is used by JSSE Kerberos Cipher Suites
*/
public static Subject getSubject(GSSCaller caller,
AccessControlContext acc) throws LoginException {
// Try to get the Subject from acc
Subject subject = Subject.getSubject(acc);
// Try to get Subject obtained from GSSUtil
if (subject == null && !GSSUtil.useSubjectCredsOnly(caller)) {
subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
}
return subject;
}
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,
示例34: logout
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
/**
* Remove the user identity and roles added to the Subject during commit.
*
* @return true always.
*/
@Override
public boolean logout() throws LoginException {
UniversalLoginModule.log.info("User logged out: " + getUserName());
// Remove the user identity
Set principals = subject.getPrincipals();
principals.remove(identity);
return true;
}
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,
示例35: getServiceCreds
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public Object getServiceCreds(AccessControlContext acc)
throws LoginException {
ServiceCreds serviceCreds =
Krb5Util.getServiceCreds(GSSCaller.CALLER_SSL_SERVER, null, acc);
return serviceCreds;
}
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,
示例36: commit
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
@Override
public boolean commit () throws LoginException
{
this.subject.getPrincipals ().add ( new UserInformationPrincipal ( this.userInformation ) );
this.subject.getPublicCredentials ().add ( this.userInformation );
return this.loggedIn;
}
開發者ID:eclipse,項目名稱:neoscada,代碼行數:8,
示例37: ejbLogin
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
private void ejbLogin(long key, String password) throws LoginException {
final SecurityService securityService = SystemInstance.get()
.getComponent(SecurityService.class);
final Object token;
securityService.disassociate();
token = securityService.login(
Long.valueOf(key).toString(),
password);
if (AbstractSecurityService.class.isInstance(securityService)
&& AbstractSecurityService.class.cast(securityService)
.currentState() == null) {
securityService.associate(token);
}
}
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,
示例38: GuildBot
點讚 2
import javax.security.auth.login.LoginException; //導入依賴的package包/類
public GuildBot(final File config, final String token, final String webhookURL) throws LoginException, IllegalArgumentException, RateLimitedException, FileNotFoundException, IOException
{
this.config = JsonValue.readHjson(FileUtils.readFileToString(config, "UTF-8")).asObject();
this.threadPool = new ScheduledThreadPoolExecutor(4, r ->
{
final Thread t = new Thread(r, "GuildBot-" + GuildBot.threadCounter.getAndIncrement());
t.setUncaughtExceptionHandler((thread, throwable) ->
{
GuildBot.log.error("An error occurred", throwable);
handleThrowable(throwable, "Uncaught error in thread: " + thread.getName());
});
return t;
});
this.threadPool.setKeepAliveTime(1, TimeUnit.MINUTES);
this.webhook = webhookURL == null
? null
: new WebhookClientBuilder(webhookURL)
.setExecutorService(threadPool)
.setDaemon(true)
.setThreadFactory(r -> new Thread(r, "Error-Webhook-Thread"))
.build();
final JDABuilder builder = new JDABuilder(AccountType.BOT);
builder.setEventManager(new AnnotatedEventManager());
builder.setToken(token);
builder.setGame(Game.of("loading..."));
builder.setStatus(OnlineStatus.DO_NOT_DISTURB);
builder.addEventListener(this);
this.jda = builder.buildAsync();
}
開發者ID:JDA-Applications,項目名稱:GuildBot,代碼行數:38,
注:本文中的javax.security.auth.login.LoginException類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。