gpt4 book ai didi

org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 16:17:05 24 4
gpt4 key购买 nike

本文整理了Java中org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl.<init>()方法的一些代码示例,展示了WSUsernameTokenPrincipalImpl.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WSUsernameTokenPrincipalImpl.<init>()方法的具体详情如下:
包路径:org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl
类名称:WSUsernameTokenPrincipalImpl
方法名:<init>

WSUsernameTokenPrincipalImpl.<init>介绍

[英]Create a WSUsernameTokenPrincipalImpl with a WSUsernameToken username.
[中]使用WSUsernameToken用户名创建WSUsernameToken。

代码示例

代码示例来源: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: 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.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/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: 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: 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/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: 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()));

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com