Search in sources :

Example 1 with Attribute

use of org.forgerock.openam.radius.common.Attribute in project OpenAM by OpenRock.

the class RadiusRequest method loadAttsMap.

/**
     * Loads the attributes into a map. warning: this is lossy for atts that support duplicates like proxyState. but we
     * aren't using those for authentication but only need State, UserName, and UserPassword. So we are good.
     */
private void loadAttsMap() {
    final AttributeSet atts = requestPacket.getAttributeSet();
    for (int i = 0; i < atts.size(); i++) {
        final Attribute att = atts.getAttributeAt(i);
        // warning: this is lossy for atts that support duplicates like proxyState. but we aren't using those
        // for authentication but only need State, UserName, and UserPassword. So we are good.
        attributeMap.put(att.getClass(), att);
    }
}
Also used : AttributeSet(org.forgerock.openam.radius.common.AttributeSet) Attribute(org.forgerock.openam.radius.common.Attribute) UserNameAttribute(org.forgerock.openam.radius.common.UserNameAttribute)

Example 2 with Attribute

use of org.forgerock.openam.radius.common.Attribute in project OpenAM by OpenRock.

the class RadiusRequestContext method getPacketRepresentation.

/**
     * Formats a textual representation of the contents of a packet.
     *
     * @param pkt
     *            the packet whose content is to be logged in human read-able form.
     * @return The packet's contents in human read-able form.
     */
public static String getPacketRepresentation(Packet pkt) {
    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);
    String packetType = null;
    final Class clazz = pkt.getClass();
    if (clazz == AccessRequest.class) {
        packetType = "ACCESS_REQUEST";
    } else if (clazz == AccessReject.class) {
        packetType = "ACCESS_REJECT";
    } else if (clazz == AccessAccept.class) {
        packetType = "ACCESS_ACCEPT";
    } else if (clazz == AccessChallenge.class) {
        packetType = "ACCESS_CHALLENGE";
    } else {
        packetType = pkt.getClass().getSimpleName();
    }
    pw.println("  " + packetType + " [" + pkt.getIdentifier() + "]");
    final AttributeSet atts = pkt.getAttributeSet();
    for (int i = 0; i < atts.size(); i++) {
        final Attribute a = atts.getAttributeAt(i);
        pw.println("    - " + a);
    }
    pw.flush();
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) AttributeSet(org.forgerock.openam.radius.common.AttributeSet) Attribute(org.forgerock.openam.radius.common.Attribute) AccessReject(org.forgerock.openam.radius.common.AccessReject) AccessChallenge(org.forgerock.openam.radius.common.AccessChallenge) PrintWriter(java.io.PrintWriter)

Aggregations

Attribute (org.forgerock.openam.radius.common.Attribute)2 AttributeSet (org.forgerock.openam.radius.common.AttributeSet)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 AccessChallenge (org.forgerock.openam.radius.common.AccessChallenge)1 AccessReject (org.forgerock.openam.radius.common.AccessReject)1 UserNameAttribute (org.forgerock.openam.radius.common.UserNameAttribute)1