Example usage for org.springframework.security.acls.domain IdentityUnavailableException IdentityUnavailableException

List of usage examples for org.springframework.security.acls.domain IdentityUnavailableException IdentityUnavailableException

Introduction

In this page you can find the example usage for org.springframework.security.acls.domain IdentityUnavailableException IdentityUnavailableException.

Prototype

public IdentityUnavailableException(String msg, Throwable t) 

Source Link

Document

Constructs an IdentityUnavailableException with the specified message and root cause.

Usage

From source file:net.projectmonkey.spring.acl.enhancement.identity.strategy.ConfigurableObjectIdentityRetrievalStrategy.java

@Override
public ObjectIdentity getObjectIdentity(final SecureObjectMapping mapping) {
    Assert.notNull(mapping, "mapping cannot be null");

    Class<?> identityType = mapping.getSecuredClass();
    Object id = mapping.getDomainObject();
    Assert.notNull(identityType, "identity type cannot be null");
    Assert.notNull(id, "domain object cannot be null");

    if (StringUtils.hasText(identifierMethod)) {
        try {//from w w  w.  j  ava  2 s  .c  o  m
            id = MethodUtil.invoke(id, identifierMethod);
        } catch (Exception e) {
            throw new IdentityUnavailableException("Could not extract identity from object " + id, e);
        }
        Assert.notNull(id, identifierMethod + "() is required to return a non-null value");
    }

    Assert.isInstanceOf(Serializable.class, id, "Getter must provide a return value of type Serializable");
    return new ObjectIdentityImpl(identityType, (Serializable) id);
}

From source file:org.bremersee.common.security.acls.model.CommonObjectIdentityRetrievalStrategy.java

public static String getId(final Object object) {
    Validate.notNull(object, "Object cannot be null.");

    Class<?> typeClass = ClassUtils.getUserClass(object.getClass());

    Object result;//w  w  w.j a v a  2 s .  co  m

    try {
        @SuppressWarnings("RedundantArrayCreation")
        Method method = typeClass.getMethod("getId", new Class[] {});
        result = method.invoke(object);
    } catch (Exception e) {
        throw new IdentityUnavailableException("Could not extract identity from object " + object, e);
    }

    Assert.notNull(result, "getId() is required to return a non-null value");
    return result.toString();
}