if (credential == null || credential.getUsernametoken() == null) { throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential"); String password = null; UsernameToken usernameToken = credential.getUsernametoken();
if (credential == null || credential.getUsernametoken() == null) { throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential"); String requiredPasswordType = data.getRequiredPasswordType(); UsernameToken usernameToken = credential.getUsernametoken(); usernameToken.setPasswordsAreEncoded(passwordsAreEncoded);
} else if (credential.getUsernametoken() != null) { tokenElement = credential.getUsernametoken().getElement(); hash = credential.getUsernametoken().hashCode(); } else if (credential.getBinarySecurityToken() != null) { tokenElement = credential.getBinarySecurityToken().getElement(); returnedToken = c.requestSecurityToken(); c.setOnBehalfOf(null); } else if (useIssueBinding && !useOnBehalfOf && credential.getUsernametoken() != null) { c.getProperties().put(SecurityConstants.USERNAME, credential.getUsernametoken().getName()); c.getProperties().put(SecurityConstants.PASSWORD, credential.getUsernametoken().getPassword()); returnedToken = c.requestSecurityToken(); c.getProperties().remove(SecurityConstants.USERNAME);
} else if (credential.getUsernametoken() != null) { tokenElement = credential.getUsernametoken().getElement(); hash = credential.getUsernametoken().hashCode(); } else if (credential.getBinarySecurityToken() != null) { tokenElement = credential.getBinarySecurityToken().getElement(); returnedToken = c.requestSecurityToken(); c.setOnBehalfOf(null); } else if (useIssueBinding && !useOnBehalfOf && credential.getUsernametoken() != null) { c.getProperties().put(SecurityConstants.USERNAME, credential.getUsernametoken().getName()); c.getProperties().put(SecurityConstants.PASSWORD, credential.getUsernametoken().getPassword()); returnedToken = c.requestSecurityToken(); c.getProperties().remove(SecurityConstants.USERNAME);
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; } }
UsernameToken token = credential.getUsernametoken();