本文整理汇总了Java中javax.security.enterprise.credential.Credential类的典型用法代码示例。如果您正苦于以下问题:Java Credential类的具体用法?Java Credential怎么用?Java Credential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Credential类属于javax.security.enterprise.credential包,在下文中一共展示了Credential类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: login
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
Credential credential = new UsernamePasswordCredential(username, new Password(password));
AuthenticationStatus status = securityContext.authenticate(
getRequest(context),
getResponse(context),
withParams()
.credential(credential)
.newAuthentication(!continued)
.rememberMe(rememberMe)
);
LOG.info("authentication result:" + status);
if (status.equals(SEND_CONTINUE)) {
// Authentication mechanism has send a redirect, should not
// send anything to response from JSF now.
context.responseComplete();
} else if (status.equals(SEND_FAILURE)) {
addError(context, "Authentication failed");
}
}
开发者ID:hantsy,项目名称:javaee8-jsf-sample,代码行数:26,代码来源:LoginBean.java
示例2: login
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
public void login() {
Credential credential = new UsernamePasswordCredential(username, new Password(password));
AuthenticationStatus status = securityContext.authenticate(
getRequestFrom(facesContext),
getResponseFrom(facesContext),
withParams().credential(credential));
if (status.equals(SEND_CONTINUE)) {
facesContext.responseComplete();
} else if (status.equals(SEND_FAILURE)) {
addError(facesContext, "Authentication failed");
}
}
开发者ID:readlearncode,项目名称:Java-EE-8-Sampler,代码行数:17,代码来源:LoginBean.java
示例3: validate
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
@Override
public CredentialValidationResult validate(Credential credential) {
if (credential instanceof TokenResponseCredential) {
TokenResponseCredential tokenCredential = (TokenResponseCredential) credential;
OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/oauth2/v3/userinfo");
OAuth20Service service = tokenCredential.getService();
OAuth2AccessToken token = tokenCredential.getTokenResponse();
service.signRequest(token, request);
try {
Response oResp = service.execute(request);
String body = oResp.getBody();
OAuth2User oAuth2User = jsonProcessor.extractUserInfo(body);
return new CredentialValidationResult(oAuth2User);
} catch (InterruptedException | ExecutionException | IOException e) {
e.printStackTrace(); // FIXME
}
}
return CredentialValidationResult.NOT_VALIDATED_RESULT;
}
开发者ID:atbashEE,项目名称:jsr375-extensions,代码行数:27,代码来源:DemoIdentityStore.java
示例4: validate
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
@Override
public CredentialValidationResult validate(Credential credential) {
CredentialValidationResult result;
if (credential instanceof UsernamePasswordCredential) {
UsernamePasswordCredential usernamePassword = (UsernamePasswordCredential) credential;
result = users.findByUsername(usernamePassword.getCaller())
.map(
u -> passwordHash.matches(new String(usernamePassword.getPassword().getValue()), u.getPassword())
? new CredentialValidationResult(usernamePassword.getCaller(), u.getAuthorities())
: INVALID_RESULT
)
.orElse(INVALID_RESULT);
} else {
result = NOT_VALIDATED_RESULT;
}
return result;
}
开发者ID:hantsy,项目名称:javaee8-jaxrs-sample,代码行数:21,代码来源:JpaIdentityStore.java
示例5: login
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
Credential credential = new UsernamePasswordCredential(username, new Password(password));
AuthenticationStatus status = securityContext.authenticate(
getRequest(context),
getResponse(context),
withParams()
.credential(credential));
LOG.info("authentication result:" + status);
if (status.equals(SEND_CONTINUE)) {
// Authentication mechanism has send a redirect, should not
// send anything to response from JSF now.
context.responseComplete();
} else if (status.equals(SEND_FAILURE)) {
addError(context, "Authentication failed");
}
}
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:23,代码来源:LoginBean.java
示例6: login
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
public void login() {
FacesContext context = FacesContext.getCurrentInstance();
Credential credential = new UsernamePasswordCredential(username, new Password(password));
AuthenticationStatus status = securityContext.authenticate(
getRequest(context),
getResponse(context),
withParams()
.credential(credential));
LOG.log(Level.INFO, "authentication result:{0}", status);
if (status.equals(SEND_CONTINUE)) {
// Authentication mechanism has send a redirect, should not
// send anything to response from JSF now.
context.responseComplete();
} else if (status.equals(SEND_FAILURE)) {
addError(context, "Authentication failed");
}
}
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:23,代码来源:LoginBean.java
示例7: validateRequest
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
@Override
public AuthenticationStatus validateRequest(
HttpServletRequest request,
HttpServletResponse response,
HttpMessageContext context) throws AuthenticationException {
Credential credential = context.getAuthParameters().getCredential();
if (credential != null) {
return context.notifyContainerAboutLogin(identityStore.validate(credential));
} else {
return context.doNothing();
}
}
开发者ID:hantsy,项目名称:javaee8-jsf-sample,代码行数:15,代码来源:CustomAuthenticationMechanism.java
示例8: validate
import javax.security.enterprise.credential.Credential; //导入依赖的package包/类
@Override
public CredentialValidationResult validate(Credential credential) {
UsernamePasswordCredential user = (UsernamePasswordCredential) credential;
if (user.getCaller().equalsIgnoreCase("Duke") && user.getPasswordAsString().equalsIgnoreCase("Dance")) {
return new CredentialValidationResult("Duke",new HashSet<>(asList("foo", "bar")));
}
return INVALID_RESULT;
}
开发者ID:ivargrimstad,项目名称:security-samples,代码行数:13,代码来源:SimpleIdentityStore.java
注:本文中的javax.security.enterprise.credential.Credential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论