Search in sources :

Example 1 with SerializablePrincipal

use of org.apache.catalina.ha.session.SerializablePrincipal in project geode by apache.

the class DeltaSession method getSerializedPrincipal.

private byte[] getSerializedPrincipal() {
    if (this.serializedPrincipal == null) {
        if (this.principal != null && this.principal instanceof GenericPrincipal) {
            GenericPrincipal gp = (GenericPrincipal) this.principal;
            SerializablePrincipal sp = SerializablePrincipal.createPrincipal(gp);
            this.serializedPrincipal = serialize(sp);
            if (manager != null) {
                DeltaSessionManager mgr = (DeltaSessionManager) getManager();
                if (mgr.getLogger().isDebugEnabled()) {
                    mgr.getLogger().debug(this + ": Serialized principal: " + sp);
                // mgr.logCurrentStack();
                }
            }
        }
    }
    return this.serializedPrincipal;
}
Also used : GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) SerializablePrincipal(org.apache.catalina.ha.session.SerializablePrincipal)

Example 2 with SerializablePrincipal

use of org.apache.catalina.ha.session.SerializablePrincipal in project geode by apache.

the class DeltaSession method getPrincipal.

public Principal getPrincipal() {
    if (this.principal == null && this.serializedPrincipal != null) {
        SerializablePrincipal sp = null;
        try {
            sp = (SerializablePrincipal) BlobHelper.deserializeBlob(this.serializedPrincipal);
        } catch (Exception e) {
            StringBuilder builder = new StringBuilder();
            builder.append(this).append(": Serialized principal contains a byte[] that cannot be deserialized due to the following exception");
            ((DeltaSessionManager) getManager()).getLogger().warn(builder.toString(), e);
            return null;
        }
        this.principal = sp.getPrincipal(((DeltaSessionManager) this.manager).getTheContext().getRealm());
        if (getManager() != null) {
            DeltaSessionManager mgr = (DeltaSessionManager) getManager();
            if (mgr.getLogger().isDebugEnabled()) {
                mgr.getLogger().debug(this + ": Deserialized principal: " + this.principal);
            // mgr.logCurrentStack();
            }
        }
    }
    return this.principal;
}
Also used : SerializablePrincipal(org.apache.catalina.ha.session.SerializablePrincipal) InvalidDeltaException(org.apache.geode.InvalidDeltaException) IOException(java.io.IOException)

Aggregations

SerializablePrincipal (org.apache.catalina.ha.session.SerializablePrincipal)2 IOException (java.io.IOException)1 GenericPrincipal (org.apache.catalina.realm.GenericPrincipal)1 InvalidDeltaException (org.apache.geode.InvalidDeltaException)1