Code example for Collection

Methods: sizetoArray

    public String[] getRoles(final Principal p) {
        CommonUtils.assertTrue(p instanceof AttributePrincipal,
                "Expected instance of AttributePrincipal but got " + p.getClass());
        final Collection<String> roles = getRoleCollection(p);
        final String[] array = new String[roles.size()];
        return array;
    /** {@inheritDoc} */ 
    public boolean hasRole(final Principal principal, final String role) {
        if ("*".equals(role)) {
            return true; 
        return getRoleCollection(principal).contains(role);
     * Retrieves the attributes for a Principal.  To make life easy this should NEVER return null.