use of org.forgerock.openam.radius.common.UserNameAttribute in project OpenAM by OpenRock.
the class RadiusConn method authenticate.
/**
* Authenticates the username and password against the remote servers.
*
* @param name the username.
* @param password the password.
* @throws IOException if there is a problem.
* @throws NoSuchAlgorithmException if there is a problem.
* @throws RejectException if there is a problem.
* @throws ChallengeException if there is a problem.
*/
public void authenticate(String name, String password) throws IOException, NoSuchAlgorithmException, RejectException, ChallengeException {
AccessRequest req = createAccessRequest();
req.addAttribute(new UserNameAttribute(name));
req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(), secret, password));
req.addAttribute(new NASIPAddressAttribute(InetAddress.getLocalHost()));
req.addAttribute(new NASPortAttribute(socket.getLocalPort()));
sendPacket(req);
}
use of org.forgerock.openam.radius.common.UserNameAttribute in project OpenAM by OpenRock.
the class RadiusConn method replyChallenge.
/**
* Sends an access-request to the server in response to a challenge request.
*
* @param name the username.
* @param password the password.
* @param ce the challenge exception providing access to the original challenge response.
* @throws IOException if there is a problem.
* @throws NoSuchAlgorithmException if there is a problem.
* @throws RejectException if there is a problem.
* @throws ChallengeException if there is a problem.
*/
public void replyChallenge(String name, String password, ChallengeException ce) throws IOException, NoSuchAlgorithmException, RejectException, ChallengeException {
StateAttribute state = (StateAttribute) ce.getAttributeSet().getAttributeByType(AttributeType.STATE);
if (state == null) {
throw new IOException("State not found in challenge");
}
AccessRequest req = createAccessRequest();
// needed in challenge
req.addAttribute(state);
if (name != null) {
req.addAttribute(new UserNameAttribute(name));
}
req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(), secret, password));
req.addAttribute(new NASIPAddressAttribute(InetAddress.getLocalHost()));
req.addAttribute(new NASPortAttribute(socket.getLocalPort()));
sendPacket(req);
}
Aggregations