org.apache.ws.security.WSUsernameTokenPrincipal类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(131)

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

WSUsernameTokenPrincipal介绍

[英]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: stackoverflow.com

WSUsernameTokenPrincipal mockedWsutp = mock(WSUsernameTokenPrincipal.class);
when(mockedWsutp.getName()).thenReturn("TheNameRequiredForYourTestCase");
...

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

/**
 * Create a WSUsernameTokenPrincipal from this UsernameToken object
 */
public Principal createPrincipal() {
  WSUsernameTokenPrincipal principal = 
    new WSUsernameTokenPrincipal(getName(), isHashed());
  principal.setNonce(getNonce());
  principal.setPassword(getPassword());
  principal.setCreatedTime(getCreated());
  return principal;
}

代码示例来源:origin: org.apache.servicemix/servicemix-cxf-bc

WSUsernameTokenPrincipal p = (WSUsernameTokenPrincipal)er.get(WSSecurityEngineResult.TAG_PRINCIPAL);
subject.getPrincipals().add(p);
this.authenticationService.authenticate(subject, domain, p.getName(), p.getPassword());
authenticated = true;

代码示例来源:origin: org.apache.rampart/rampart-core

String username = userNameTokenPrincipal.getName();
msgCtx.setProperty(RampartMessageData.USERNAME, username);
if (userNameTokenPrincipal.getNonce() != null) {
  boolean valueRepeating = serviceNonceCache.isNonceRepeatingForService(serviceEndpointName, username, userNameTokenPrincipal.getNonce());
    throw new RampartException("repeatingNonceValue", new Object[]{ userNameTokenPrincipal.getNonce(), username} );
  serviceNonceCache.addNonceForService(serviceEndpointName, username, userNameTokenPrincipal.getNonce(), nonceLifeTimeInSeconds);

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sts.passive

OMElement rstr = null;
principal = new WSUsernameTokenPrincipal(request.getUserName(), false);

代码示例来源:origin: org.n52.security/52n-security-sts

AuthenticationService authenticationService = securityConfig.getServiceConfig(STSAuthenticationService.SERVICENAME).getAuthenticationService();
CredentialsCallbackHandler ccbh = new CredentialsCallbackHandler();
ccbh.add(new UsernamePasswordCredential(token.getName(), token
    .getPassword()));
AuthenticationContext authCxt = authenticationService.login(ccbh);

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.sts/org.wso2.carbon.identity.sts.passive

principal = new WSUsernameTokenPrincipal(request.getUserName(), false);

代码示例来源:origin: org.apache.ws.security/wss4j

/**
 * Create a WSUsernameTokenPrincipal from this UsernameToken object
 */
public Principal createPrincipal() {
  WSUsernameTokenPrincipal principal = 
    new WSUsernameTokenPrincipal(getName(), isHashed());
  principal.setNonce(getNonce());
  principal.setPassword(getPassword());
  principal.setCreatedTime(getCreated());
  return principal;
}

代码示例来源:origin: stackoverflow.com

@WebResult(name = "UpdatePatternResponse", targetNamespace = "http://test.com/schemas/xsd/myservice/", partName = "UpdatePatternResponse")
@WebMethod(operationName = "UpdatePattern", action = "UpdatePattern")
@Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2015-02-19T12:49:59.491-05:00")
public test.com.schemas.xsd.myservice.UpdatePatternResponse updatePattern(
  @WebParam(partName = "UpdatePatternRequest", name = "UpdatePatternRequest", targetNamespace = "http://test.com/schemas/xsd/myservice/")
  test.com.schemas.xsd.myservice.UpdatePatternRequest updatePatternRequest
) throws SIASFaultMessage{
  .
  .
  Message message = PhaseInterceptorChain.getCurrentMessage();
  WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal)message.get("wss4j.principal.result");
  String userName = principal.getName();
  .
  .
  .
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.sts.passive

principal = new WSUsernameTokenPrincipal(request.getUserName(), false);

代码示例来源:origin: org.apache.ws.security/wss4j

} else {
  WSUsernameTokenPrincipal principal = 
    new WSUsernameTokenPrincipal(token.getName(), token.isHashed());
  principal.setNonce(token.getNonce());
  principal.setPassword(token.getPassword());
  principal.setCreatedTime(token.getCreated());
  principal.setPasswordType(token.getPasswordType());
  result.put(WSSecurityEngineResult.TAG_PRINCIPAL, principal);

代码示例来源:origin: org.apache.rampart/rampart-core

/**
 * Scan through {@link WSHandlerResult} list for a Username token and return
 * the username if a Username Token found 
 * @param results
 * @return
 */

public static String getUsername(List<WSHandlerResult> results) {
  /*
   * Scan the results for a matching actor. Use results only if the
   * receiving Actor and the sending Actor match.
   */
  for (WSHandlerResult result : results) {
    List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();
    /*
    * Scan the results for a username token. Use the username
    * of this token to set the alias for the encryption user
    */
    for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {
      Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);
      if (actInt == WSConstants.UT) {
        WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal) wsSecEngineResult.
            get(WSSecurityEngineResult.TAG_PRINCIPAL);
        return principal.getName();
      }
    }
  }
      return null;
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.sts/org.wso2.carbon.identity.sts.passive

OMElement rstr = null;
principal = new WSUsernameTokenPrincipal(request.getUserName(), false);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

} else {
  WSUsernameTokenPrincipal principal = 
    new WSUsernameTokenPrincipal(token.getName(), token.isHashed());
  principal.setNonce(token.getNonce());
  principal.setPassword(token.getPassword());
  principal.setCreatedTime(token.getCreated());
  principal.setPasswordType(token.getPasswordType());
  result.put(WSSecurityEngineResult.TAG_PRINCIPAL, principal);

代码示例来源:origin: edu.internet2.middleware.grouper/grouper-ws

userIdLoggedIn = principal.getName();
break OUTER;

相关文章