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


Java Credential类代码示例

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


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

示例1: verifyCredential

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean verifyCredential(Account account, Credential credential) {
    boolean match = false;
    if (credential instanceof PasswordCredential) {
        char[] password = ((PasswordCredential) credential).getPassword();
        User user = users.get(account.getPrincipal().getName());
        String expectedPassword = user.getPassword();
        try {
            match = HashUtil.validatePassword(password, expectedPassword);
            Arrays.fill(password, ' ');
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            logger.error("Exception:", e);
        }
    }
    if(logger.isDebugEnabled()) logger.debug("verfifyCredential = " + match);
    return match;
}
 
开发者ID:networknt,项目名称:light-oauth2,代码行数:18,代码来源:MapIdentityManager.java

示例2: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
  PasswordCredential passwordCredential = (PasswordCredential) credential;

  try {
    User user = repository.authenticate(id, passwordCredential.getPassword());
    if(logger.isDebugEnabled()) {
      logger.debug("User {} logged", user);
    }

    return new UserPrincipal(user.id, user.username, User.ROLES);
  } catch (UserNotFoundException e) {
    if(logger.isInfoEnabled()) {
      logger.info("Login failed", e);
    }
  }

  return null;
}
 
开发者ID:vvergnolle,项目名称:vas,代码行数:20,代码来源:RepositoryIdentityManager.java

示例3: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
    if (id == null || id.trim().length() == 0) {
        return null;
    }

    FakeAccount account = accounts.get(id);
    if ((credential instanceof PasswordCredential)
            && String.valueOf(((PasswordCredential) credential).getPassword()).equals(account.password)) {
        account.roles.add(
                LightblueRestTestHarness.SECURITY_ROLE_AUTHENTICATED);
        return account;
    }

    return null;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:17,代码来源:FakeIdentityManager.java

示例4: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String username, Credential credential) {
    if (username == null || credential == null || !(credential instanceof PasswordCredential)) {
        return null;
    }
    PasswordCredential pwc = (PasswordCredential) credential;

    try {
        Set<String> roles = getRoles(username, new String(pwc.getPassword()));
        Account acct = new SimpleAccount(username, pwc.getPassword(), roles);
        return acct;
    } catch (NamingException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:17,代码来源:ADIdentityManager.java

示例5: verifyCredential

import io.undertow.security.idm.Credential; //导入依赖的package包/类
private boolean verifyCredential(Account account, Credential credential) {
    String id = account.getPrincipal().getName();

    SimpleAccount ourAccount = getAccount(id);

    if (ourAccount == null) {
        return false;
    }

    if (credential instanceof PasswordCredential
            && account instanceof SimpleAccount) {
        char[] password = ((PasswordCredential) credential).getPassword();
        char[] expected = ourAccount.getCredentials().getPassword();

        return checkPassword(
                this.bcryptHashedPassword,
                password,
                expected);
    }
    return false;
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:22,代码来源:AbstractDbIdentityManager.java

示例6: authenticate

import io.undertow.security.idm.Credential; //导入依赖的package包/类
public AuthenticationMechanismOutcome authenticate(final HttpServerExchange exchange, final SecurityContext securityContext) {
    SSLSessionInfo sslSession = exchange.getConnection().getSslSessionInfo();
    if (sslSession != null) {
        try {
            Certificate[] clientCerts = getPeerCertificates(exchange, sslSession, securityContext);
            if (clientCerts[0] instanceof X509Certificate) {
                Credential credential = new X509CertificateCredential((X509Certificate) clientCerts[0]);

                IdentityManager idm = securityContext.getIdentityManager();
                Account account = idm.verify(credential);
                if (account != null) {
                    securityContext.authenticationComplete(account, name, false);
                    return AuthenticationMechanismOutcome.AUTHENTICATED;
                }
            }
        } catch (SSLPeerUnverifiedException e) {
            // No action - this mechanism can not attempt authentication without peer certificates so allow it to drop out
            // to NOT_ATTEMPTED.
        }
    }

    /*
     * For ClientCert we do not have a concept of a failed authentication, if the client did use a key then it was deemed
     * acceptable for the connection to be established, this mechanism then just 'attempts' to use it for authentication but
     * does not mandate success.
     */

    return AuthenticationMechanismOutcome.NOT_ATTEMPTED;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ClientCertAuthenticationMechanism.java

示例7: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
    Account account = getAccount(id);
    if (account != null && verifyCredential(account, credential)) {
        return account;
    }

    return null;
}
 
开发者ID:networknt,项目名称:light-oauth2,代码行数:10,代码来源:MapIdentityManager.java

示例8: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
    if(!(credential instanceof PasswordCredential)) {
        return null;
    }
    PasswordCredential pc = (PasswordCredential) credential;
    char[] pwdArr = pc.getPassword();
    if(pwdArr != null && passwordEncoder.matches(new String(pwdArr), encodedPass)) {
        return new AccountImpl(id);
    }
    return null;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:13,代码来源:AuthConfiguration.java

示例9: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
/**
 * Called by FormAuthenticationMechanism when user submits the login form.
 */
@Override
public Account verify(String id, Credential credential) {
    PasswordCredential pwdCredential = (PasswordCredential) credential;
    return this.userRolesMapping
            .entrySet()
            .stream()
            .filter(entry -> StringUtils.equals(entry.getKey(), id)
                    && ArrayUtils.isNotEmpty(pwdCredential.getPassword())
                    && CredentialMatcher.match(entry.getKey(), new String(pwdCredential.getPassword())))
            .map(entry -> new SimpleAccount(new SimplePrincipal(entry.getKey()), new HashSet<>(entry.getValue())))
            .findFirst()
            .orElse(null);
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:17,代码来源:SimpleIdentityManager.java

示例10: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
	if (this.account.getPrincipal().getName().equals(id)) {
		return this.account;
	} else {
		return null;
	}
}
 
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:9,代码来源:UnisonIdentityManager.java

示例11: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(Credential credential) {
    return new Account() {
        @Override
        public Principal getPrincipal() {
            return principal;
        }

        @Override
        public Set<String> getRoles() {
            return Collections.emptySet();
        }
    };
}
 
开发者ID:ULYSSIS-KUL,项目名称:ipp,代码行数:15,代码来源:HttpServerPublisher.java

示例12: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String username, Credential credential) {
    Account account = null;
    if (this.username.equals(username) && verifyCredential(credential)) {
        account = getAccount(username);
    }

    return account;
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:10,代码来源:Identity.java

示例13: verifyCredential

import io.undertow.security.idm.Credential; //导入依赖的package包/类
private boolean verifyCredential(Credential credential) {
    if (credential instanceof PasswordCredential) {
        return CodecUtils.checkJBCrypt(
                new String (((PasswordCredential) credential).getPassword()),
                this.password);
    }
    
    return false;
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:10,代码来源:Identity.java

示例14: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
    Account account = users.get(id);
    if (account != null && verifyCredential(account, credential)) {
        return account;
    }

    return null;
}
 
开发者ID:undertow-io,项目名称:undertow.js,代码行数:10,代码来源:ServletIdentityManager.java

示例15: verify

import io.undertow.security.idm.Credential; //导入依赖的package包/类
@Override
public Account verify(String id, Credential credential) {
    if (id == null || id.length() == 0) {
        HttpServerLogger.ROOT_LOGGER.debug("Missing or empty username received, aborting account verification.");
        return null;
    }

    if (credential instanceof PasswordCredential) {
        return verify(id, (PasswordCredential) credential);
    } else if (credential instanceof DigestCredential) {
        return verify(id, (DigestCredential) credential);
    }

    throw HttpServerLogger.ROOT_LOGGER.invalidCredentialType(credential.getClass().getName());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:RealmIdentityManager.java


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