use of org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl in project testcases by coheigea.
the class ShiroBasicAuthInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
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 error = "No user credentials are available";
LOG.warning(error + " " + "for name: " + name);
throw new SecurityException(error);
}
try {
UsernameToken token = convertPolicyToToken(policy);
Credential credential = new Credential();
credential.setUsernametoken(token);
RequestData data = new RequestData();
data.setMsgContext(message);
credential = validator.validate(credential, data);
// Create a Principal/SecurityContext
Principal p = null;
if (credential != null && credential.getPrincipal() != null) {
p = credential.getPrincipal();
} else {
p = new WSUsernameTokenPrincipalImpl(policy.getUserName(), false);
((WSUsernameTokenPrincipalImpl) p).setPassword(policy.getPassword());
}
message.put(SecurityContext.class, createSecurityContext(p));
} catch (Exception ex) {
throw new Fault(ex);
}
}
use of org.apache.wss4j.common.principal.WSUsernameTokenPrincipalImpl in project ddf by codice.
the class AttributeMapLoader method getCredentials.
public String getCredentials(Principal principal) {
String credential = null;
if (principal instanceof X500Principal) {
X500Principal x500p = (X500Principal) principal;
credential = new String(x500p.getEncoded(), StandardCharsets.UTF_8);
} else if (principal instanceof WSUsernameTokenPrincipalImpl) {
credential = ((WSUsernameTokenPrincipalImpl) principal).getPassword();
}
return credential;
}
Aggregations