Search in sources :

Example 6 with UserNameAttribute

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);
}
Also used : AccessRequest(org.forgerock.openam.radius.common.AccessRequest) UserNameAttribute(org.forgerock.openam.radius.common.UserNameAttribute) NASPortAttribute(org.forgerock.openam.radius.common.packet.NASPortAttribute) NASIPAddressAttribute(org.forgerock.openam.radius.common.packet.NASIPAddressAttribute) UserPasswordAttribute(org.forgerock.openam.radius.common.UserPasswordAttribute)

Example 7 with UserNameAttribute

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);
}
Also used : StateAttribute(org.forgerock.openam.radius.common.StateAttribute) AccessRequest(org.forgerock.openam.radius.common.AccessRequest) UserNameAttribute(org.forgerock.openam.radius.common.UserNameAttribute) NASPortAttribute(org.forgerock.openam.radius.common.packet.NASPortAttribute) IOException(java.io.IOException) NASIPAddressAttribute(org.forgerock.openam.radius.common.packet.NASIPAddressAttribute) UserPasswordAttribute(org.forgerock.openam.radius.common.UserPasswordAttribute)

Aggregations

UserNameAttribute (org.forgerock.openam.radius.common.UserNameAttribute)7 AccessRequest (org.forgerock.openam.radius.common.AccessRequest)6 UserPasswordAttribute (org.forgerock.openam.radius.common.UserPasswordAttribute)5 IOException (java.io.IOException)3 StateAttribute (org.forgerock.openam.radius.common.StateAttribute)3 NASIPAddressAttribute (org.forgerock.openam.radius.common.packet.NASIPAddressAttribute)3 NASPortAttribute (org.forgerock.openam.radius.common.packet.NASPortAttribute)3 Test (org.testng.annotations.Test)3 Authenticator (org.forgerock.openam.radius.common.Authenticator)2 Packet (org.forgerock.openam.radius.common.Packet)2 ContextHolder (org.forgerock.openam.radius.server.spi.handlers.amhandler.ContextHolder)2 AuthContext (com.sun.identity.authentication.AuthContext)1 Status (com.sun.identity.authentication.AuthContext.Status)1 PagePropertiesCallback (com.sun.identity.authentication.spi.PagePropertiesCallback)1 InetSocketAddress (java.net.InetSocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 DatagramChannel (java.nio.channels.DatagramChannel)1 SecureRandom (java.security.SecureRandom)1 Properties (java.util.Properties)1 Callback (javax.security.auth.callback.Callback)1