- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl
类的一些代码示例,展示了WSUsernameTokenPrincipalImpl
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WSUsernameTokenPrincipalImpl
类的具体详情如下:
包路径:org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl
类名称:WSUsernameTokenPrincipalImpl
[英]This class implements the Principal
interface and represents a UsernameToken user.
In addition to the principal's name this principal object also contains the nonce and created time of the UsernameToken (refer to the OASIS WS Security specification, UsernameToken profile). These values are set only if the password of UsernameToken was of type PasswordDigest
.
Furthermore the password type is provided to the application. The password type is the string of the type attribute of the password element inside the username token. Refer to the OASIS WSS specification for predefined password types.
The equals()
method use the prinicipal's name only and does not compare nonce or created time.
Modelled according to the example provided by JAAS documentation
[中]此类实现Principal
接口并表示UsernameToken用户。
除了主体的名称之外,这个主体对象还包含UsernameToken的nonce和创建时间(请参阅OASIS WS-Security规范UsernameToken配置文件)。仅当UsernameToken的密码类型为PasswordDigest
时,才会设置这些值。
此外,还会向应用程序提供密码类型。password type是用户名令牌中password元素的type属性的字符串。有关预定义的密码类型,请参阅OASIS WSS规范。equals()
方法只使用prinicipal的名称,不比较nonce或created time。
根据JAAS文档提供的示例建模
代码示例来源:origin: apache/cxf
/**
* Create a principal based on the authenticated UsernameToken.
* @throws Base64DecodingException
*/
private Principal createPrincipal(
String username,
String passwordValue,
String passwordType,
String nonce,
String createdTime
) {
boolean hashed = false;
if (WSS4JConstants.PASSWORD_DIGEST.equals(passwordType)) {
hashed = true;
}
WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(username, hashed);
if (nonce != null) {
principal.setNonce(Base64.getMimeDecoder().decode(nonce));
}
principal.setPassword(passwordValue);
principal.setCreatedTime(createdTime);
principal.setPasswordType(passwordType);
return principal;
}
代码示例来源:origin: spring-projects/spring-ws
@Override
protected void handleUsernameTokenPrincipal(UsernameTokenPrincipalCallback callback)
throws IOException, UnsupportedCallbackException {
UserDetails user = loadUserDetails(callback.getPrincipal().getName());
WSUsernameTokenPrincipalImpl principal = callback.getPrincipal();
UsernamePasswordAuthenticationToken authRequest =
new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), user.getAuthorities());
if (logger.isDebugEnabled()) {
logger.debug("Authentication success: " + authRequest.toString());
}
SecurityContextHolder.getContext().setAuthentication(authRequest);
}
代码示例来源:origin: apache/cxf
protected void validate(Message message) throws WSSecurityException {
AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
String name = null;
if (policy != null) {
name = policy.getUserName();
}
String errorMsg = "No user name and/or password is available, name: " + name;
LOG.warning(errorMsg);
throw new SecurityException(errorMsg);
}
UsernameToken token = convertPolicyToToken(policy);
Credential credential = new Credential();
credential.setUsernametoken(token);
RequestData data = new RequestData();
data.setMsgContext(message);
data.setCallbackHandler(callbackHandler);
credential = getValidator().validate(credential, data);
// Create a Principal/SecurityContext
SecurityContext sc = null;
if (credential != null && credential.getPrincipal() != null) {
sc = createSecurityContext(message, credential);
} else {
Principal p = new WSUsernameTokenPrincipalImpl(policy.getUserName(), false);
((WSUsernameTokenPrincipalImpl)p).setPassword(policy.getPassword());
sc = createSecurityContext(p);
}
message.put(SecurityContext.class, sc);
}
代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core
/**
* Create a principal based on the authenticated UsernameToken.
* @throws Base64DecodingException
*/
private Principal createPrincipal(
String username,
String passwordValue,
String passwordType,
String nonce,
String createdTime
) {
boolean hashed = false;
if (WSS4JConstants.PASSWORD_DIGEST.equals(passwordType)) {
hashed = true;
}
WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(username, hashed);
if (nonce != null) {
principal.setNonce(Base64.getMimeDecoder().decode(nonce));
}
principal.setPassword(passwordValue);
principal.setCreatedTime(createdTime);
principal.setPasswordType(passwordType);
return principal;
}
代码示例来源:origin: org.springframework.ws/spring-ws-security
@Override
protected void handleUsernameTokenPrincipal(UsernameTokenPrincipalCallback callback)
throws IOException, UnsupportedCallbackException {
UserDetails user = loadUserDetails(callback.getPrincipal().getName());
WSUsernameTokenPrincipalImpl principal = callback.getPrincipal();
UsernamePasswordAuthenticationToken authRequest =
new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), user.getAuthorities());
if (logger.isDebugEnabled()) {
logger.debug("Authentication success: " + authRequest.toString());
}
SecurityContextHolder.getContext().setAuthentication(authRequest);
}
代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom
/**
* Create a WSUsernameTokenPrincipal from this UsernameToken object
*/
public Principal createPrincipal() throws WSSecurityException {
WSUsernameTokenPrincipalImpl principal =
new WSUsernameTokenPrincipalImpl(getName(), isHashed());
String nonce = getNonce();
if (nonce != null) {
principal.setNonce(org.apache.xml.security.utils.XMLUtils.decode(nonce));
}
principal.setPassword(getPassword());
principal.setCreatedTime(getCreated());
return principal;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected void handleUsernameTokenPrincipal(UsernameTokenPrincipalCallback callback)
throws IOException, UnsupportedCallbackException {
UserDetails user = loadUserDetails(callback.getPrincipal().getName());
WSUsernameTokenPrincipalImpl principal = callback.getPrincipal();
UsernamePasswordAuthenticationToken authRequest =
new UsernamePasswordAuthenticationToken(principal, principal.getPassword(), user.getAuthorities());
if (logger.isDebugEnabled()) {
logger.debug("Authentication success: " + authRequest.toString());
}
SecurityContextHolder.getContext().setAuthentication(authRequest);
}
代码示例来源:origin: apache/cxf
protected UsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant)
throws WSSecurityException, Base64DecodingException {
BSPEnforcer bspEnforcer = new org.apache.wss4j.common.bsp.BSPEnforcer(!bspCompliant);
org.apache.wss4j.dom.message.token.UsernameToken ut =
new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement, false, bspEnforcer);
WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(ut.getName(), ut.isHashed());
if (ut.getNonce() != null) {
principal.setNonce(XMLUtils.decode(ut.getNonce()));
}
principal.setPassword(ut.getPassword());
principal.setCreatedTime(ut.getCreated());
principal.setPasswordType(ut.getPasswordType());
return principal;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-ws-security
protected UsernameTokenPrincipal parseTokenAndCreatePrincipal(Element tokenElement, boolean bspCompliant)
throws WSSecurityException, Base64DecodingException {
BSPEnforcer bspEnforcer = new org.apache.wss4j.common.bsp.BSPEnforcer(!bspCompliant);
org.apache.wss4j.dom.message.token.UsernameToken ut =
new org.apache.wss4j.dom.message.token.UsernameToken(tokenElement, false, bspEnforcer);
WSUsernameTokenPrincipalImpl principal = new WSUsernameTokenPrincipalImpl(ut.getName(), ut.isHashed());
if (ut.getNonce() != null) {
principal.setNonce(XMLUtils.decode(ut.getNonce()));
}
principal.setPassword(ut.getPassword());
principal.setCreatedTime(ut.getCreated());
principal.setPasswordType(ut.getPasswordType());
return principal;
}
代码示例来源:origin: apache/cxf
public Credential validate(Credential credential, RequestData data) throws WSSecurityException {
Credential cred = super.validate(credential, data);
UsernameToken ut = credential.getUsernametoken();
WSUsernameTokenPrincipalImpl principal =
new WSUsernameTokenPrincipalImpl(ut.getName(), ut.isHashed());
principal.setCreatedTime(ut.getCreated());
principal.setNonce(principal.getNonce());
principal.setPassword(ut.getPassword());
principal.setPasswordType(ut.getPasswordType());
Subject subject = new Subject();
subject.getPrincipals().add(principal);
if ("Alice".equals(ut.getName())) {
subject.getPrincipals().add(new SimpleGroup("manager", ut.getName()));
}
subject.getPrincipals().add(new SimpleGroup("worker", ut.getName()));
cred.setSubject(subject);
return cred;
}
}
代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom
} else {
WSUsernameTokenPrincipalImpl principal =
new WSUsernameTokenPrincipalImpl(token.getName(), token.isHashed());
if (token.getNonce() != null) {
principal.setNonce(XMLUtils.decode(token.getNonce()));
principal.setPassword(token.getPassword());
principal.setCreatedTime(token.getCreated());
principal.setPasswordType(token.getPasswordType());
result.put(WSSecurityEngineResult.TAG_PRINCIPAL, principal);
我正在使用 Fluent Azure SDK for .NET 尝试获取租户中所有服务主体的列表。 var authenticatedContext = Azure.Authenticate(
我需要查找哪个主体修改或创建了给定主体。 我们可以使用 Microsoft Graph Api 获得修改后的主体列表: https://graph.microsoft.com/beta/service
我目前在 Azure 中有 10 个 SQL 数据库。在 Azure 门户中,我有我的用户名 (omnipos)。 当我想使用 MSSM 连接到数据库时,出现错误 无法作为数据库主体执行,因为主体“[
我正在尝试追踪 glassfish 中的一条烦人的消息正在污染我们的日志文件的原因。 为了简化我们的设置,我们有 2 个运行 3.1.2.2 的 glassfish 服务器。 服务器 A 上部署了一个
我在应用程序中使用springSecurityCore插件,并且用户在appStartupController中登录后,我喜欢 def index = { if (springSecurityS
你好,你好吗?我是 Azure 中组织订阅的唯一所有者,我需要创建服务主体。 我如何向我的用户授予权限?或者我可以创建一个新角色来分配此权限吗? 有什么想法吗? 提前致谢 最佳答案 注意:订阅的角色和
我很困惑为什么在 WebAPI 中需要设置 Principal,因为每次调用都是完全无状态的。因为每次调用都应该是完全无状态的,所以使用您记录的用户信息设置它有什么好处和原因? 我的印象是,一个登录的
我一直在看这篇文章: http://pythonhosted.org/Flask-Principal/#granular-resource-protection 现在虽然它当前的工作方式没有任何问题,
我是编写 flask 的新手,目前使用 flask-principal 作为我的授权机制。当用户试图在没有所需权限的情况下访问 url 时,flask-principal 会引发 Permission
Spring Security 假设 Authentication 是 Principal 。 public interface Authentication extends Principal, S
在装饰器中调用安全身份验证属性 principal.displayName 是否会导致问题? 我将其设置为 sitemesh 装饰器中的变量:
我正在Grails中编写更新或更改用户数据表单。这是我表单的一部分,用户可以在其中更改其旧登录名: Логин ... 更新之前必须显示旧的用户数据。我用它:${springSe
在我的 ASP 项目中,我使用的是 ASP.NET Identity 2.2.1。在许多地方,我必须获得当前(登录)用户的电子邮件。现在我发现那个用户使用这个: var user = await Us
为什么 Principal.IsMemberOf(GroupPrincipal) ( MSDN ) 在以下测试中为 Domain Computers 组返回假阴性? [TestMethod] publ
我正在尝试确定给定的本地用户帐户是否在本地管理员组中。在系统加入域之前一切正常。当加入域时抛出异常,提示未找到网络路径,但仅在查找本地非管理员帐户时才会抛出异常;如果测试帐户是本地管理员,则该方法返回
我有一个在 Tomcat 中运行的网络应用程序。我想允许任何拥有服务器信任的有效证书的用户访问 Web 应用程序,但我想从证书中读取用户的 DN。我用 clientAuth="true"配置了 SSL
有没有一种标准的方法可以将 CSS 文件命名为主体文件?我有两个 CSS 文件(一个用于 Bootstrap,一个用于我的自定义 CSS),我希望自定义文件中的所有样式对所有元素文件都同样重要。但我也
所有,我正在编写一个依赖于 flask-principal 的 flask 应用程序用于管理用户角色。我想编写一些简单的单元测试来检查哪些用户可以访问哪些 View 。已发布代码示例 on paste
在谈论 .NET 中的身份时,我们想到了 Principal .有接口(interface) IPrincipal并与它一起实现 ClaimsPrincipal .我们甚至可以随时使用 Thread.
本文整理了Java中org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl类的一些代码示例,展示了WSUsernameTokenP
我是一名优秀的程序员,十分优秀!